/* ========================================
   DASHBOARD — Lemonade Pink/Black Design
   Bold accents, layered dark mode, high contrast
   ======================================== */

/* Page Wrapper */
.db-wrapper {
    width: 100%;
    height: calc(100vh - 60px);
    overflow: hidden;
    background: var(--bg-secondary);
    display: flex;
    flex-direction: column;
    position: relative;
}

.db-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow-y: auto;
    position: relative;
    z-index: var(--z-base);
}

.db-container::-webkit-scrollbar {
    width: 4px;
}

.db-container::-webkit-scrollbar-track {
    background: transparent;
}

.db-container::-webkit-scrollbar-thumb {
    background: var(--border-secondary);
    border-radius: 2px;
}

/* ========================================
   LOADING SPINNER
   ======================================== */

.db-spinner-overlay {
    position: fixed;
    inset: 0;
    background: var(--overlay-light);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-modal);
}

.db-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.db-spinner-ring {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-primary);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.db-spinner p {
    color: var(--text-body);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
}

/* ========================================
   DASHBOARD CONTENT
   ======================================== */

.db-content {
    padding: 16px 24px 24px 24px;
}

/* ========================================
   STAT CARDS — Color-coded with pink accent
   ======================================== */

.db-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.db-stat-card {
    background: var(--surface);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    padding: 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: var(--shadow-sm);
    transition: all 0.25s ease;
    position: relative;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

a.db-stat-card,
a.db-stat-card:hover,
a.db-stat-card:focus,
a.db-stat-card:visited {
    text-decoration: none;
    color: inherit;
}

/* Subtle pink top accent line */
.db-stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--accent-primary);
    opacity: 0;
    transition: opacity 0.25s ease;
}

.db-stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.db-stat-card:hover::before {
    opacity: 1;
}

.db-stat-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    background: var(--accent-light);
    color: var(--accent-primary);
}

/* Per-card icon colors — Light mode */
.db-stat-card.stat-posted .db-stat-icon {
    background: rgba(255, 0, 131, 0.1);
    color: #ff0083;
}
.db-stat-card.stat-checkedin .db-stat-icon {
    background: rgba(42, 118, 228, 0.1);
    color: #2A76E4;
}
.db-stat-card.stat-weighedin .db-stat-icon {
    background: rgba(255, 176, 28, 0.1);
    color: #FFB01C;
}
.db-stat-card.stat-invoice .db-stat-icon {
    background: rgba(42, 213, 189, 0.1);
    color: #2AD5BD;
}
.db-stat-card.stat-lab .db-stat-icon {
    background: rgba(124, 58, 237, 0.1);
    color: #7C3AED;
}

/* Per-card icon colors — Dark mode (brighter) */
[data-theme="dark"] .db-stat-card.stat-posted .db-stat-icon {
    background: rgba(255, 0, 131, 0.16);
    color: #ff3da0;
}
[data-theme="dark"] .db-stat-card.stat-checkedin .db-stat-icon {
    background: rgba(74, 144, 226, 0.16);
    color: #6aacf5;
}
[data-theme="dark"] .db-stat-card.stat-weighedin .db-stat-icon {
    background: rgba(255, 224, 113, 0.16);
    color: #FFE071;
}
[data-theme="dark"] .db-stat-card.stat-invoice .db-stat-icon {
    background: rgba(42, 213, 189, 0.16);
    color: #4de8d3;
}
[data-theme="dark"] .db-stat-card.stat-lab .db-stat-icon {
    background: rgba(196, 181, 253, 0.16);
    color: #C4B5FD;
}

/* Dark mode stat card — use surface for clear separation from bg */
[data-theme="dark"] .db-stat-card {
    background: var(--surface);
    border-color: var(--border-primary);
}

.db-stat-info {
    flex: 1;
    min-width: 0;
}

.db-stat-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}

.db-stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
    font-family: var(--font-numeric);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
}

/* ========================================
   DASHBOARD SECTIONS
   ======================================== */

.db-section {
    background: var(--surface);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
}

.db-section:hover {
    box-shadow: var(--shadow-md);
}

.db-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-primary);
}

.db-section-title {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.db-section-title i {
    color: var(--accent-primary);
    font-size: 15px;
}

.db-section-subtitle {
    font-size: var(--text-xs);
    color: var(--text-muted);
    font-weight: var(--font-medium);
    margin-left: 6px;
    padding: 3px 10px;
    background: var(--bg-secondary);
    border-radius: var(--radius-full);
    border: 1px solid var(--border-primary);
}

.db-view-all {
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--accent-primary);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    transition: all 0.15s ease;
}

.db-view-all:hover {
    background: var(--accent-light);
}

.db-view-all i {
    font-size: 10px;
}

/* Dark mode section — elevated from page bg */
[data-theme="dark"] .db-section {
    background: var(--surface);
    border-color: var(--border-primary);
}

