/* ============================================
   NiyaInnovation - Dashboard CSS
   ============================================ */

:root {
    --primary: #6c5ce7; --primary-dark: #5a4bd1; --primary-light: #7c6eea;
    --secondary: #00cec9; --accent: #fd79a8;
    --success: #00b894; --warning: #e17055; --danger: #d63031; --info: #0984e3;
    --dark: #f0f2f5; --dark-2: #ffffff; --dark-3: #f4f6f8;
    --surface: #f8f9fa; --surface-2: #e9ecef;
    --text: #1e1e3f; --text-muted: #64748b; --white: #fff;
    --glass-bg: rgba(0,0,0,0.03); --glass-border: rgba(0,0,0,0.09);
    --gradient: linear-gradient(135deg, #6c5ce7, #a29bfe);
    --sidebar-w: 260px; --topbar-h: 64px;
    --font: 'Inter', -apple-system, sans-serif;
    --radius: 12px; --radius-sm: 8px;
    --shadow: 0 4px 20px rgba(0,0,0,0.1);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font); background: var(--dark); color: var(--text); overflow-x: hidden; }

/* Layout */
.app-layout { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
    width: var(--sidebar-w); background: var(--dark-2);
    border-right: 1px solid var(--glass-border);
    box-shadow: 2px 0 12px rgba(0,0,0,0.06);
    display: flex; flex-direction: column; position: fixed;
    top: 0; left: 0; height: 100vh; z-index: 100;
    transition: var(--transition);
}
.sidebar-header {
    padding: 20px; display: flex; align-items: center; justify-content: space-between;
    border-bottom: 1px solid var(--glass-border);
}
.sidebar-logo {
    display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text);
}
.logo-icon {
    width: 36px; height: 36px; background: var(--gradient); border-radius: 10px;
    display: flex; align-items: center; justify-content: center; font-size: 16px;
}
.logo-text { font-size: 18px; font-weight: 800; }
.logo-text .accent { color: var(--primary-light); }
.sidebar-close { display: none; background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 18px; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 16px 12px; }
.nav-section { margin-bottom: 8px; }
.nav-label {
    font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.5px;
    color: var(--text-muted); padding: 8px 12px 4px; opacity: 0.6;
}
.nav-item {
    display: flex; align-items: center; gap: 12px; padding: 10px 12px;
    color: var(--text-muted); text-decoration: none; font-size: 14px; font-weight: 500;
    border-radius: var(--radius-sm); transition: var(--transition); margin: 2px 0;
}
.nav-item:hover { color: var(--primary); background: rgba(108,92,231,0.06); }
.nav-item.active {
    color: var(--primary); background: rgba(108, 92, 231, 0.1);
    border-left: 3px solid var(--primary);
}
.nav-item i { width: 20px; text-align: center; font-size: 15px; }

.sidebar-footer { padding: 16px; border-top: 1px solid var(--glass-border); }
.user-card {
    display: flex; align-items: center; gap: 10px; padding: 10px;
    background: var(--glass-bg); border-radius: var(--radius-sm);
}
.user-avatar {
    width: 36px; height: 36px; background: var(--gradient); border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 14px; color: var(--white);
}
.user-avatar.sm { width: 32px; height: 32px; font-size: 12px; border-radius: 8px; }
.user-name { font-size: 13px; font-weight: 600; color: var(--text); }
.user-role { font-size: 11px; color: var(--text-muted); }

/* Main Content */
.main-content {
    flex: 1; margin-left: var(--sidebar-w); min-height: 100vh;
    display: flex; flex-direction: column;
}

