/**
 * AdTrax Invoicing - UI Skin
 * App-like Responsive Layout (2025 refresh)
 * Copyright (c) 2003 Jeffery Paris
 */

/* ==========================================================================
   Theme + Base
   ========================================================================== */

:root {
    --brand: #007AFF;
    --brand-strong: #0057D9;
    --success: #16A34A;
    --warning: #D97706;
    --danger: #DC2626;

    --bg: #F6F7FB;
    --surface: #FFFFFF;
    --surface-2: #F1F5F9;
    --border: rgba(15, 23, 42, 0.10);

    --text: #0F172A;
    --text-muted: rgba(15, 23, 42, 0.65);
    --text-light: rgba(15, 23, 42, 0.45);

    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 10px 20px rgba(15, 23, 42, 0.10);
    --shadow-lg: 0 24px 48px rgba(15, 23, 42, 0.18);

    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 18px;

    --sidebar-w: 264px;

    /* JS compatibility aliases */
    --primary: var(--brand);
    --color-success: var(--success);
    --color-warning: var(--warning);
    --color-danger: var(--danger);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    text-size-adjust: 100%;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg);
}

a {
    color: var(--brand);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

img {
    max-width: 100%;
    height: auto;
}

/* ==========================================================================
   Layout
   ========================================================================== */

.app-container {
    min-height: 100vh;
}

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: linear-gradient(180deg, #0B1224 0%, #0F172A 40%, #111B31 100%);
    color: rgba(226, 232, 240, 0.92);
    z-index: 120;
    display: flex;
    flex-direction: column;
    border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-header {
    padding: 18px 18px 14px 18px;
}

.sidebar-logo .logo-text {
    display: block;
    font-weight: 700;
    letter-spacing: -0.01em;
    font-size: 15px;
    color: rgba(226, 232, 240, 0.96);
}

.sidebar-user {
    padding: 12px 18px 16px 18px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(0, 122, 255, 0.16);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.10);
}

.avatar-initials {
    font-weight: 700;
    letter-spacing: 0.03em;
    color: rgba(226, 232, 240, 0.96);
    font-size: 14px;
}

.user-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.user-name {
    font-size: 14px;
    font-weight: 600;
    color: rgba(226, 232, 240, 0.96);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 12px;
    color: rgba(148, 163, 184, 0.92);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-nav {
    padding: 14px 10px 10px 10px;
    overflow: auto;
    flex: 1;
}

.nav-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-item {
    list-style: none;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 12px;
    color: rgba(226, 232, 240, 0.88);
    font-weight: 500;
    font-size: 14px;
    transition: background 120ms ease, color 120ms ease;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.07);
    color: rgba(226, 232, 240, 0.98);
    text-decoration: none;
}

.nav-link:focus-visible {
    outline: 3px solid rgba(0, 122, 255, 0.45);
    outline-offset: 2px;
}

.nav-icon svg {
    display: block;
}

.nav-divider {
    margin: 10px 12px 8px 12px;
    height: 1px;
    background: rgba(255, 255, 255, 0.08);
}

.nav-divider-text {
    display: block;
    margin: 10px 12px 6px 12px;
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(148, 163, 184, 0.90);
}

.nav-item.logout .nav-link {
    color: rgba(253, 186, 116, 0.96);
}

.sidebar-footer {
    padding: 12px 18px 16px 18px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 12px;
    color: rgba(148, 163, 184, 0.92);
}

.main-content {
    min-height: 100vh;
    margin-left: var(--sidebar-w);
}

.page-content {
    padding: 22px 22px 40px 22px;
    max-width: 1240px;
    margin: 0 auto;
}

/* ==========================================================================
   Mobile Header + Mobile Menu
   ========================================================================== */

.mobile-header {
    display: none;
}

.mobile-title {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.hamburger-btn {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--surface);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.hamburger-btn:hover {
    background: var(--surface-2);
}

.hamburger-btn:focus-visible {
    outline: 3px solid rgba(0, 122, 255, 0.35);
    outline-offset: 2px;
}

.hamburger-line {
    width: 18px;
    height: 2px;
    border-radius: 2px;
    background: rgba(15, 23, 42, 0.78);
    display: block;
}

.header-spacer {
    width: 40px;
    height: 40px;
}

.mobile-menu-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(2px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 160ms ease;
    z-index: 200;
}

.mobile-menu-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.mobile-menu {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: min(84vw, 360px);
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    transform: translateX(-105%);
    transition: transform 180ms ease;
    z-index: 210;
    display: flex;
    flex-direction: column;
}

.mobile-menu.active {
    transform: translateX(0);
}

.mobile-menu-header {
    padding: 16px 16px 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
}

.mobile-menu-logo .logo-text {
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--text);
    font-size: 16px;
}

.mobile-menu-close {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--surface);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.mobile-menu-close:hover {
    background: var(--surface-2);
}

.mobile-menu-user {
    padding: 14px 16px 16px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border);
}

