/* ============================================================
   EasyCompta — Custom Stylesheet
   ============================================================ */

:root {
    --sidebar-width: 240px;
    --sidebar-bg: #1e293b;
    --sidebar-color: #cbd5e1;
    --sidebar-hover-bg: #334155;
    --sidebar-active-bg: #3b82f6;
    --sidebar-active-color: #ffffff;
    --topbar-height: 56px;
    --body-bg: #f1f5f9;
    --card-shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
}

/* ============================================================
   Layout
   ============================================================ */
body {
    background-color: var(--body-bg);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 0.9rem;
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background-color: var(--sidebar-bg);
    color: var(--sidebar-color);
    z-index: 1040;
    overflow-y: auto;
    transition: transform 0.25s ease-in-out;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,.07);
    min-height: var(--topbar-height);
    display: flex;
    align-items: center;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    text-decoration: none;
    color: #fff;
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: 0.3px;
}

.sidebar-brand:hover {
    color: #fff;
}

.sidebar-logo {
    max-height: 36px;
    max-width: 36px;
    object-fit: contain;
    border-radius: 4px;
}

.sidebar-brand-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-nav {
    padding: 0.75rem 0;
    list-style: none;
    margin: 0;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1.25rem;
    color: var(--sidebar-color);
    border-radius: 0;
    transition: background 0.15s, color 0.15s;
    font-size: 0.875rem;
    white-space: nowrap;
}

.sidebar-nav .nav-link i {
    font-size: 1rem;
    width: 1.2rem;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-nav .nav-link:hover {
    background-color: var(--sidebar-hover-bg);
    color: #fff;
}

.sidebar-nav .nav-link.active {
    background-color: var(--sidebar-active-bg);
    color: var(--sidebar-active-color);
}

.sidebar-nav .nav-link.text-danger-light {
    color: #fca5a5;
}

.sidebar-nav .nav-link.text-danger-light:hover {
    color: #fff;
    background-color: #ef4444;
}

.sidebar-divider {
    border-top: 1px solid rgba(255,255,255,.07);
    margin: 0.5rem 0;
    padding: 0;
}

.sidebar-footer {
    padding: 0.75rem 1.25rem;
    border-top: 1px solid rgba(255,255,255,.07);
    font-size: 0.75rem;
    color: #64748b;
}

/* Main wrapper */
#main-wrapper {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.25s ease-in-out;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 1020;
    min-height: var(--topbar-height);
    box-shadow: 0 1px 2px rgba(0,0,0,.06);
}

#page-content {
    flex: 1;
}

/* Sidebar collapsed state */
body.sidebar-collapsed .sidebar {
    transform: translateX(calc(-1 * var(--sidebar-width)));
}

body.sidebar-collapsed #main-wrapper {
    margin-left: 0;
}

/* ============================================================
   Cards
   ============================================================ */
.card {
    border: none;
    box-shadow: var(--card-shadow);
    border-radius: 0.5rem;
}

.card-header {
    background-color: #fff;
    border-bottom: 1px solid #e2e8f0;
    font-weight: 600;
    padding: 0.875rem 1.25rem;
}

.card-footer {
    background-color: #f8fafc;
    border-top: 1px solid #e2e8f0;
}

