/**
 * Common Layout Styles
 * Shared styles for header, footer, navigation, loading overlays, and alerts
 */

/* ===== Container ===== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* ===== Header ===== */
.header {
    background: white;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid var(--border-light);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    /*padding: 1rem;*/
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    text-decoration: none;
}

.logo:hover {
    color: var(--primary-hover);
}

/* ===== Hamburger Menu ===== */
.hamburger {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    z-index: 102;
    width: 40px;
    height: 40px;
}

.hamburger span {
    display: block;
    width: 25px;
    height: 3px;
    background: var(--text-primary);
    transition: all 0.3s ease;
    border-radius: 2px;
    transform-origin: center;
}

.hamburger.active span:nth-child(1) {
    transform: rotate(45deg) translateY(8px);
}

.hamburger.active span:nth-child(2) {
    opacity: 0;
    transform: scaleX(0);
}

.hamburger.active span:nth-child(3) {
    transform: rotate(-45deg) translateY(-8px);
}

/* ===== Navigation ===== */
.nav {
    display: flex;
    gap: 1.5rem;
    align-items: center;
    margin: 0 0 4px 0;
}

.nav a {
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.nav a:hover {
    color: var(--primary-color);
}

.nav a.active {
    color: var(--primary-color);
    font-weight: 600;
}

/* ===== Footer ===== */
.footer {
    background: var(--background-secondary);
    color: var(--text-secondary);
    text-align: center;
    padding: 2rem 1rem;
    margin-top: auto;
    border-top: 1px solid var(--border-light);
}

.footer p {
    margin: 0;
    font-size: var(--font-size-sm);
}

/* ===== Loading Overlay ===== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.loading-overlay.active {
    display: flex;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-light);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ===== Alerts ===== */
.alert {
    padding: 1rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.alert-success {
    background: rgba(0, 179, 113, 0.1);
    border: 1px solid var(--accent-success);
    color: var(--accent-success);
}

.alert-error {
    background: #fee;
    border: 1px solid var(--accent-error);
    color: var(--accent-error);
}

.alert-info {
    background: rgba(83, 111, 212, 0.1);
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
}

.alert-warning {
    background: rgba(251, 166, 75, 0.1);
    border: 1px solid var(--accent-warning);
    color: var(--accent-warning);
}

/* ===== Buttons ===== */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius-md);
    font-size: var(--font-size-base);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    text-decoration: none;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    color: white;
}

.btn-secondary {
    background: var(--text-secondary);
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background: var(--text-primary);
}

.btn-outline {
    background: white;
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
}

.btn-outline:hover:not(:disabled) {
    background: var(--primary-color);
    color: white !important;
}

.btn-danger {
    background: var(--accent-error);
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: #dc2626;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: var(--font-size-sm);
}

.btn-lg {
    padding: 1rem 2rem;
    font-size: var(--font-size-lg);
}

.btn-block {
    width: 100%;
}

/* ===== Links ===== */
.link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.link:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    margin-bottom: 1rem;
    font-size: var(--font-size-base);
}

.back-link:hover {
    color: var(--primary-color);
}

/* ===== Cards ===== */
.card {
    background: white;
    padding: 2rem;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
}

/* ===== Utilities ===== */
.text-center {
    text-align: center;
}

.text-left {
    text-align: left;
}

.text-right {
    text-align: right;
}

.text-muted {
    color: var(--text-secondary);
}

.text-primary {
    color: var(--primary-color);
}

.text-success {
    color: var(--accent-success);
}

.text-error {
    color: var(--accent-error);
}

.text-warning {
    color: var(--accent-warning);
}

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

.pt-0 { padding-top: 0; }
.pt-1 { padding-top: 0.5rem; }
.pt-2 { padding-top: 1rem; }
.pt-3 { padding-top: 1.5rem; }
.pt-4 { padding-top: 2rem; }

.pb-0 { padding-bottom: 0; }
.pb-1 { padding-bottom: 0.5rem; }
.pb-2 { padding-bottom: 1rem; }
.pb-3 { padding-bottom: 1.5rem; }
.pb-4 { padding-bottom: 2rem; }

/* ===== Responsive ===== */
@media (max-width: 768px) {
    /* Keep header on one line */
    .header-content {
        padding: 0.75rem 1rem;
        flex-direction: row;
        gap: 0;
    }

    /* Show hamburger button on mobile */
    .hamburger {
        display: flex;
        position: relative;
        z-index: 102;
    }

    /* Mobile menu backdrop - OUTSIDE the nav */
    body.menu-open::after {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 98;
        animation: fadeIn 0.3s ease;
    }

    @keyframes fadeIn {
        from { opacity: 0; }
        to { opacity: 1; }
    }

    /* Hide navigation by default on mobile */
    .nav {
        position: fixed;
        top: 0;
        right: 0;
        width: 280px;
        max-width: 85vw;
        height: 100vh;
        background: white;
        box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        padding: 4rem 0 1rem 0;
        margin: 0;
        transform: translateX(100%);
        transition: transform 0.3s ease;
        overflow-y: auto;
        z-index: 101;
    }

    /* Show navigation when active */
    .nav.active {
        transform: translateX(0);
    }

    /* Style nav links for mobile */
    .nav a,
    .nav button {
        padding: 1rem 1.5rem;
        border-bottom: 1px solid var(--border-light);
        text-align: left;
        width: 100%;
        background: transparent;
    }

    .nav a:hover {
        background: var(--background-secondary);
    }

    .nav a.active {
        background: rgba(83, 111, 212, 0.1);
        border-left: 3px solid var(--primary-color);
    }

    /* Style the user profile section on mobile */
    .nav > div {
        flex-direction: column;
        gap: 0;
        padding: 0;
        width: 100%;
    }

    .nav > div > a {
        padding: 1rem 1.5rem;
        border-bottom: 1px solid var(--border-light);
    }

    .nav > div > button {
        margin: 0;
        border-radius: 0;
        justify-content: flex-start;
        border: none;
        border-bottom: 1px solid var(--border-light);
    }

    /* Adjust buttons on mobile */
    .btn {
        padding: 0.6rem 1.2rem;
        font-size: var(--font-size-sm);
    }
}

/* Desktop only styles */
@media (min-width: 769px) {
    .hamburger {
        display: none !important;
    }
}