.mobile-menu-user .user-avatar {
    background: rgba(0, 122, 255, 0.12);
    border-color: rgba(15, 23, 42, 0.10);
}

.mobile-menu-user .user-name {
    color: var(--text);
}

.user-email {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 220px;
}

.mobile-nav {
    list-style: none;
    padding: 10px 10px 14px 10px;
    overflow: auto;
    flex: 1;
}

.mobile-nav .nav-link {
    color: rgba(15, 23, 42, 0.86);
    font-weight: 600;
}

.mobile-nav .nav-link:hover {
    background: rgba(0, 122, 255, 0.08);
    color: rgba(15, 23, 42, 0.98);
}

.mobile-nav .nav-divider {
    background: rgba(15, 23, 42, 0.10);
}

.mobile-footer {
    display: none;
}

/* ==========================================================================
   Page Header + Text Helpers
   ========================================================================== */

.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
}

.page-header h1 {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin: 0;
}

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

/* ==========================================================================
   Cards
   ========================================================================== */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.card + .card {
    margin-top: 16px;
}

.card-header {
    padding: 16px 18px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.card-header h2 {
    font-size: 16px;
    font-weight: 800;
    letter-spacing: -0.01em;
    margin: 0;
}

.card-body,
.card form {
    padding: 18px;
}

/* ==========================================================================
   Dashboard Grids
   ========================================================================== */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 16px;
}

.stat-label {
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 600;
}

.stat-value {
    margin-top: 6px;
    font-size: 24px;
    font-weight: 900;
    letter-spacing: -0.02em;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 16px;
}

.dashboard-sidebar .card {
    position: sticky;
    top: 18px;
}

.quick-actions .btn {
    justify-content: center;
}

/* ==========================================================================
   Empty States
   ========================================================================== */

.empty-state {
    text-align: center;
    padding: 28px 18px;
}

.empty-state-icon {
    font-size: 34px;
    line-height: 1;
    margin-bottom: 10px;
}

.empty-state-title {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin: 0 0 6px 0;
}

.empty-state-text {
    color: var(--text-muted);
    margin: 0 0 16px 0;
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 12px;
    border: 1px solid transparent;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    transition: transform 60ms ease, background 120ms ease, border-color 120ms ease, color 120ms ease;
    user-select: none;
}

.btn:active {
    transform: translateY(1px);
}

.btn-primary {
    background: var(--brand);
    border-color: rgba(0, 0, 0, 0);
    color: #FFFFFF;
}

.btn-primary:hover {
    background: var(--brand-strong);
    text-decoration: none;
}

.btn-secondary {
    background: rgba(15, 23, 42, 0.06);
    border-color: rgba(15, 23, 42, 0.08);
    color: rgba(15, 23, 42, 0.92);
}

.btn-secondary:hover {
    background: rgba(15, 23, 42, 0.09);
    text-decoration: none;
}

.btn-outline {
    background: transparent;
    border-color: rgba(15, 23, 42, 0.14);
    color: rgba(15, 23, 42, 0.92);
}

.btn-outline:hover {
    background: rgba(0, 122, 255, 0.08);
    border-color: rgba(0, 122, 255, 0.28);
    text-decoration: none;
}

