/* SK Texcot Dashboard - Modern Design with Light/Dark Mode */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ==================== LIGHT MODE (DEFAULT) ==================== */
:root {
    /* Primary Colors */
    --primary: #1E5BB8;
    --primary-hover: #164a99;
    --primary-light: #e8f1fd;

    /* Background Colors */
    --bg-main: #F5F7FB;
    --bg-surface: #FFFFFF;
    --bg-secondary: #f8fafc;

    /* Text Colors */
    --text-primary: #1a202c;
    --text-secondary: #718096;
    --text-muted: #a0aec0;

    /* Border & Divider */
    --border-color: #e2e8f0;

    /* Status Colors */
    --success: #10b981;
    --success-bg: #ecfdf5;
    --danger: #ef4444;
    --danger-bg: #fef2f2;
    --warning: #f59e0b;
    --info: #3b82f6;

    /* Chart Colors */
    --chart-blue: #3b82f6;
    --chart-green: #10b981;
    --chart-purple: #8b5cf6;
    --chart-orange: #f59e0b;
    --chart-red: #ef4444;

    /* Shadows */
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px 0 rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 24px 0 rgba(0, 0, 0, 0.12);
}

/* ==================== DARK MODE ==================== */
[data-theme="dark"] {
    /* Primary Colors */
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --primary-light: #1e3a8a;

    /* Background Colors */
    --bg-main: #1a1f2e;
    --bg-surface: #242b3d;
    --bg-secondary: #1e2532;

    /* Text Colors */
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;

    /* Border & Divider */
    --border-color: #334155;

    /* Status Colors */
    --success: #10b981;
    --success-bg: #064e3b;
    --danger: #ef4444;
    --danger-bg: #7f1d1d;

    /* Chart Colors - Brighter for dark mode */
    --chart-blue: #60a5fa;
    --chart-green: #34d399;
    --chart-purple: #a78bfa;
    --chart-orange: #fbbf24;
    --chart-red: #f87171;

    /* Shadows - Darker for dark mode */
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 12px 0 rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 10px 24px 0 rgba(0, 0, 0, 0.6);
}

/* ==================== BASE STYLES ==================== */
.dashboard-container {
    padding: 0;
    background: var(--bg-main);
    min-height: 100vh;
}

/* ==================== PAGE HEADER ==================== */
.dashboard-page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.dashboard-page-header h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.dashboard-fy-selector {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    padding: 10px 20px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--primary);
    cursor: pointer;
    transition: all 0.2s;
}

.dashboard-fy-selector:hover {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.dashboard-fy-selector svg {
    width: 16px;
    height: 16px;
}

/* Live Clock - Now in Dashboard Content */
.live-clock {
    font-size: 14px;
    font-weight: 600;
    color: var(--primary);
    background: var(--bg-surface);
    padding: 8px 16px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    white-space: nowrap;
    /* display: none; Removed default hide since it's only in dashboard.html now */
}


/* ==================== KPI CARDS SECTION ==================== */

.dropdown-item.active {
    color: var(--primary);
    background: var(--primary-light);
    font-weight: 600;
}



@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==================== KPI CARDS SECTION ==================== */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
    margin-bottom: 24px;
}

.kpi-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
    position: relative;
    overflow: visible;
    /* Changed to visible to allow dropdown overflow if needed, though dropdown is absolute */
    min-height: 160px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* ... existing hover styles ... */
.kpi-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.kpi-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}

.kpi-card-title {
    font-size: 16px;
    /* Increased */
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: capitalize;
}

.kpi-card-subtitle {
    font-size: 13px;
    /* Increased */
    color: var(--text-muted);
    margin-top: 4px;
}

.kpi-card-icon {
    width: 48px;
    /* Increased */
    height: 48px;
    /* Increased */
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: var(--primary-light);
    color: var(--primary);
}

.kpi-card-icon svg {
    width: 24px;
    /* Increased */
    height: 24px;
    /* Increased */
}

.kpi-card-value {
    font-size: 36px;
    /* Increased substantially */
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0;
}

/* KPI Actions & Dropdown */
.kpi-card-actions {
    position: relative;
    margin-left: 8px;
}

.kpi-dropdown-btn {
    background: none;
    border: none;
    padding: 4px;
    border-radius: 4px;
    cursor: pointer;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.kpi-dropdown-btn:hover {
    background: var(--bg-secondary);
    color: var(--text-secondary);
}

.kpi-dropdown-btn svg {
    width: 16px;
    height: 16px;
}

.kpi-dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--shadow-md);
    min-width: 120px;
    z-index: 10;
    display: none;
    flex-direction: column;
    padding: 4px;
    margin-top: 4px;
}

.kpi-dropdown-menu.show {
    display: flex;
}

.kpi-dropdown-item {
    padding: 8px 12px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
    text-align: left;
}

.kpi-dropdown-item:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.kpi-dropdown-item.active {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
}