/* Topbar */
.topbar {
    height: var(--topbar-h); background: var(--dark-2);
    border-bottom: 1px solid var(--glass-border);
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 24px; position: sticky; top: 0; z-index: 50;
}
.topbar-left { display: flex; align-items: center; gap: 16px; }
.menu-toggle {
    display: none; background: none; border: none; color: var(--text);
    font-size: 18px; cursor: pointer; padding: 8px;
}
.breadcrumb { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.bc-item { color: var(--text-muted); }
.bc-item:last-child { color: var(--text); font-weight: 600; }
.bc-item + .bc-item::before { content: '/'; margin-right: 8px; color: var(--text-muted); opacity: 0.5; }

.topbar-right { display: flex; align-items: center; gap: 12px; }
.search-box {
    position: relative; display: flex; align-items: center;
}
.search-box i { position: absolute; left: 12px; color: var(--text-muted); font-size: 13px; }
.search-box input {
    padding: 8px 16px 8px 36px; background: var(--glass-bg); border: 1px solid var(--glass-border);
    border-radius: 50px; color: var(--text); font-size: 13px; width: 220px;
    font-family: var(--font); transition: var(--transition);
}
.search-box input:focus { outline: none; border-color: var(--primary); width: 280px; }
.topbar-btn {
    position: relative; background: none; border: none; color: var(--text-muted);
    font-size: 16px; cursor: pointer; padding: 8px; transition: var(--transition);
}
.topbar-btn:hover { color: var(--primary); }
.badge {
    position: absolute; top: 2px; right: 2px; width: 16px; height: 16px;
    background: var(--danger); border-radius: 50%; font-size: 10px;
    display: flex; align-items: center; justify-content: center;
    color: var(--white); font-weight: 700;
}
.topbar-user { position: relative; cursor: pointer; }
.dropdown-menu {
    display: none; position: absolute; top: 100%; right: 0;
    background: var(--dark-2); border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm); min-width: 180px; padding: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12); margin-top: 8px;
}
.dropdown-menu.show { display: block; }
.dropdown-item {
    display: flex; align-items: center; gap: 8px; padding: 8px 12px;
    color: var(--text-muted); text-decoration: none; font-size: 13px;
    border-radius: 6px; transition: var(--transition);
}
.dropdown-item:hover { background: rgba(108,92,231,0.06); color: var(--primary); }
.dropdown-divider { height: 1px; background: var(--glass-border); margin: 4px 0; }

/* Page Content */
.page-content { flex: 1; padding: 24px; }

/* Cards */
.card {
    background: var(--dark-2); border: 1px solid var(--glass-border);
    border-radius: var(--radius); padding: 24px; transition: var(--transition);
}
.card:hover { border-color: rgba(108, 92, 231, 0.3); }
.card-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--glass-border);
}
.card-title { font-size: 16px; font-weight: 700; }
.card-icon {
    width: 40px; height: 40px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center; font-size: 18px;
}

/* Stat Cards */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; margin-bottom: 24px; }
.stat-card {
    background: var(--dark-2); border: 1px solid var(--glass-border);
    border-radius: var(--radius); padding: 24px; position: relative; overflow: hidden;
}
.stat-card .stat-icon {
    width: 48px; height: 48px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; margin-bottom: 16px;
}
.stat-card .stat-icon.purple { background: rgba(108, 92, 231, 0.15); color: var(--primary-light); }
.stat-card .stat-icon.green { background: rgba(0, 184, 148, 0.15); color: var(--success); }
.stat-card .stat-icon.orange { background: rgba(253, 203, 110, 0.15); color: var(--warning); }
.stat-card .stat-icon.red { background: rgba(214, 48, 49, 0.15); color: var(--danger); }
.stat-card .stat-icon.blue { background: rgba(9, 132, 227, 0.15); color: var(--info); }
.stat-card .stat-icon.cyan { background: rgba(0, 206, 201, 0.15); color: var(--secondary); }
.stat-value { font-size: 1.8rem; font-weight: 800; margin-bottom: 4px; }
.stat-label { font-size: 13px; color: var(--text-muted); }
.stat-trend { position: absolute; top: 16px; right: 16px; font-size: 12px; font-weight: 600; }
.stat-trend.up { color: var(--success); }
.stat-trend.down { color: var(--danger); }

/* Grid Layout */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }

/* Table */
.table-container { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
    text-align: left; padding: 12px 16px; font-size: 12px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted);
    border-bottom: 1px solid var(--glass-border); white-space: nowrap;
}
tbody td {
    padding: 14px 16px; font-size: 14px; border-bottom: 1px solid rgba(0,0,0,0.05);
    white-space: nowrap;
}
tbody tr { transition: var(--transition); }
tbody tr:hover { background: rgba(108,92,231,0.04); }