.btn-danger {
    background: rgba(220, 38, 38, 0.12);
    border-color: rgba(220, 38, 38, 0.18);
    color: var(--danger);
}

.btn-sm {
    padding: 7px 10px;
    font-size: 13px;
    border-radius: 10px;
}

.btn-block {
    width: 100%;
}

.btn.loading {
    opacity: 0.85;
    pointer-events: none;
}

.spinner-small {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.45);
    border-top-color: rgba(255, 255, 255, 0.95);
    animation: spin 0.8s linear infinite;
}

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

.btn-secondary .spinner-small,
.btn-outline .spinner-small {
    border: 2px solid rgba(15, 23, 42, 0.20);
    border-top-color: rgba(15, 23, 42, 0.70);
}

.mb-2 {
    margin-bottom: 10px;
}

/* ==========================================================================
   Forms
   ========================================================================== */

.form-group {
    margin-bottom: 14px;
}

label {
    display: block;
    font-weight: 700;
    font-size: 13px;
    color: rgba(15, 23, 42, 0.82);
    margin-bottom: 6px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="number"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 11px 12px;
    font-size: 15px;
    color: var(--text);
    background: var(--surface);
    border: 1px solid rgba(15, 23, 42, 0.14);
    border-radius: 12px;
    box-shadow: 0 1px 0 rgba(15, 23, 42, 0.03);
}

textarea {
    min-height: 96px;
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: rgba(0, 122, 255, 0.55);
    box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.16);
}

small {
    display: block;
    font-size: 12px;
    color: var(--text-light);
    margin-top: 6px;
}

/* Checkbox */
.checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 14px;
    color: rgba(15, 23, 42, 0.80);
}

.checkbox-label input {
    width: 18px;
    height: 18px;
}

/* ==========================================================================
   Tables
   ========================================================================== */

.data-table,
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--surface);
}

.data-table thead th,
table thead th {
    text-align: left;
    padding: 12px 14px;
    font-size: 13px;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--text-muted);
    background: rgba(15, 23, 42, 0.02);
    border-bottom: 1px solid var(--border);
}

.data-table tbody td,
table tbody td {
    padding: 12px 14px;
    border-bottom: 1px solid rgba(15, 23, 42, 0.06);
    vertical-align: top;
}

.data-table tbody tr:hover,
table tbody tr:hover {
    background: rgba(0, 122, 255, 0.05);
}

.table-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* ==========================================================================
   Filter Form + Pagination
   ========================================================================== */

.filter-form {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-end;
    margin-bottom: 14px;
}

.filter-form input,
.filter-form select {
    width: auto;
    min-width: 180px;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 16px;
}

.pagination a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    height: 38px;
    padding: 0 12px;
    border-radius: 12px;
    border: 1px solid rgba(15, 23, 42, 0.14);
    background: var(--surface);
    color: rgba(15, 23, 42, 0.92);
    font-weight: 700;
    font-size: 14px;
}

.pagination a:hover {
    background: rgba(0, 122, 255, 0.08);
    border-color: rgba(0, 122, 255, 0.25);
    text-decoration: none;
}

.pagination .page-info {
    font-size: 13px;
    color: var(--text-muted);
}

/* ==========================================================================
   Badges + Alerts
   ========================================================================== */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.02em;
    border: 1px solid rgba(15, 23, 42, 0.10);
    background: rgba(15, 23, 42, 0.04);
    color: rgba(15, 23, 42, 0.85);
}

.badge-success {
    background: rgba(22, 163, 74, 0.10);
    border-color: rgba(22, 163, 74, 0.16);
    color: var(--success);
}

.badge-warning {
    background: rgba(217, 119, 6, 0.10);
    border-color: rgba(217, 119, 6, 0.16);
    color: var(--warning);
}

.badge-danger {
    background: rgba(220, 38, 38, 0.10);
    border-color: rgba(220, 38, 38, 0.16);
    color: var(--danger);
}

