/* ===================================
   Dashboard Support - Styles
   =================================== */

:root {
    --bg: #f8f9fb;
    --bg-card: #ffffff;
    --text: #1a1d23;
    --text-muted: #6b7280;
    --primary: #e64821;
    --primary-hover: #ff8352;
    --primary-light: #eff6ff;
    --border: #e5e7eb;
    --border-light: #f3f4f6;
    --success: #059669;
    --success-light: #ecfdf5;
    --warning: #d97706;
    --warning-light: #fffbeb;
    --danger: #dc2626;
    --danger-light: #fef2f2;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.06), 0 2px 4px rgba(0,0,0,0.04);
    --radius: 8px;
    --radius-lg: 12px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

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

a:hover {
    text-decoration: underline;
}

/* ===== LOGIN ===== */

.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, #fcc117 0%, #e64821 100%);
}

.login-box {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 40px;
    width: 100%;
    max-width: 420px;
}

.login-box h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 4px;
    color: var(--text);
}

.login-box .subtitle {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-bottom: 32px;
}

.login-box .logo {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    margin-bottom: 24px;
}

.login-box .logo svg {
    width: 28px;
    height: 28px;
    fill: white;
}

/* ===== FORMS ===== */

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

.form-group label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.875rem;
    color: var(--text);
    background: var(--bg-card);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
}

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

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

.btn-full {
    width: 100%;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}

.btn-outline:hover {
    background: var(--border-light);
    text-decoration: none;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8125rem;
}

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

.btn-danger:hover {
    background: #b91c1c;
}

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

.btn-success:hover {
    background: #047857;
}

/* ===== ALERTS ===== */

.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 0.875rem;
    margin-bottom: 20px;
}

.alert-error {
    background: var(--danger-light);
    color: var(--danger);
    border: 1px solid #fecaca;
}

.alert-success {
    background: var(--success-light);
    color: var(--success);
    border: 1px solid #a7f3d0;
}

.alert-warning {
    background: var(--warning-light);
    color: var(--warning);
    border: 1px solid #fde68a;
}

/* ===== LAYOUT ===== */

.layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    padding: 24px 0;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
}

.sidebar-header {
    padding: 0 20px 24px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
}

.sidebar-header h2 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-header h2 .icon {
    width: 32px;
    height: 32px;
    background: var(--primary);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-header h2 .icon svg {
    width: 18px;
    height: 18px;
    fill: white;
}

.sidebar-header .user-info {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-top: 8px;
}

.sidebar-nav {
    flex: 1;
    padding: 0 12px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
    transition: all 0.15s;
    margin-bottom: 2px;
}

.sidebar-nav a:hover {
    background: var(--border-light);
    color: var(--text);
    text-decoration: none;
}

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

.sidebar-nav a svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 16px 12px 0;
    border-top: 1px solid var(--border);
    margin-top: auto;
}

.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 32px;
    min-height: 100vh;
}

/* ===== HEADER ===== */

.page-header {
    margin-bottom: 32px;
}

.page-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
}

.page-header p {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.page-header-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
}

/* ===== STATS CARDS ===== */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    box-shadow: var(--shadow-sm);
}

.stat-card .stat-label {
    font-size: 0.8125rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 8px;
}

.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text);
}

.stat-card .stat-unit {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 400;
}

.stat-card .stat-change {
    font-size: 0.75rem;
    margin-top: 6px;
}

.stat-change.up {
    color: var(--success);
}

.stat-change.down {
    color: var(--danger);
}

/* ===== TABLES ===== */

.table-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    margin-bottom: 24px;
}

.table-card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.table-card-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    background: var(--border-light);
    padding: 12px 16px;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

tbody td {
    padding: 12px 16px;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--border-light);
    color: var(--text);
}

tbody tr:hover {
    background: var(--border-light);
}

tbody tr:last-child td {
    border-bottom: none;
}

/* ===== BADGES ===== */

.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-primary {
    background: var(--primary-light);
    color: var(--primary);
}

.badge-success {
    background: var(--success-light);
    color: var(--success);
}

.badge-warning {
    background: var(--warning-light);
    color: var(--warning);
}

/* ===== MONTH SELECTOR ===== */

.month-nav {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.month-nav .month-btn {
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 0.8125rem;
    font-weight: 500;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
}

.month-nav .month-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    text-decoration: none;
}

.month-nav .month-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* ===== BAR CHART (Pure CSS) ===== */

.chart-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
}

.chart-container h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 20px;
}

.bar-chart {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    height: 200px;
    padding-top: 20px;
    border-bottom: 1px solid var(--border);
}

.bar-chart .bar-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    height: 100%;
    justify-content: flex-end;
}

.bar-chart .bar {
    width: 100%;
    max-width: 48px;
    background: var(--primary);
    border-radius: 4px 4px 0 0;
    min-height: 4px;
    transition: opacity 0.15s;
    position: relative;
}