/* Status Badges */
.status {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 12px; border-radius: 50px; font-size: 12px; font-weight: 600;
}
.status.paid, .status.payee { background: rgba(0, 184, 148, 0.15); color: var(--success); }
.status.pending, .status.en-attente, .status.brouillon { background: rgba(253, 203, 110, 0.15); color: var(--warning); }
.status.overdue, .status.annulee { background: rgba(214, 48, 49, 0.15); color: var(--danger); }
.status.partial, .status.partielle { background: rgba(9, 132, 227, 0.15); color: var(--info); }
.status.sent, .status.emise, .status.envoyee { background: rgba(108, 92, 231, 0.15); color: var(--primary-light); }
.status.accepted, .status.accepte { background: rgba(0, 184, 148, 0.15); color: var(--success); }
.status.refused, .status.refuse { background: rgba(214, 48, 49, 0.15); color: var(--danger); }
.status.converted, .status.converti { background: rgba(0, 206, 201, 0.15); color: var(--secondary); }

/* Action Buttons */
.actions { display: flex; gap: 6px; }
.action-btn {
    width: 32px; height: 32px; border: none; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; font-size: 13px; transition: var(--transition);
    background: var(--glass-bg); color: var(--text-muted);
}
.action-btn:hover { color: var(--text); }
.action-btn.edit:hover { background: rgba(108, 92, 231, 0.2); color: var(--primary-light); }
.action-btn.delete:hover { background: rgba(214, 48, 49, 0.2); color: var(--danger); }
.action-btn.view:hover { background: rgba(0, 206, 201, 0.2); color: var(--secondary); }
.action-btn.download:hover { background: rgba(0, 184, 148, 0.2); color: var(--success); }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 20px; border-radius: var(--radius-sm);
    font-family: var(--font); font-weight: 600; font-size: 13px;
    text-decoration: none; border: none; cursor: pointer;
    transition: var(--transition); white-space: nowrap;
}
.btn-primary { background: var(--gradient); color: var(--white); }
.btn-primary:hover { box-shadow: 0 4px 20px rgba(108, 92, 231, 0.4); }
.btn-success { background: var(--success); color: var(--white); }
.btn-danger { background: var(--danger); color: var(--white); }
.btn-outline {
    background: transparent; color: var(--text); border: 1px solid var(--glass-border);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: 6px 14px; font-size: 12px; }
.btn-icon { padding: 8px; }

/* Form Controls */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }
.form-control {
    width: 100%; padding: 10px 14px;
    background: var(--dark); border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm); color: var(--text);
    font-family: var(--font); font-size: 14px; transition: var(--transition);
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.15); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.form-row-4 { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 16px; }
.form-help { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* Modal */
.modal-overlay {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px); z-index: 1000;
    align-items: center; justify-content: center; padding: 24px;
}
.modal-overlay.show { display: flex; }
.modal {
    background: var(--dark-2); border: 1px solid var(--glass-border);
    border-radius: var(--radius); width: 100%; max-width: 700px;
    max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}
.modal.modal-lg { max-width: 900px; }
.modal.modal-xl { max-width: 1100px; }
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 20px 24px; border-bottom: 1px solid var(--glass-border);
}
.modal-header h3 { font-size: 18px; font-weight: 700; }
.modal-close {
    background: none; border: none; color: var(--text-muted);
    font-size: 18px; cursor: pointer; padding: 4px;
}
.modal-body { padding: 24px; }
.modal-footer {
    display: flex; justify-content: flex-end; gap: 12px;
    padding: 16px 24px; border-top: 1px solid var(--glass-border);
}

/* Page Header */
.page-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 24px;
}
.page-title { font-size: 1.5rem; font-weight: 800; }
.page-subtitle { font-size: 14px; color: var(--text-muted); margin-top: 4px; }

/* Filters */
.filters {
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    margin-bottom: 20px; padding: 16px;
    background: var(--glass-bg); border: 1px solid var(--glass-border);
    border-radius: var(--radius);
}
.filter-input {
    padding: 8px 14px; background: var(--dark); border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm); color: var(--text); font-size: 13px;
    font-family: var(--font);
}
.filter-input:focus { outline: none; border-color: var(--primary); }

