/* ══════════════════════════════════════════════════════════════
   LAYOUT — Desktop-first base, mobile overrides in @media
   Desktop is the DEFAULT. Mobile is the OVERRIDE.
   ══════════════════════════════════════════════════════════════ */

/* ── Main Content — desktop: sidebar offset ── */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}

/* ── Topbar — desktop defaults ── */
.topbar {
    position: sticky;
    top: 0;
    height: var(--topbar-height);
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 50;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 4px;
}

.page-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
}

.topbar-btn {
    position: relative;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-sm);
}

.topbar-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.topbar-btn svg { width: 20px; height: 20px; }

.notif-dot {
    position: absolute;
    top: 6px; right: 6px;
    width: 7px; height: 7px;
    background: var(--danger);
    border-radius: 50%;
}

/* Hidden on desktop */
.mobile-menu-btn { display: none; }

/* ── Page Content — desktop defaults ── */
.page-content {
    padding: 24px;
    max-width: 1400px;
}

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all var(--duration-fast);
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

.btn-primary {
    background: linear-gradient(135deg, var(--brand-primary), var(--brand-primary-dark));
    color: white;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}
.btn-primary:hover { box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color-strong);
    color: var(--text-secondary);
}
.btn-outline:hover {
    background: var(--bg-hover);
    border-color: var(--brand-primary);
    color: var(--text-primary);
}

.btn-full { width: 100%; }
.btn svg { width: 16px; height: 16px; }

.spinner {
    width: 16px; height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Section Title ── */
.section-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 12px;
}

/* ── Modal — centered dialog on desktop ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.modal {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}
.modal-header h2 { font-size: 1.05rem; font-weight: 700; }

.modal-close {
    background: none; border: none;
    color: var(--text-tertiary); cursor: pointer; padding: 4px;
}
.modal-close svg { width: 20px; height: 20px; }

.modal-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.modal-body .form-group label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.modal-body input[type="text"],
.modal-body input[type="email"],
.modal-body input[type="tel"],
.modal-body select {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-surface-2);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.9rem;
    outline: none;
    font-family: inherit;
}

.modal-body input:focus,
.modal-body select:focus {
    border-color: var(--brand-primary);
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 8px;
}

/* ── Gradients ── */
.gradient-green  { background: linear-gradient(135deg, #22c55e, #16a34a); }
.gradient-blue   { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.gradient-purple { background: linear-gradient(135deg, #8b5cf6, #7c3aed); }
.gradient-orange { background: linear-gradient(135deg, #f59e0b, #d97706); }


/* ══════════════════════════════════════════════════════════════
   MOBILE OVERRIDES — phones + portrait tablets
   ══════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
    .main-content {
        margin-left: 0;
        min-height: 100dvh;
    }

    .topbar {
        padding: 0 12px;
        background: var(--bg-surface);
        -webkit-backdrop-filter: blur(12px);
    }

    .mobile-menu-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        border: none;
        background: none;
        color: var(--text-primary);
        cursor: pointer;
        border-radius: var(--radius-sm);
        -webkit-tap-highlight-color: transparent;
    }

    .mobile-menu-btn:active {
        background: var(--bg-hover);
    }

    .mobile-menu-btn svg { width: 22px; height: 22px; }

    .page-title {
        font-size: 1rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .page-content {
        padding: 12px;
        max-width: 100%;
        overflow-x: hidden;
    }

    /* Modal → bottom sheet on mobile */
    .modal-overlay {
        align-items: flex-end;
    }

    .modal {
        max-width: 100%;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    }

    @keyframes slideUp {
        from { transform: translateY(100%); }
        to { transform: translateY(0); }
    }

    .modal-header {
        position: sticky;
        top: 0;
        background: var(--bg-surface);
        z-index: 1;
    }

    /* Table scroll */
    .table-responsive,
    .data-table-wrap {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* ── Small phone ── */
@media (max-width: 480px) {
    .page-content { padding: 8px; }
    .page-title { font-size: 0.9rem; }
    .topbar { height: 50px; }
    .topbar-right { gap: 2px; }
    .topbar-btn { width: 36px; height: 36px; padding: 6px; }
}

/* ── Tablet portrait ── */
@media (min-width: 481px) and (max-width: 768px) {
    .page-content { padding: 16px; }
    .page-title { font-size: 1.05rem; }
}

/* ── iPad landscape ── */
@media (min-width: 769px) and (max-width: 1024px) {
    .page-content {
        padding: 20px;
    }
}

/* ── Large desktop ── */
@media (min-width: 1200px) {
    .page-content {
        padding: 28px 32px;
    }
}
