/* ========================================
   Factures GrowMedia - Styles
   ======================================== */

:root {
    --primary: #4285F4;
    --primary-dark: #3367D6;
    --secondary: #34A853;
    --danger: #EA4335;
    --warning: #FBBC05;
    --dark: #1a1a2e;
    --dark-2: #16213e;
    --dark-3: #0f3460;
    --gray-dark: #2d2d44;
    --gray-medium: #4a4a6a;
    --gray-light: #8888a8;
    --light: #f5f5f7;
    --white: #ffffff;
    --border-radius: 8px;
    --shadow: 0 4px 6px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 40px rgba(0,0,0,0.2);
    --transition: all 0.3s ease;
    --sidebar-width: 240px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--dark);
    color: var(--light);
    line-height: 1.6;
    min-height: 100vh;
}
a { color: var(--primary); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--primary-dark); }

/* ========================================
   Login Page
   ======================================== */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--dark) 0%, var(--dark-2) 50%, var(--dark-3) 100%);
}
.login-container { width: 100%; max-width: 400px; padding: 20px; }
.login-box {
    background: var(--gray-dark);
    border-radius: 12px;
    padding: 40px;
    box-shadow: var(--shadow-lg);
    text-align: center;
}
.login-header h1 { font-size: 1.8rem; margin-bottom: 8px; color: var(--white); }
.login-header p { color: var(--gray-light); margin-bottom: 30px; }
.login-footer { margin-top: 24px; }
.login-footer p { color: var(--gray-light); font-size: 0.85rem; }

/* ========================================
   Alerts
   ======================================== */
.alert {
    padding: 12px 16px;
    border-radius: var(--border-radius);
    margin-bottom: 20px;
    font-size: 0.9rem;
}
.alert-error { background: rgba(234,67,53,0.15); color: #ff6b6b; border: 1px solid rgba(234,67,53,0.3); }
.alert-success { background: rgba(52,168,83,0.15); color: #69db7c; border: 1px solid rgba(52,168,83,0.3); }
.alert-warning { background: rgba(251,188,5,0.15); color: #ffd43b; border: 1px solid rgba(251,188,5,0.3); }

/* ========================================
   Buttons
   ======================================== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--border-radius);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: var(--transition);
    text-decoration: none;
}
.btn-primary { background: var(--primary); color: var(--white); }
.btn-primary:hover { background: var(--primary-dark); color: var(--white); }
.btn-secondary { background: var(--gray-dark); color: var(--light); border: 1px solid var(--gray-medium); }
.btn-secondary:hover { background: var(--gray-medium); color: var(--white); }
.btn-success { background: var(--secondary); color: var(--white); }
.btn-success:hover { background: #2d9249; color: var(--white); }
.btn-danger { background: var(--danger); color: var(--white); }
.btn-danger:hover { background: #d33426; color: var(--white); }
.btn-warning { background: var(--warning); color: var(--dark); }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-google {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    padding: 14px 24px;
    background: var(--white);
    color: #333;
    border-radius: var(--border-radius);
    font-weight: 500;
    font-size: 1rem;
}
.btn-google:hover { background: #f0f0f0; color: #333; box-shadow: var(--shadow); }
.btn-icon { font-size: 1.1rem; }

/* ========================================
   Layout
   ======================================== */
.app-layout { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--dark-2);
    border-right: 1px solid var(--gray-dark);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: transform 0.3s ease;
}
.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--gray-dark);
}
.sidebar-header h1 {
    font-size: 1.1rem;
    color: var(--white);
    font-weight: 700;
}
.sidebar-header span {
    font-size: 0.75rem;
    color: var(--gray-light);
}
.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: var(--gray-light);
    font-size: 0.9rem;
    transition: var(--transition);
    border-left: 3px solid transparent;
}
.sidebar-nav a:hover { color: var(--white); background: rgba(255,255,255,0.05); }
.sidebar-nav a.active {
    color: var(--primary);
    background: rgba(66,133,244,0.1);
    border-left-color: var(--primary);
}
.sidebar-nav a svg { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar-nav .nav-divider {
    height: 1px;
    background: var(--gray-dark);
    margin: 8px 20px;
}
.sidebar-user {
    padding: 16px 20px;
    border-top: 1px solid var(--gray-dark);
    display: flex;
    align-items: center;
    gap: 10px;
}
.sidebar-user img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
}
.sidebar-user .user-info { flex: 1; min-width: 0; }
.sidebar-user .user-name {
    font-size: 0.85rem;
    color: var(--white);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}