/* ========================================
   WEIGHBRIDGE STATUS
   ======================================== */

.db-hub-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

.db-wb-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-sm);
    padding: 16px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    position: relative;
    overflow: hidden;
}

.db-wb-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 3px;
    height: 100%;
    background: var(--accent-primary);
    border-radius: 0 2px 2px 0;
}

.db-wb-card:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* Dark mode wb card — use surface-inset for depth */
[data-theme="dark"] .db-wb-card {
    background: var(--surface-inset);
    border-color: var(--border-primary);
}

.db-wb-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.db-wb-name {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.db-wb-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 6px var(--success);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.db-wb-weight {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    font-family: var(--font-numeric);
    font-variant-numeric: tabular-nums;
    margin-bottom: 6px;
    line-height: 1;
    letter-spacing: -0.02em;
}

.db-wb-weight .unit {
    font-size: 14px;
    font-weight: 500;
    margin-left: 2px;
    color: var(--text-muted);
}

.db-wb-time {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 4px;
}

.db-wb-time i {
    color: var(--accent-primary);
    font-size: 10px;
}

.db-no-data {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
    font-size: var(--text-sm);
    font-style: italic;
}

/* ========================================
   ORDER SECTIONS — Sales & Purchase
   Professional, compact, enterprise-grade
   ======================================== */

.db-orders {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.db-order-section {
    background: var(--surface);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    padding: 16px;
    box-shadow: var(--shadow-sm);
    transition: all 0.25s ease;
}

.db-order-section:hover {
    box-shadow: var(--shadow-md);
}

[data-theme="dark"] .db-order-section {
    background: var(--surface);
    border-color: var(--border-primary);
}

.db-order-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.db-order-header i {
    color: var(--accent-primary);
    font-size: 14px;
}

.db-order-viewall {
    margin-left: auto;
    font-size: 11px;
    font-weight: 600;
    color: var(--accent-primary);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: var(--radius-full);
    transition: all 0.15s ease;
}

.db-order-viewall:hover {
    background: var(--accent-light);
    text-decoration: none;
}

.db-order-viewall i {
    font-size: 9px;
}

.db-order-cards {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.db-order-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    text-decoration: none;
    color: inherit;
    transition: all 0.15s ease;
    position: relative;
    cursor: pointer;
    border-left: 3px solid transparent;
    border-bottom: 1px solid var(--border-primary);
}

.db-order-card:last-child {
    border-bottom: none;
}

.db-order-card:hover {
    background: var(--bg-secondary);
    text-decoration: none;
    color: inherit;
}

a.db-order-card,
a.db-order-card:hover,
a.db-order-card:visited {
    text-decoration: none;
    color: inherit;
}

[data-theme="dark"] .db-order-card:hover {
    background: var(--surface-inset);
}

.db-order-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.db-order-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-body);
    flex: 1;
}

.db-order-count {
    font-size: 18px;
    font-weight: 700;
    font-family: var(--font-numeric);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
    line-height: 1;
    color: var(--text-primary);
}

/* Status indicator colors — subtle left border + dot */
.db-order-open { border-left-color: #2AD5BD; }
.db-order-open .db-order-dot { background: #2AD5BD; }

.db-order-pending { border-left-color: #FFB01C; }
.db-order-pending .db-order-dot { background: #FFB01C; }

.db-order-future { border-left-color: #2A76E4; }
.db-order-future .db-order-dot { background: #2A76E4; }

[data-theme="dark"] .db-order-open { border-left-color: #4de8d3; }
[data-theme="dark"] .db-order-open .db-order-dot { background: #4de8d3; }
[data-theme="dark"] .db-order-pending { border-left-color: #FFE071; }
[data-theme="dark"] .db-order-pending .db-order-dot { background: #FFE071; }
[data-theme="dark"] .db-order-future { border-left-color: #6aacf5; }
[data-theme="dark"] .db-order-future .db-order-dot { background: #6aacf5; }

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */

@media (max-width: 1200px) {
    .db-stats {
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    }
}

@media (max-width: 768px) {
    .db-content {
        padding: 12px 16px;
    }

    .db-stats {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .db-orders {
        grid-template-columns: 1fr;
    }

    .db-section {
        padding: 16px;
        margin-bottom: 14px;
    }

    .db-hub-grid {
        grid-template-columns: 1fr;
    }

    .db-stat-value {
        font-size: 22px;
    }

    .db-wb-weight {
        font-size: 22px;
    }

    .db-order-count {
        font-size: 22px;
    }
}

@media (max-width: 480px) {
    .db-stat-icon {
        width: 36px;
        height: 36px;
        font-size: 15px;
    }

    .db-stat-value {
        font-size: 20px;
    }

    .db-stats {
        grid-template-columns: 1fr;
    }
}

/* ========================================
   ANIMATIONS
   ======================================== */

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