.kpi-card-trend {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
}

.kpi-trend-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 6px;
    font-weight: 600;
}

.kpi-trend-indicator.positive {
    background: var(--success-bg);
    color: var(--success);
}

.kpi-trend-indicator.negative {
    background: var(--danger-bg);
    color: var(--danger);
}

.kpi-trend-indicator svg {
    width: 12px;
    height: 12px;
}

.kpi-trend-text {
    color: var(--text-muted);
    font-size: 11px;
}

/* ==================== CHART SECTION ==================== */
.chart-section {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.chart-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.chart-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
}

.chart-container {
    position: relative;
    height: 350px;
    width: 100%;
}

/* ==================== BOTTOM GRID (CUSTOMERS + GST) ==================== */
.bottom-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

/* ==================== TOP CUSTOMERS PANEL ==================== */
.customers-panel {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--shadow-sm);
}

.customers-panel h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 20px 0;
}

/* KPI Accents */
.kpi-card.sales {
    border-left: 4px solid var(--chart-blue);
}

.kpi-card.purchase {
    border-left: 4px solid var(--chart-red);
}

.kpi-card.receivable {
    border-left: 4px solid var(--chart-orange);
}

.kpi-card.credit {
    border-left: 4px solid var(--success);
}

.kpi-card.debit {
    border-left: 4px solid var(--danger);
}

.customers-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 400px;
    overflow-y: auto;
}

.customer-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    box-shadow: var(--shadow-sm);
}

.customer-item:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-4px);
    border-color: var(--primary);
}

.customer-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    flex-shrink: 0;
}

.customer-info {
    flex: 1;
    min-width: 0;
}

.customer-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.customer-type {
    font-size: 11px;
    color: var(--text-muted);
}

.customer-amount {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
}

/* ==================== GST OVERVIEW PANEL ==================== */
.gst-panel {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--shadow-sm);
}

.gst-panel h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 20px 0;
}

.gst-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
}

.gst-chart-wrapper {
    width: 240px;
    height: 240px;
    position: relative;
}

.gst-chart-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    pointer-events: none;
}

.gst-chart-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.gst-chart-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
}

.gst-legend {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    width: 100%;
}

.gst-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border-radius: 6px;
}

.gst-legend-color {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    flex-shrink: 0;
}

.gst-legend-text {
    flex: 1;
    min-width: 0;
}

.gst-legend-label {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gst-legend-value {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

/* ==================== SCROLLBAR CUSTOM STYLING ==================== */
.customers-list::-webkit-scrollbar {
    width: 6px;
}

.customers-list::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 3px;
}

.customers-list::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.customers-list::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

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

/* Tablets and below */
@media (max-width: 1024px) {
    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .bottom-grid {
        grid-template-columns: 1fr;
    }
}

/* Mobile devices */
@media (max-width: 768px) {
    .dashboard-page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .kpi-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .chart-container {
        height: 280px;
    }

    .gst-legend {
        grid-template-columns: 1fr;
    }
}

/* ==================== THEME TRANSITION ==================== */
/* ==================== LEDGER SPECIFIC STYLES ==================== */
.sticky-header th {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--primary);
    /* Or header background color */
    color: white;
}

.text-success {
    color: var(--success);
}

.text-danger {
    color: var(--danger);
}

.text-bold {
    font-weight: 700;
}

/* Skeleton Loader */
.skeleton {
    background: #e2e8f0;
    background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 37%, #e2e8f0 63%);
    background-size: 400% 100%;
    animation: skeleton-loading 1.4s ease infinite;
    border-radius: 4px;
    height: 20px;
    width: 100%;
}

@keyframes skeleton-loading {
    0% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0 50%;
    }
}

.skeleton-row td {
    padding: 12px;
}

/* Sort Icons */
.sort-icon {
    display: inline-block;
    width: 0;
    height: 0;
    margin-left: 5px;
    vertical-align: middle;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-bottom: 4px solid rgba(255, 255, 255, 0.4);
    position: relative;
    top: -3px;
}

.sort-icon.asc {
    border-bottom: 4px solid #fff;
}

.sort-icon.desc {
    border-bottom: none;
    border-top: 4px solid #fff;
    top: 3px;
}

/* Pagination */
.pagination-container {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-top: 10px;
    gap: 10px;
}

.pagination-btn {
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    background: var(--bg-surface);
    border-radius: 4px;
    cursor: pointer;
}

.pagination-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination-info {
    font-size: 14px;
    color: var(--text-secondary);
}

/* Print Styles */
@media print {
    .app-container {
        margin: 0;
        padding: 0;
    }

    #sidebar-container,
    #header-container,
    .no-print {
        display: none !important;
    }

    #page-content {
        padding: 0;
        margin: 0;
    }

    .main-content {
        margin-left: 0;
    }

    .card,
    .table-container {
        box-shadow: none;
        border: none;
    }

    /* Ensure colors print */
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
}