.alert {
    position: relative;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    border: 1px solid rgba(15, 23, 42, 0.10);
    background: rgba(15, 23, 42, 0.04);
    margin-bottom: 14px;
    box-shadow: var(--shadow-sm);
}

.alert-success {
    background: rgba(22, 163, 74, 0.08);
    border-color: rgba(22, 163, 74, 0.18);
}

.alert-warning {
    background: rgba(217, 119, 6, 0.08);
    border-color: rgba(217, 119, 6, 0.18);
}

.alert-danger {
    background: rgba(220, 38, 38, 0.08);
    border-color: rgba(220, 38, 38, 0.18);
}

.alert button.alert-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    border: 1px solid rgba(15, 23, 42, 0.10);
    background: rgba(255, 255, 255, 0.70);
    cursor: pointer;
}

/* ==========================================================================
   Tabs
   ========================================================================== */

.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
}

.tab {
    padding: 9px 12px;
    border-radius: 12px;
    border: 1px solid rgba(15, 23, 42, 0.12);
    background: var(--surface);
    font-weight: 800;
    font-size: 13px;
    color: rgba(15, 23, 42, 0.90);
    cursor: pointer;
}

.tab.active {
    background: rgba(0, 122, 255, 0.12);
    border-color: rgba(0, 122, 255, 0.25);
    color: rgba(0, 122, 255, 0.95);
}

/* ==========================================================================
   Password Strength (JS)
   ========================================================================== */

.password-strength {
    margin-top: 10px;
}

.password-strength-bar {
    width: 100%;
    height: 8px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.10);
    overflow: hidden;
}

.password-strength-fill {
    height: 100%;
    width: 0;
    border-radius: 999px;
    transition: width 140ms ease;
    background: rgba(15, 23, 42, 0.35);
}

.password-strength-fill.weak { background: var(--danger); }
.password-strength-fill.fair { background: var(--warning); }
.password-strength-fill.good { background: var(--brand); }
.password-strength-fill.strong { background: var(--success); }

.password-strength-text {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
}


/* ==========================================================================
   Optional Header + Breadcrumbs (safe defaults)
   ========================================================================== */

.main-header {
    padding: 14px 22px;
    max-width: 1240px;
    margin: 0 auto;
}

.breadcrumbs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin: 10px 0 14px 0;
    color: var(--text-muted);
    font-size: 13px;
}

.breadcrumbs a {
    color: var(--text-muted);
    font-weight: 700;
}

.breadcrumbs a:hover {
    color: var(--brand);
    text-decoration: none;
}

.breadcrumb-sep {
    opacity: 0.5;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 1024px) {
    :root {
        --sidebar-w: 240px;
    }
}

@media (max-width: 900px) {
    .sidebar {
        display: none;
    }

    .main-content {
        margin-left: 0;
    }

    .mobile-header {
        display: flex;
        position: sticky;
        top: 0;
        z-index: 160;
        height: 56px;
        padding: 0 14px;
        gap: 12px;
        align-items: center;
        justify-content: space-between;
        background: rgba(255, 255, 255, 0.92);
        border-bottom: 1px solid rgba(15, 23, 42, 0.08);
        backdrop-filter: blur(10px);
    }

    .page-content {
        padding: 18px 14px 32px 14px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .dashboard-sidebar .card {
        position: static;
    }

    .mobile-footer {
        display: block;
        padding: 16px 14px 22px 14px;
        color: var(--text-muted);
        font-size: 12px;
        text-align: center;
    }
}

@media (max-width: 420px) {
    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .page-header h1 {
        font-size: 20px;
    }

    .filter-form input,
    .filter-form select {
        min-width: 0;
        width: 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        scroll-behavior: auto !important;
        transition: none !important;
        animation: none !important;
    }
}

/* Print */
@media print {
    .sidebar,
    .mobile-header,
    .mobile-menu,
    .mobile-menu-overlay,
    .btn,
    .filter-form,
    .pagination {
        display: none !important;
    }

    .main-content {
        margin: 0;
    }

    body {
        background: #FFFFFF;
    }
}
