/* Root Variables */
:root {
    --primary-color: #d4a853;
    --primary-dark: #b8923f;
    --secondary-color: #2c3e50;
    --success-color: #27ae60;
    --danger-color: #e74c3c;
    --warning-color: #f39c12;
    --info-color: #3498db;
    --light-bg: #f8f9fa;
    --dark-bg: #1a1a2e;
    --sidebar-width: 260px;
    --header-height: 70px;
    --card-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    --transition: all 0.3s ease;
}

/* Global Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--light-bg);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: linear-gradient(180deg, var(--dark-bg) 0%, #16213e 100%);
    padding: 20px 0;
    z-index: 1000;
    transition: var(--transition);
    overflow-y: auto;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 0 20px 30px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 20px;
}

.sidebar-header .logo {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    background: var(--primary-color);
}

.sidebar-header h4 {
    color: #fff;
    font-weight: 600;
    margin: 0;
}

.sidebar .nav-item {
    margin: 5px 15px;
}

.sidebar .nav-link {
    color: rgba(255, 255, 255, 0.7);
    padding: 12px 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: var(--transition);
    text-decoration: none;
}

.sidebar .nav-link:hover,
.sidebar .nav-link.active {
    background: rgba(212, 168, 83, 0.2);
    color: var(--primary-color);
}

.sidebar .nav-link i {
    width: 20px;
    text-align: center;
}

/* Main Content */
.main-content {
    margin-right: var(--sidebar-width);
    min-height: 100vh;
    padding: 20px 30px;
    transition: var(--transition);
}

/* Dashboard Header */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid #e0e0e0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.header-left h2 {
    color: var(--secondary-color);
    font-weight: 700;
    margin: 0;
}

.sidebar-toggle {
    display: none;
    font-size: 1.5rem;
    color: var(--secondary-color);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.header-right .form-select {
    width: 180px;
    border-radius: 10px;
    border: 1px solid #e0e0e0;
    padding: 10px 15px;
}

.header-right .btn-primary {
    background: var(--primary-color);
    border: none;
    border-radius: 10px;
    padding: 10px 20px;
    font-weight: 500;
}

.header-right .btn-primary:hover {
    background: var(--primary-dark);
}

/* KPI Cards */
.kpi-card {
    background: #fff;
    border-radius: 16px;
    padding: 25px;
    display: flex;
    align-items: center;
    gap: 20px;
    box-shadow: var(--card-shadow);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 100%;
    height: 4px;
}

.kpi-card.sales::before { background: var(--primary-color); }
.kpi-card.profit::before { background: var(--success-color); }
.kpi-card.expenses::before { background: var(--danger-color); }
.kpi-card.units::before { background: var(--info-color); }

.kpi-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
}