.bar-chart .bar:hover {
    opacity: 0.8;
}

.bar-chart .bar-label {
    font-size: 0.6875rem;
    color: var(--text-muted);
    text-align: center;
    margin-top: 8px;
}

.bar-chart .bar-value {
    font-size: 0.6875rem;
    color: var(--text);
    font-weight: 600;
}

/* ===== PAGINATION ===== */

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 16px;
}

.pagination a,
.pagination span {
    padding: 6px 12px;
    border-radius: var(--radius);
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-muted);
    border: 1px solid var(--border);
    transition: all 0.15s;
}

.pagination a:hover {
    border-color: var(--primary);
    color: var(--primary);
    text-decoration: none;
}

.pagination .current {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* ===== EMPTY STATE ===== */

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state svg {
    width: 48px;
    height: 48px;
    margin-bottom: 16px;
    opacity: 0.4;
}

.empty-state h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}

.empty-state p {
    font-size: 0.875rem;
}

/* ===== RESPONSIVE ===== */

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

    .main-content {
        margin-left: 0;
        padding: 20px 16px;
    }

    .mobile-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 12px 16px;
        background: var(--bg-card);
        border-bottom: 1px solid var(--border);
        position: sticky;
        top: 0;
        z-index: 50;
        margin: -20px -16px 20px;
    }

    .mobile-header h2 {
        font-size: 0.9375rem;
        font-weight: 700;
    }

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

    .stat-card {
        padding: 16px;
    }

    .stat-card .stat-value {
        font-size: 1.375rem;
    }

    .page-header h1 {
        font-size: 1.375rem;
    }

    .page-header-actions {
        flex-direction: column;
        align-items: flex-start;
    }

    .bar-chart {
        height: 150px;
    }

    .month-nav {
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 8px;
    }

    .month-nav .month-btn {
        white-space: nowrap;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* ===== ADMIN SPECIFIC ===== */

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

.client-form {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
    max-width: 500px;
}

.client-form h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 20px;
}

/* ===== TABS ===== */

.tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 24px;
}

.tabs a {
    padding: 12px 20px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    transition: all 0.15s;
    margin-bottom: -1px;
}

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

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

/* ===== KEYWORDS ===== */

.keywords {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.keyword {
    display: inline-block;
    padding: 2px 8px;
    background: var(--border-light);
    border-radius: 4px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ===== PROGRESS BAR ===== */

.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--border-light);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar .progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 4px;
    transition: width 0.3s;
}

/* ===== CONTRACT PROGRESS BAR ===== */

.contrat-progress {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 160px;
}

.contrat-progress-bar {
    width: 100%;
    height: 10px;
    background: var(--border-light);
    border-radius: 5px;
    overflow: hidden;
}

.contrat-progress-fill {
    height: 100%;
    border-radius: 5px;
    transition: width 0.3s;
}

.contrat-progress-label {
    font-size: 0.75rem;
}

.badge-danger {
    background: var(--danger-light);
    color: var(--danger);
}

/* Badges de statut des tickets Sellsy */
.badge-status-open,
.badge-status-actif {
    background: var(--success-light);
    color: var(--success);
}

.badge-status-pending,
.badge-status-en-attente {
    background: var(--warning-light);
    color: var(--warning);
}

.badge-status-closed,
.badge-status-ferme {
    background: var(--danger-light);
    color: var(--danger);
}

/* ===== 2FA PAGES ===== */

.login-box-2fa {
    max-width: 480px;
}

.qr-container {
    display: flex;
    justify-content: center;
    padding: 24px;
    margin-bottom: 16px;
    background: var(--border-light);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.qr-container img {
    border-radius: 4px;
}

.secret-container {
    text-align: center;
    margin-bottom: 28px;
}

.secret-label {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.secret-code {
    display: inline-block;
    font-family: 'SF Mono', 'Consolas', 'Liberation Mono', 'Menlo', monospace;
    font-size: 1.125rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    color: var(--text);
    background: var(--border-light);
    padding: 8px 16px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    user-select: all;
    margin-bottom: 8px;
}

.btn-copy {
    margin-left: 8px;
    vertical-align: middle;
}

.form-2fa {
    margin-top: 8px;
}

.input-otp {
    text-align: center;
    font-size: 1.5rem !important;
    font-weight: 700 !important;
    letter-spacing: 0.5em !important;
    font-family: 'SF Mono', 'Consolas', 'Liberation Mono', 'Menlo', monospace !important;
    padding: 14px 16px !important;
}

.input-otp::placeholder {
    letter-spacing: 0.3em;
    font-weight: 400;
    opacity: 0.35;
}

.link-cancel {
    display: block;
    text-align: center;
    margin-top: 20px;
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.link-cancel:hover {
    color: var(--danger);
}