.sidebar-user .user-email {
    font-size: 0.7rem;
    color: var(--gray-light);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}
.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 30px;
    background: var(--dark-2);
    border-bottom: 1px solid var(--gray-dark);
    position: sticky;
    top: 0;
    z-index: 50;
}
.top-bar h2 { font-size: 1.2rem; color: var(--white); }
.top-bar-actions { display: flex; gap: 10px; align-items: center; }
.content { padding: 30px; }

/* Mobile hamburger */
.hamburger {
    display: none;
    background: none;
    border: none;
    color: var(--white);
    cursor: pointer;
    padding: 4px;
}
.hamburger svg { width: 24px; height: 24px; }

/* ========================================
   Cards & Widgets
   ======================================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}
.stat-card {
    background: var(--gray-dark);
    border-radius: var(--border-radius);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
}
.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}
.stat-icon.income { background: rgba(52,168,83,0.15); color: var(--secondary); }
.stat-icon.expense { background: rgba(234,67,53,0.15); color: var(--danger); }
.stat-icon.balance { background: rgba(66,133,244,0.15); color: var(--primary); }
.stat-icon.invoices { background: rgba(251,188,5,0.15); color: var(--warning); }
.stat-info h3 { font-size: 1.5rem; color: var(--white); line-height: 1.2; }
.stat-info p { font-size: 0.8rem; color: var(--gray-light); }

.card {
    background: var(--gray-dark);
    border-radius: var(--border-radius);
    padding: 24px;
    margin-bottom: 20px;
}
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.card-header h3 { font-size: 1.05rem; color: var(--white); }

/* ========================================
   Tables
   ======================================== */
.table-wrapper { overflow-x: auto; }
table {
    width: 100%;
    border-collapse: collapse;
}
table th, table td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    font-size: 0.88rem;
}
table th {
    color: var(--gray-light);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}
table td { color: var(--light); }
table tbody tr:hover { background: rgba(255,255,255,0.03); }
table .text-right { text-align: right; }
table .text-center { text-align: center; }
.amount-positive { color: var(--secondary); font-weight: 600; }
.amount-negative { color: var(--danger); font-weight: 600; }
.amount-neutral { color: var(--primary); font-weight: 600; }

/* Status badges */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}
.badge-draft { background: rgba(136,136,168,0.2); color: var(--gray-light); }
.badge-sent { background: rgba(66,133,244,0.2); color: var(--primary); }
.badge-paid { background: rgba(52,168,83,0.2); color: var(--secondary); }
.badge-cancelled { background: rgba(234,67,53,0.2); color: var(--danger); }

/* ========================================
   Forms
   ======================================== */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-size: 0.85rem;
    color: var(--gray-light);
    margin-bottom: 4px;
    font-weight: 500;
}
.form-control {
    width: 100%;
    padding: 10px 14px;
    background: var(--dark);
    border: 1px solid var(--gray-medium);
    border-radius: var(--border-radius);
    color: var(--white);
    font-size: 0.9rem;
    transition: var(--transition);
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(66,133,244,0.2);
}
.form-control::placeholder { color: var(--gray-medium); }
select.form-control { cursor: pointer; }
textarea.form-control { min-height: 80px; resize: vertical; }
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}
.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--gray-dark);
}

/* ========================================
   Modal
   ======================================== */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-overlay.active { display: flex; }