/* Stat cards */
.stat-card {
    border-radius: 0.5rem;
    padding: 1.25rem 1.5rem;
    color: #fff;
    box-shadow: var(--card-shadow);
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.stat-card .stat-icon {
    font-size: 2.5rem;
    opacity: 0.8;
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
}

.stat-card .stat-label {
    font-size: 0.8rem;
    opacity: 0.85;
    margin-top: 0.2rem;
}

.stat-card-blue   { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.stat-card-green  { background: linear-gradient(135deg, #10b981, #059669); }
.stat-card-orange { background: linear-gradient(135deg, #f59e0b, #d97706); }
.stat-card-purple { background: linear-gradient(135deg, #8b5cf6, #7c3aed); }

/* ============================================================
   Tables
   ============================================================ */
.table-responsive {
    border-radius: 0.375rem;
    overflow: hidden;
}

.table thead th {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background-color: #f8fafc;
    color: #64748b;
    border-bottom: 2px solid #e2e8f0;
    white-space: nowrap;
}

.table-hover tbody tr:hover {
    background-color: #f0f7ff;
}

/* ============================================================
   Status badges (custom)
   ============================================================ */
.badge {
    font-weight: 500;
    font-size: 0.75rem;
    padding: 0.35em 0.65em;
}

/* ============================================================
   Forms
   ============================================================ */
.form-label {
    font-weight: 500;
    font-size: 0.85rem;
    color: #374151;
    margin-bottom: 0.3rem;
}

.form-control,
.form-select {
    border-color: #d1d5db;
    font-size: 0.875rem;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-control:focus,
.form-select:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 0.2rem rgba(59,130,246,.2);
}

.required-star::after {
    content: ' *';
    color: #ef4444;
}

/* ============================================================
   Order line items table
   ============================================================ */
#items-table {
    font-size: 0.85rem;
}

#items-table th {
    background-color: #f1f5f9;
}

#items-table .item-total {
    font-weight: 600;
    color: #1e40af;
}

.totals-box {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 0.375rem;
    padding: 1rem 1.25rem;
    min-width: 280px;
}

.totals-box .totals-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.25rem 0;
    font-size: 0.875rem;
}

.totals-box .totals-row.total-ttc {
    font-size: 1.1rem;
    font-weight: 700;
    color: #1e40af;
    border-top: 2px solid #e2e8f0;
    margin-top: 0.5rem;
    padding-top: 0.5rem;
}

/* ============================================================
   Stock level indicators
   ============================================================ */
.stock-ok       { color: #059669; font-weight: 600; }
.stock-low      { color: #d97706; font-weight: 600; }
.stock-critical { color: #dc2626; font-weight: 600; }

/* ============================================================
   Page header
   ============================================================ */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1e293b;
    margin: 0;
}

/* ============================================================
   Filters bar
   ============================================================ */
.filters-bar {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    padding: 0.875rem 1.25rem;
    margin-bottom: 1.25rem;
}

/* ============================================================
   Flash alerts
   ============================================================ */
.flash-alert {
    border-radius: 0.5rem;
    margin-bottom: 1.25rem;
}

/* ============================================================
   Misc utilities
   ============================================================ */
.btn-action {
    padding: 0.2rem 0.5rem;
    font-size: 0.8rem;
}

.text-ht   { color: #64748b; }
.text-ttc  { color: #1e40af; font-weight: 700; }

.cursor-pointer { cursor: pointer; }

.timeline {
    position: relative;
    padding: 0;
    list-style: none;
}

.timeline-item {
    display: flex;
    gap: 1rem;
    padding: 0.5rem 0;
}

.timeline-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #3b82f6;
    flex-shrink: 0;
    margin-top: 0.25rem;
}

/* ============================================================
   Print / PDF styles
   ============================================================ */
@media print {
    .sidebar,
    #main-wrapper .topbar,
    .btn,
    .filters-bar,
    .page-header .btn,
    nav,
    #sidebarToggle {
        display: none !important;
    }

    #main-wrapper {
        margin-left: 0 !important;
    }

    #page-content {
        padding: 0 !important;
    }

    body {
        background: #fff;
    }

    .card {
        box-shadow: none;
        border: 1px solid #ddd;
    }

    .no-print {
        display: none !important;
    }
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(calc(-1 * var(--sidebar-width)));
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
    }

    #main-wrapper {
        margin-left: 0;
    }

    .stat-card {
        padding: 1rem;
    }

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

/* ============================================================
   Login page
   ============================================================ */
.login-wrapper {
    min-height: 100vh;
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card {
    width: 100%;
    max-width: 420px;
    border-radius: 1rem;
    box-shadow: 0 20px 60px rgba(0,0,0,.3);
    border: none;
}

.login-logo {
    font-size: 2.5rem;
    color: #3b82f6;
    margin-bottom: 0.5rem;
}

.login-title {
    font-size: 1.6rem;
    font-weight: 700;
    color: #1e293b;
}

.login-subtitle {
    color: #64748b;
    font-size: 0.875rem;
}

/* ============================================================
   PDF / Print view
   ============================================================ */
.pdf-wrapper {
    max-width: 800px;
    margin: 0 auto;
    background: #fff;
    padding: 2rem;
    box-shadow: 0 0 20px rgba(0,0,0,.1);
    font-size: 0.9rem;
}

.pdf-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #3b82f6;
}

.pdf-company-name {
    font-size: 1.4rem;
    font-weight: 700;
    color: #1e293b;
}

.pdf-doc-title {
    font-size: 1.8rem;
    font-weight: 700;
    color: #3b82f6;
    text-align: right;
}

.pdf-doc-number {
    font-size: 1rem;
    color: #64748b;
    text-align: right;
}

.pdf-addresses {
    display: flex;
    justify-content: space-between;
    margin-bottom: 2rem;
    gap: 2rem;
}

.pdf-address-block h6 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #94a3b8;
    margin-bottom: 0.5rem;
}

.pdf-items-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1.5rem;
}

.pdf-items-table th {
    background: #f1f5f9;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.6rem 0.75rem;
    text-align: left;
    border-bottom: 2px solid #e2e8f0;
    color: #64748b;
}

.pdf-items-table td {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid #f1f5f9;
}

.pdf-totals {
    float: right;
    min-width: 260px;
    clear: both;
}

.pdf-totals table {
    width: 100%;
    border-collapse: collapse;
}

.pdf-totals td {
    padding: 0.35rem 0.75rem;
    font-size: 0.875rem;
}

.pdf-totals .grand-total td {
    font-size: 1.1rem;
    font-weight: 700;
    color: #1e40af;
    border-top: 2px solid #e2e8f0;
    padding-top: 0.5rem;
}

.pdf-footer {
    margin-top: 3rem;
    padding-top: 1rem;
    border-top: 1px solid #e2e8f0;
    font-size: 0.75rem;
    color: #94a3b8;
    text-align: center;
}

.clearfix::after {
    content: '';
    display: table;
    clear: both;
}
