/* ===============================================
   1. Base Cards
   =============================================== */

.card {
    background-color: var(--bg-card, #ffffff);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    border: 1px solid var(--border-color, #e5e7eb);
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.card__header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color-light, #f1f5f9);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.card__title { 
    font-size: 1rem; 
    font-weight: 700; 
    color: var(--text-primary, #111827);
    font-family: 'Poppins', sans-serif;
}
.card__dropdown, .card__actions { display: flex; gap: 8px; }

/* ===============================================
   2. Dashboard Statistics
   =============================================== */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 24px;
    margin-bottom: 24px;
}

.stat-card { 
    padding: 24px; 
    border-radius: 8px;
    background: var(--bg-card, #ffffff);
    border: 1px solid var(--border-color, #e5e7eb);
}
.stat-card__top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}
.stat-card__label { 
    color: var(--text-muted, #64748b); 
    font-size: 0.85rem; 
    font-weight: 600; 
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.stat-card__icon {
    width: 40px; 
    height: 40px;
    border-radius: 6px; /* Subtle rounding */
    display: flex; 
    align-items: center; 
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
}

/* SaaS Color Palette for Icons */
.stat-card__icon--primary { background: rgba(37, 99, 235, 0.1); color: #2563eb; }
.stat-card__icon--info { background: rgba(59, 130, 246, 0.1); color: #3b82f6; }
.stat-card__icon--success { background: rgba(16, 185, 129, 0.1); color: #10b981; }
.stat-card__icon--warning { background: rgba(245, 158, 11, 0.1); color: #f59e0b; }
.stat-card__icon--danger { background: rgba(239, 68, 68, 0.1); color: #ef4444; }
.stat-card__icon--gold { background: rgba(245, 166, 35, 0.1); color: #f5a623; }

.stat-card__value { 
    font-size: 1.75rem; 
    font-weight: 800; 
    margin-bottom: 4px; 
    color: var(--text-primary, #111827);
    font-family: 'Poppins', sans-serif;
    line-height: 1.2;
}
.stat-card__trend { 
    font-size: 0.75rem; 
    font-weight: 500; 
    color: var(--text-muted, #64748b);
}

/* ===============================================
   3 & 4. Wallet Balance & Order Status (Supporting Structures)
   =============================================== */
/* Base styles to support the new dashboard.html layout */

.wallet-grid {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    gap: 24px;
    margin-bottom: 24px;
    align-items: stretch;
}

.balance-card {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.balance-card__label {
    color: var(--text-muted, #64748b);
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
}
.balance-card__amount {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text-primary, #111827);
    line-height: 1.1;
}
.balance-card__divider {
    height: 1px;
    background: var(--border-color, #e5e7eb);
    margin: 12px 0;
}
.balance-card__substats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}
.sub-stat {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.sub-stat__label {
    font-size: 0.75rem;
    color: var(--text-muted, #64748b);
    font-weight: 600;
    text-transform: uppercase;
}
.sub-stat__value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary, #111827);
}

.status-card {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}
.status-card__header {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary, #111827);
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color-light, #f1f5f9);
}
.status-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}
.status-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.status-item__label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted, #64748b);
}
.status-item__value {
    font-size: 1.5rem;
    font-weight: 800;
}
.status-item--pending .status-item__value { color: #f59e0b; }
.status-item--completed .status-item__value { color: #10b981; }
.status-item--cancelled .status-item__value { color: #ef4444; }

/* ===============================================
   5. Dashboard Rows
   =============================================== */

.dashboard-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
    margin-bottom: 24px;
}
.dashboard-row:last-child { margin-bottom: 0; }

/* ===============================================
   6. Revenue Chart
   =============================================== */

.chart-card { 
    padding: 24px; 
}
.chart-placeholder { 
    height: 300px; 
    margin-top: 20px; 
}

.chart-container {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    height: 240px;
    padding-top: 20px;
    gap: 12px;
    border-bottom: 1px solid var(--border-color, #e5e7eb);
    padding-bottom: 0;
}

.chart-bar {
    flex: 1;
    background: linear-gradient(180deg, #2563eb 0%, rgba(37, 99, 235, 0.2) 100%);
    border-radius: 4px 4px 0 0;
    min-height: 4px;
    transition: height 0.5s cubic-bezier(0.4, 0, 0.2, 1), background 0.2s ease;
    position: relative;
    cursor: pointer;
}
.chart-bar:hover {
    background: linear-gradient(180deg, #1d4ed8 0%, rgba(37, 99, 235, 0.4) 100%);
}

/* ===============================================
   7. Quick Actions
   =============================================== */

.quick-actions-card { padding: 24px; }
.quick-actions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 16px;
}
.quick-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 20px;
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 6px;
    color: var(--text-secondary, #64748b);
    transition: border-color 0.2s ease, transform 0.2s ease;
    background: var(--bg-card, #ffffff);
    text-decoration: none;
}
.quick-action-btn:hover {
    border-color: #2563eb;
    color: #2563eb;
    transform: translateY(-2px);
}
.quick-action-btn span {
    font-size: 0.85rem;
    font-weight: 600;
}

/* ===============================================
   8. Notifications
   =============================================== */

.notification-list { 
    padding: 8px 0; 
}
.notification-item {
    display: flex;
    gap: 12px;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color-light, #f1f5f9);
    transition: background 0.2s ease;
}
.notification-item:last-child { border-bottom: none; }
.notification-item:hover {
    background: var(--bg-input, #f8fafc);
}
.notification__icon {
    width: 36px; 
    height: 36px; 
    border-radius: 6px;
    display: flex; 
    align-items: center; 
    justify-content: center;
    font-weight: 700; 
    flex-shrink: 0;
}
.notification__icon--success { background: rgba(16, 185, 129, 0.1); color: #10b981; }
.notification__icon--warning { background: rgba(245, 158, 11, 0.1); color: #f59e0b; }
.notification__icon--info { background: rgba(59, 130, 246, 0.1); color: #3b82f6; }
.notification__content p { 
    font-size: 0.85rem; 
    margin-bottom: 2px; 
    color: var(--text-primary, #111827);
    font-weight: 500;
}
.notification__time { 
    font-size: 0.75rem; 
    color: var(--text-muted, #64748b); 
}

/* ===============================================
   9. API Documentation
   =============================================== */

.api-doc-card { 
    margin-top: 24px; 
}
.api-doc-card h4 { 
    margin-top: 16px; 
    margin-bottom: 8px; 
    font-size: 1.1rem; 
    color: var(--text-primary, #111827); 
    font-weight: 600;
}
.api-doc-card .table { 
    margin-bottom: 16px; 
    font-size: 14px; 
    width: 100%;
    border-collapse: collapse;
}
.api-doc-card .table th, 
.api-doc-card .table td { 
    padding: 12px 16px; 
    border: 1px solid var(--border-color, #e5e7eb); 
    text-align: left;
}
.api-doc-card .table th {
    background-color: var(--bg-input, #f8fafc);
    color: var(--text-secondary, #64748b);
    font-weight: 600;
}
.api-doc-card .code-block,
.api-code-card .code-block {
    background: #1e1e2e; 
    color: #a6accd; 
    padding: 16px; 
    border-radius: 6px; 
    overflow-x: auto; 
    font-family: 'Courier New', Courier, monospace;
    font-size: 13px;
    line-height: 1.5;
    margin: 0;
}
.api-code-card .code-block code {
    background: transparent;
    padding: 0;
    color: inherit;
}

/* ===============================================
   10. Progress Bars
   =============================================== */

.progress-bar {
    width: 100%;
    height: 8px;
    background-color: var(--bg-input, #f1f5f9);
    border-radius: 4px;
    overflow: hidden;
    margin-top: 5px;
}
.progress-bar__fill {
    height: 100%;
    background-color: #2563eb; 
    border-radius: 4px;
    transition: width 0.3s ease;
}

/* ===============================================
   11. Service ID / Currency Utilities
   =============================================== */

.service-id-input {
    width: 65px;
    padding: 4px 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary, #111827);
    background: var(--bg-input, #f8fafc);
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 4px;
    text-align: center;
    cursor: default; 
    transition: border-color 0.2s ease;
}
.service-id-input:focus {
    outline: none;
    border-color: #2563eb;
}
.service-id-link {
    font-weight: 600;
    color: #2563eb;
    text-decoration: none;
    cursor: pointer;
    transition: opacity 0.2s ease;
}
.service-id-link:hover {
    opacity: 0.8;
    text-decoration: underline;
}
.charge-ugx,
.rate-value-ugx {
    display: block;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary, #64748b);
    margin-top: 2px;
    letter-spacing: 0.2px;
}
#charge-amount-ugx {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary, #64748b);
    margin-top: 4px;
    text-align: right;
}
.ugx-amount {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary, #64748b);
    margin-bottom: 8px; 
}

/* ===============================================
   12. Announcements
   =============================================== */

.announcements-scroller-card {
    margin-top: 24px;
    padding: 20px;
    background: var(--bg-card, #ffffff);
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 8px;
    animation: fadeInUp 0.5s ease-out;
}
.announcements-scroller-header {
    display: flex; 
    align-items: center; 
    gap: 10px; 
    margin-bottom: 15px;
}
.announcements-scroller-header h3 {
    margin: 0; 
    font-size: 16px; 
    font-weight: 700; 
    color: var(--text-primary, #111827);
}
.announcements-scroller-header span {
    font-size: 12px; 
    color: var(--text-muted, #64748b); 
}
.announcements-scroller-container {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    scroll-behavior: smooth;
    padding-bottom: 10px;
    scrollbar-width: thin;
    scrollbar-color: #2563eb transparent;
    -webkit-overflow-scrolling: touch; 
}
.announcements-scroller-container::-webkit-scrollbar {
    height: 6px;
}
.announcements-scroller-container::-webkit-scrollbar-track {
    background: transparent;
}
.announcements-scroller-container::-webkit-scrollbar-thumb {
    background-color: #2563eb;
    border-radius: 10px;
}
.announcement-pill {
    flex: 0 0 auto;
    background: var(--bg-input, #f8fafc);
    border: 1px solid var(--border-color, #e5e7eb);
    padding: 16px 20px;
    border-radius: 6px;
    min-width: 260px;
    max-width: 300px;
    transition: transform 0.2s ease, border-color 0.2s ease;
}
.announcement-pill:hover {
    transform: translateY(-2px);
    border-color: #2563eb;
}
.announcement-pill h4 { 
    margin: 0 0 8px 0; 
    font-size: 14px; 
    color: #2563eb; 
    display: flex; 
    align-items: center; 
    gap: 5px; 
    font-weight: 700;
}
.announcement-pill p { 
    margin: 0; 
    font-size: 13px; 
    color: var(--text-secondary, #64748b); 
    line-height: 1.5; 
}
@keyframes fadeInUp {
    from { 
        opacity: 0; 
        transform: translateY(20px); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0); 
    }
}

/* ===============================================
   13. Accessibility & Touch Behavior
   =============================================== */

.stat-card,
.service-card,
.quick-action-btn,
.announcement-pill {
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}
.btn:focus-visible,
.stat-card:focus-visible,
a:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

/* ===============================================
   14 & 15. Responsive Desktop/Tablet/Mobile
   =============================================== */

@media (max-width: 768px) {
    /* Base Card Polish */
    .card {
        border-radius: 8px;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
        padding: 16px;
    }

    /* Stats Grid: Stack naturally */
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 12px;
        margin-bottom: 16px;
    }

    .stat-card {
        padding: 16px;
        border-radius: 8px;
        transition: transform 0.15s ease, box-shadow 0.15s ease;
    }

    .stat-card:active,
    .service-card:active,
    .quick-action-btn:active,
    .btn:active {
        transform: scale(0.98);
    }

    @media (hover: hover) {
        .stat-card:hover,
        .service-card:hover,
        .quick-action-btn:hover {
            transform: translateY(-1px);
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
        }
    }

    .stat-card__top {
        margin-bottom: 8px;
    }

    .stat-card__label {
        font-size: 12px;
    }

    .stat-card__icon {
        width: 32px;
        height: 32px;
        font-size: 14px;
        border-radius: 6px;
    }

    .stat-card__value,
    .balance-card__amount {
        font-size: 1.5rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

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

    .balance-card__substats, 
    .status-grid {
        grid-template-columns: 1fr 1fr;
        gap: 16px;
    }

    .dashboard-row {
        grid-template-columns: 1fr;
        gap: 16px;
        margin-bottom: 16px;
    }

    .chart-card {
        padding: 16px;
    }
    .chart-placeholder, 
    #chart-revenue {
        height: 200px;
        min-height: 180px;
        margin-top: 12px;
    }

    .quick-actions-grid {
        gap: 12px;
    }
    .quick-action-btn {
        padding: 16px;
        border-radius: 6px;
    }

    .announcements-scroller-container {
        gap: 12px;
        padding: 4px 0 10px 0; 
    }
    .announcement-pill {
        min-width: 280px;
        max-width: 320px;
        padding: 12px 16px;
        border-radius: 6px;
    }
}

/* ===============================================
   16. Ultra-small screens
   =============================================== */

@media (max-width: 360px) {
    .stats-grid {
        gap: 10px;
    }
    .stat-card {
        padding: 12px;
    }
    .stat-card__label {
        font-size: 11px;
    }
    .stat-card__value,
    .balance-card__amount {
        font-size: 1.25rem;
    }
    .announcement-pill {
        min-width: 260px;
    }
}

/* Mobile Safe Area & Bottom Nav Spacing */
@media (max-width: 768px) {
    .main-wrapper {
        padding-bottom: calc(70px + env(safe-area-inset-bottom, 0px));
    }
}