.modal {
    background: var(--gray-dark);
    border-radius: 12px;
    width: 100%;
    max-width: 700px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.modal-header h3 { font-size: 1.1rem; color: var(--white); }
.modal-close {
    background: none;
    border: none;
    color: var(--gray-light);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}
.modal-close:hover { color: var(--white); }
.modal-body { padding: 24px; }
.modal-footer {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding: 16px 24px;
    border-top: 1px solid rgba(255,255,255,0.06);
}

/* ========================================
   Invoice Items (dynamic rows)
   ======================================== */
.invoice-items-table { width: 100%; }
.invoice-items-table th { font-size: 0.8rem; }
.invoice-items-table td { padding: 6px 8px; }
.invoice-items-table .form-control { padding: 8px 10px; font-size: 0.85rem; }
.invoice-items-table .btn-remove {
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 4px;
}
.invoice-items-table .btn-remove:hover { color: #ff6b6b; }
.invoice-totals {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
    margin-top: 16px;
    font-size: 0.9rem;
}
.invoice-totals .total-row {
    display: flex;
    gap: 20px;
    align-items: center;
}
.invoice-totals .total-label { color: var(--gray-light); min-width: 100px; text-align: right; }
.invoice-totals .total-value { color: var(--white); font-weight: 600; min-width: 100px; text-align: right; }
.invoice-totals .total-grand .total-value { font-size: 1.2rem; color: var(--secondary); }

/* ========================================
   Filters
   ======================================== */
.filters-bar {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.filters-bar .form-control { width: auto; min-width: 140px; }
.filters-bar select.form-control { min-width: 160px; }

/* ========================================
   Quarterly summary
   ======================================== */
.quarter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    margin-bottom: 30px;
}
.quarter-card {
    background: var(--dark);
    border-radius: var(--border-radius);
    padding: 16px;
    border: 1px solid rgba(255,255,255,0.06);
}
.quarter-card h4 {
    font-size: 0.9rem;
    color: var(--gray-light);
    margin-bottom: 12px;
}
.quarter-card .quarter-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 0.88rem;
}
.quarter-card .quarter-row.total {
    border-top: 1px solid var(--gray-medium);
    margin-top: 4px;
    padding-top: 8px;
    font-weight: 600;
}

/* ========================================
   Empty state
   ======================================== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--gray-light);
}
.empty-state svg { width: 64px; height: 64px; margin-bottom: 16px; opacity: 0.4; }
.empty-state h3 { color: var(--white); margin-bottom: 8px; }
.empty-state p { margin-bottom: 20px; }

/* ========================================
   Loading
   ======================================== */
.loading { text-align: center; padding: 40px; color: var(--gray-light); }
.spinner {
    display: inline-block;
    width: 32px;
    height: 32px;
    border: 3px solid var(--gray-dark);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ========================================
   Pagination
   ======================================== */
.pagination {
    display: flex;
    gap: 4px;
    justify-content: center;
    margin-top: 20px;
}
.pagination a, .pagination span {
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 0.85rem;
    color: var(--gray-light);
    border: 1px solid var(--gray-dark);
}
.pagination a:hover { background: var(--gray-dark); color: var(--white); }
.pagination .active { background: var(--primary); color: var(--white); border-color: var(--primary); }

/* ========================================
   Chart container
   ======================================== */
.chart-container {
    position: relative;
    width: 100%;
    height: 300px;
}

/* ========================================
   File upload
   ======================================== */
.file-upload {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
}
.file-upload input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}
.file-upload .file-name {
    font-size: 0.85rem;
    color: var(--gray-light);
}
.pdf-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--primary);
    font-size: 0.85rem;
}
.pdf-link:hover { text-decoration: underline; }

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .hamburger { display: block; }
    .content { padding: 16px; }
    .top-bar { padding: 12px 16px; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .modal { max-width: 100%; margin: 10px; }
    .filters-bar { flex-direction: column; align-items: stretch; }
    .filters-bar .form-control { width: 100%; }
}
@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
}