/* Lines (invoice/quote items) */
.lines-table { width: 100%; margin-top: 16px; }
.lines-table th {
    text-align: left; padding: 8px; font-size: 12px;
    color: var(--text-muted); border-bottom: 1px solid var(--glass-border);
}
.lines-table td { padding: 8px; }
.lines-table input, .lines-table select {
    width: 100%; padding: 8px; background: var(--dark); border: 1px solid var(--glass-border);
    border-radius: 6px; color: var(--text); font-size: 13px; font-family: var(--font);
}
.line-total { text-align: right; font-weight: 600; }
.add-line-btn {
    display: inline-flex; align-items: center; gap: 6px; margin-top: 12px;
    padding: 8px 16px; background: rgba(108, 92, 231, 0.1); border: 1px dashed var(--primary);
    border-radius: 8px; color: var(--primary-light); font-size: 13px;
    cursor: pointer; font-family: var(--font); transition: var(--transition);
}
.add-line-btn:hover { background: rgba(108, 92, 231, 0.2); }

/* Totals */
.totals-box {
    margin-top: 20px; margin-left: auto; width: 300px;
    background: var(--glass-bg); border: 1px solid var(--glass-border);
    border-radius: var(--radius); padding: 16px;
}
.total-row {
    display: flex; justify-content: space-between; padding: 6px 0;
    font-size: 14px; color: var(--text-muted);
}
.total-row.grand { font-size: 18px; font-weight: 800; color: var(--text); padding-top: 12px; border-top: 1px solid var(--glass-border); margin-top: 8px; }

/* Pagination */
.pagination {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    margin-top: 20px;
}
.page-btn {
    padding: 6px 12px; background: var(--glass-bg); border: 1px solid var(--glass-border);
    border-radius: 6px; color: var(--text-muted); font-size: 13px;
    cursor: pointer; transition: var(--transition); font-family: var(--font);
}
.page-btn:hover, .page-btn.active { background: var(--primary); color: var(--white); border-color: var(--primary); }

/* Empty State */
.empty-state {
    text-align: center; padding: 60px 20px;
}
.empty-state i { font-size: 48px; color: var(--text-muted); margin-bottom: 16px; opacity: 0.3; }
.empty-state h4 { font-size: 18px; margin-bottom: 8px; color: var(--text-muted); }
.empty-state p { font-size: 14px; color: var(--text-muted); opacity: 0.6; }

/* Toast */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast {
    padding: 14px 20px; border-radius: var(--radius-sm); color: var(--white);
    font-size: 14px; box-shadow: var(--shadow); min-width: 300px;
    animation: toastIn 0.3s ease;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.info { background: var(--primary); }
.toast.warning { background: #e17055; }
@keyframes toastIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* Tabs */
.tabs { display: flex; gap: 4px; margin-bottom: 24px; border-bottom: 1px solid var(--glass-border); }
.tab {
    padding: 10px 20px; font-size: 14px; font-weight: 600;
    color: var(--text-muted); cursor: pointer; border-bottom: 2px solid transparent;
    transition: var(--transition); background: none; border-top: none; border-left: none; border-right: none;
    font-family: var(--font);
}
.tab:hover { color: var(--primary); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* Upload Area */
.upload-area {
    border: 2px dashed var(--glass-border); border-radius: var(--radius);
    padding: 40px; text-align: center; cursor: pointer; transition: var(--transition);
}
.upload-area:hover { border-color: var(--primary); background: rgba(108, 92, 231, 0.05); }
.upload-area i { font-size: 36px; color: var(--text-muted); margin-bottom: 12px; }
.upload-area p { font-size: 14px; color: var(--text-muted); }

/* Loading */
.loading { text-align: center; padding: 40px; }
.spinner {
    width: 40px; height: 40px; border: 3px solid var(--glass-border);
    border-top-color: var(--primary); border-radius: 50%;
    animation: spin 0.8s linear infinite; margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Responsive */
@media (max-width: 1024px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .form-row, .form-row-3, .form-row-4 { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-close { display: block; }
    .main-content { margin-left: 0; }
    .menu-toggle { display: block; }
    .search-box { display: none; }
    .stats-grid { grid-template-columns: 1fr; }
    .page-content { padding: 16px; }
    .topbar { padding: 0 16px; }
    .totals-box { width: 100%; }
}