.kpi-icon {
    width: 60px;
    height: 60px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.kpi-card.sales .kpi-icon { background: rgba(212, 168, 83, 0.15); color: var(--primary-color); }
.kpi-card.profit .kpi-icon { background: rgba(39, 174, 96, 0.15); color: var(--success-color); }
.kpi-card.expenses .kpi-icon { background: rgba(231, 76, 60, 0.15); color: var(--danger-color); }
.kpi-card.units .kpi-icon { background: rgba(52, 152, 219, 0.15); color: var(--info-color); }

.kpi-content h6 {
    color: #888;
    font-size: 0.9rem;
    margin-bottom: 5px;
}

.kpi-content h3 {
    color: var(--secondary-color);
    font-weight: 700;
    font-size: 1.6rem;
    margin-bottom: 5px;
}

.trend {
    font-size: 0.85rem;
    font-weight: 500;
}

.trend.up { color: var(--success-color); }
.trend.down { color: var(--danger-color); }

/* Chart Cards */
.chart-card {
    background: #fff;
    border-radius: 16px;
    padding: 25px;
    box-shadow: var(--card-shadow);
    height: 100%;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.chart-header h5 {
    color: var(--secondary-color);
    font-weight: 600;
    margin: 0;
}

.chart-actions .btn {
    border-radius: 8px;
    padding: 5px 12px;
    font-size: 0.85rem;
}

.chart-actions .btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: #fff;
}

/* Table Cards */
.table-card {
    background: #fff;
    border-radius: 16px;
    padding: 25px;
    box-shadow: var(--card-shadow);
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.table-header h5 {
    color: var(--secondary-color);
    font-weight: 600;
    margin: 0;
}

.table {
    margin: 0;
}

.table thead th {
    background: var(--light-bg);
    color: var(--secondary-color);
    font-weight: 600;
    border: none;
    padding: 15px;
}

.table tbody td {
    padding: 15px;
    vertical-align: middle;
    border-color: #f0f0f0;
}

.table tbody tr:hover {
    background: rgba(212, 168, 83, 0.05);
}

.total-row {
    background: var(--light-bg) !important;
}

.profit-cell {
    color: var(--success-color);
    font-weight: 600;
}

.quarter-badge {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.quarter-badge.q1 { background: rgba(52, 152, 219, 0.15); color: var(--info-color); }
.quarter-badge.q2 { background: rgba(39, 174, 96, 0.15); color: var(--success-color); }
.quarter-badge.q3 { background: rgba(243, 156, 18, 0.15); color: var(--warning-color); }
.quarter-badge.q4 { background: rgba(212, 168, 83, 0.15); color: var(--primary-color); }

/* Progress Bars */
.progress {
    height: 8px;
    border-radius: 4px;
    background: #e9ecef;
}

/* Dashboard Sections */
.dashboard-section {
    display: none;
}

.dashboard-section.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Report Generator */
.report-generator {
    background: #fff;
    border-radius: 16px;
    padding: 25px;
    box-shadow: var(--card-shadow);
}

.report-generator h5 {
    color: var(--secondary-color);
    font-weight: 600;
    margin-bottom: 20px;
}

.report-generator h5 i {
    color: var(--primary-color);
    margin-left: 10px;
}

/* Report Preview */
.report-preview {
    background: #fff;
    border-radius: 16px;
    padding: 40px;
    box-shadow: var(--card-shadow);
    border: 1px solid #e0e0e0;
}

.report-header {
    display: flex;
    align-items: center;
    gap: 20px;
    padding-bottom: 30px;
    border-bottom: 2px solid var(--primary-color);
    margin-bottom: 30px;
}

.report-header img {
    width: 80px;
    height: 80px;
    border-radius: 12px;
    background: var(--primary-color);
}

.report-header h3 {
    color: var(--secondary-color);
    font-weight: 700;
    margin-bottom: 5px;
}

.report-header p {
    color: #888;
    margin: 0;
}

.report-section {
    margin-bottom: 30px;
}

.report-section h4 {
    color: var(--secondary-color);
    font-weight: 600;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #e0e0e0;
}

.report-section p {
    color: #555;
    line-height: 1.8;
}

.report-section ul, .report-section ol {
    color: #555;
    line-height: 2;
    padding-right: 20px;
}

.report-kpis {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}

.report-kpi {
    background: var(--light-bg);
    padding: 20px;
    border-radius: 12px;
    text-align: center;
}

.report-kpi .label {
    display: block;
    color: #888;
    font-size: 0.9rem;
    margin-bottom: 8px;
}

.report-kpi .value {
    display: block;
    color: var(--secondary-color);
    font-size: 1.2rem;
    font-weight: 700;
}

/* Responsive */
@media (max-width: 1400px) {
    .kpi-content h3 {
        font-size: 1.4rem;
    }
}

@media (max-width: 1200px) {
    .report-kpis {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .main-content {
        padding: 20px;
    }
}

@media (max-width: 992px) {
    .sidebar {
        transform: translateX(100%);
        box-shadow: -5px 0 30px rgba(0, 0, 0, 0.3);
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .main-content {
        margin-right: 0;
        padding: 15px;
    }
    
    .sidebar-toggle {
        display: block;
    }
    
    /* Overlay when sidebar is open */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
    }
    
    .sidebar-overlay.active {
        display: block;
    }
    
    .chart-card {
        padding: 15px;
    }
    
    .table-card {
        padding: 15px;
    }
}

@media (max-width: 768px) {
    .dashboard-header {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
        padding-bottom: 15px;
        margin-bottom: 20px;
    }
    
    .header-left {
        justify-content: space-between;
    }
    
    .header-left h2 {
        font-size: 1.3rem;
    }
    
    .header-right {
        width: 100%;
        flex-direction: column;
        gap: 10px;
    }
    
    .header-right .form-select {
        width: 100%;
    }
    
    .header-right .btn-primary {
        width: 100%;
    }
    
    /* KPI Cards Mobile */
    .kpi-card {
        padding: 15px;
        gap: 15px;
    }
    
    .kpi-icon {
        width: 50px;
        height: 50px;
        font-size: 1.2rem;
    }
    
    .kpi-content h6 {
        font-size: 0.8rem;
    }
    
    .kpi-content h3 {
        font-size: 1.2rem;
    }
    
    .trend {
        font-size: 0.75rem;
    }
    
    /* Charts Mobile */
    .chart-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .chart-header h5 {
        font-size: 1rem;
    }
    
    .chart-actions {
        width: 100%;
        display: flex;
        gap: 5px;
    }
    
    .chart-actions .btn {
        flex: 1;
        font-size: 0.75rem;
        padding: 5px 8px;
    }
    
    /* Tables Mobile */
    .table-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .table-header .btn {
        width: 100%;
    }
    
    .table {
        font-size: 0.85rem;
    }
    
    .table thead th,
    .table tbody td {
        padding: 10px 8px;
        white-space: nowrap;
    }
    
    .quarter-badge {
        padding: 3px 8px;
        font-size: 0.75rem;
    }
    
    /* Report Section Mobile */
    .report-kpis {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .report-kpi {
        padding: 15px;
    }
    
    .report-preview {
        padding: 15px;
    }
    
    .report-header {
        flex-direction: column;
        text-align: center;
        gap: 15px;
    }
    
    .report-header h3 {
        font-size: 1.1rem;
    }
    
    .report-section h4 {
        font-size: 1rem;
    }
    
    .report-section p,
    .report-section ul,
    .report-section ol {
        font-size: 0.9rem;
    }
    
    /* Report Generator Mobile */
    .report-generator {
        padding: 15px;
    }
    
    .report-generator .row {
        gap: 10px;
    }
    
    /* Row gaps */
    .row.g-4 {
        --bs-gutter-y: 1rem;
    }
}

@media (max-width: 576px) {
    .main-content {
        padding: 10px;
    }
    
    .dashboard-header {
        padding-bottom: 10px;
        margin-bottom: 15px;
    }
    
    .header-left h2 {
        font-size: 1.1rem;
    }
    
    /* KPI Cards Extra Small */
    .kpi-card {
        padding: 12px;
        gap: 12px;
    }
    
    .kpi-icon {
        width: 45px;
        height: 45px;
        font-size: 1rem;
        border-radius: 10px;
    }
    
    .kpi-content h3 {
        font-size: 1rem;
    }
    
    /* Charts Extra Small */
    .chart-card {
        padding: 12px;
        border-radius: 12px;
    }
    
    .chart-header h5 {
        font-size: 0.9rem;
    }
    
    /* Tables Extra Small */
    .table-card {
        padding: 10px;
        border-radius: 12px;
    }
    
    .table {
        font-size: 0.75rem;
    }
    
    .table thead th,
    .table tbody td {
        padding: 8px 5px;
    }
    
    /* Sidebar Mobile */
    .sidebar {
        width: 280px;
    }
    
    .sidebar-header {
        padding: 0 15px 20px;
    }
    
    .sidebar-header h4 {
        font-size: 1.1rem;
    }
    
    .sidebar .nav-link {
        padding: 10px 15px;
        font-size: 0.9rem;
    }
    
    /* Report Preview Extra Small */
    .report-preview {
        padding: 12px;
        border-radius: 12px;
    }
    
    .report-header img {
        width: 60px;
        height: 60px;
    }
    
    .report-header h3 {
        font-size: 1rem;
    }
    
    .report-kpi .label {
        font-size: 0.8rem;
    }
    
    .report-kpi .value {
        font-size: 1rem;
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    .nav-link,
    .btn,
    .form-select {
        min-height: 44px;
    }
    
    .sidebar .nav-link {
        padding: 14px 20px;
    }
    
    .kpi-card:hover {
        transform: none;
    }
}

/* Landscape phone */
@media (max-width: 896px) and (orientation: landscape) {
    .kpi-card {
        padding: 12px;
    }
    
    .kpi-icon {
        width: 40px;
        height: 40px;
    }
    
    .kpi-content h3 {
        font-size: 1.1rem;
    }
}

/* Print Styles */
@media print {
    .sidebar, .dashboard-header, .report-generator {
        display: none !important;
    }
    
    .main-content {
        margin: 0;
        padding: 0;
    }
    
    .report-preview {
        box-shadow: none;
        border: none;
    }
}
