/* ===========================================
   Costco Gold Inventory - MDB Custom Styles
   =========================================== */

/* CSS Variables for theming */
:root {
    --cgi-primary: #1266f1;
    --cgi-success: #00b74a;
    --cgi-warning: #ffa900;
    --cgi-danger: #f93154;
    --cgi-gold: #d4af37;
    --cgi-silver: #c0c0c0;
    --cgi-sidebar-width: 280px;
}

/* ===========================================
   Sidenav Customization
   =========================================== */
.sidenav {
    width: var(--cgi-sidebar-width);
    z-index: 1050;
    height: 100vh;
    overflow-y: auto;
    /* Disable MDB sidenav transition to prevent flex on page load */
    transition: none !important;
    transform: translateX(0) !important;
}

/* User profile box in sidenav - dark mode fix */
[data-mdb-theme="dark"] .sidenav .bg-light {
    background-color: #2d2d2d !important;
}

.sidenav-link.active {
    background-color: rgba(18, 102, 241, 0.1);
    color: var(--cgi-primary);
    font-weight: 500;
}

.sidenav-link:hover:not(.active) {
    background-color: rgba(0, 0, 0, 0.05);
}

[data-mdb-theme="dark"] .sidenav-link:hover:not(.active) {
    background-color: rgba(255, 255, 255, 0.05);
}

/* Main content with sidenav */
.main-content {
    padding-left: var(--cgi-sidebar-width);
    min-height: 100vh;
}

@media (max-width: 991.98px) {
    .main-content {
        padding-left: 0 !important;
        padding-top: 60px !important; /* Mobile navbar height */
    }
}

/* ===========================================
   Mobile Navigation Dropdown
   =========================================== */
.mobile-nav-dropdown {
    background-color: var(--mdb-body-bg, #fff);
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.mobile-nav-dropdown .nav-link {
    padding: 0.75rem 1rem;
    color: var(--mdb-body-color, #212529);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.mobile-nav-dropdown .nav-link:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.mobile-nav-dropdown .nav-link.active {
    color: var(--cgi-primary);
    font-weight: 500;
}

.mobile-nav-dropdown .nav-section-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #6c757d;
    padding: 0.5rem 1rem;
    margin-top: 0.5rem;
}

[data-mdb-theme="dark"] .mobile-nav-dropdown {
    background-color: var(--mdb-body-bg, #1a1a1a);
    border-top-color: rgba(255, 255, 255, 0.1);
}

[data-mdb-theme="dark"] .mobile-nav-dropdown .nav-link:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

/* Make mobile menu scrollable when it exceeds viewport */
.mobile-nav-dropdown > nav {
    max-height: calc(100vh - 56px);
    overflow-y: auto;
}

/* Mobile navbar spacing adjustments */
nav.navbar.fixed-top.d-lg-none .container-fluid {
    padding-left: 24px;
}

nav.navbar.fixed-top.d-lg-none .container-fluid > a > img {
    margin-right: 12px !important;
}

/* ===========================================
   Premium Badge Styling
   =========================================== */
.badge-premium {
    background: linear-gradient(135deg, var(--cgi-gold), #b8960c);
    color: #1a1a1a;
    font-weight: 600;
    font-size: 0.65rem;
    padding: 0.25em 0.6em;
    text-transform: none;
}

.badge-premium i {
    color: #ffffff;
}

.badge-freemium {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: #fff;
    font-weight: 600;
    font-size: 0.65rem;
    padding: 0.25em 0.6em;
}

.badge-premium-preview {
    background: linear-gradient(135deg, #6c757d, #495057);
    color: #fff;
    font-weight: 500;
    font-size: 0.6rem;
    padding: 0.2em 0.5em;
    border-radius: 4px;
}

/* Stacked sidenav link for premium badge underneath label */
.sidenav-link-content {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    flex-grow: 1;
}

.sidenav-link-content .badge {
    margin-top: 2px;
    font-size: 0.55rem;
}

/* ===========================================
   Status Indicator Dots
   =========================================== */
.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.status-dot.gold {
    background: #ffd700;
    box-shadow: 0 0 4px rgba(255, 215, 0, 0.5);
}

.status-dot.silver {
    background: var(--cgi-silver);
    box-shadow: 0 0 4px rgba(192, 192, 192, 0.5);
}

.status-dot.both {
    background: linear-gradient(135deg, #ffd700 50%, var(--cgi-silver) 50%);
    box-shadow: 0 0 4px rgba(255, 215, 0, 0.3);
}

.status-dot.none {
    background: #6c757d;
}

/* ===========================================
   Card Enhancements
   =========================================== */
.card {
    border: none;
    box-shadow: 0 2px 15px -3px rgba(0, 0, 0, 0.07), 0 10px 20px -2px rgba(0, 0, 0, 0.04);
}

.card-header {
    background-color: transparent;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    font-weight: 600;
}

[data-mdb-theme="dark"] .card-header {
    border-bottom-color: rgba(255, 255, 255, 0.08);
}

/* ===========================================
   Stat Cards
   =========================================== */
.stat-card {
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    border-radius: 0.5rem;
    padding: 1.25rem;
    text-align: center;
}

[data-mdb-theme="dark"] .stat-card {
    background: linear-gradient(135deg, #2d2d2d 0%, #1a1a1a 100%);
}

.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--cgi-primary);
}

.stat-card .stat-label {
    font-size: 0.8rem;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ===========================================
   Stats Cards (Metal/Spot Price)
   =========================================== */
.stats-card {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 12px 16px;
}

.metal-card {
    border-left: 3px solid transparent;
}

.gold-card {
    border-left-color: #d4af37;
}

.silver-card {
    border-left-color: #c0c0c0;
}

.spot-price-gold {
    color: #d4af37;
}

.spot-price-silver {
    color: #a8a8a8;
}

[data-mdb-theme="light"] .stats-card {
    background: rgba(0, 0, 0, 0.03);
}

[data-mdb-theme="light"] .spot-price-gold {
    color: #b8960c;
}

[data-mdb-theme="light"] .spot-price-silver {
    color: #708090;
}

.spot-time {
    font-weight: 400;
    opacity: 0.7;
    font-size: 0.85em;
}

.icon-sm { width: 24px; height: 24px; }
.icon-md { width: 40px; height: 40px; }
.icon-lg { width: 48px; height: 48px; }

/* ===========================================
   Search & Form Enhancements
   =========================================== */
.search-hero {
    background: linear-gradient(135deg, var(--cgi-primary) 0%, #0d5bdd 100%);
    color: white;
    padding: 2rem;
    border-radius: 0.75rem;
    margin-bottom: 1.5rem;
}

.search-hero .form-control {
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    font-size: 1.1rem;
}

/* ===========================================
   Store/Warehouse List Items
   =========================================== */
.store-item {
    padding: 1rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.store-item:hover {
    background-color: rgba(18, 102, 241, 0.05);
}

.store-item:last-child {
    border-bottom: none;
}

.store-item.selected {
    background-color: rgba(18, 102, 241, 0.1);
    border-left: 3px solid var(--cgi-primary);
}

[data-mdb-theme="dark"] .store-item {
    border-bottom-color: rgba(255, 255, 255, 0.08);
}

/* ===========================================
   Map Container
   =========================================== */
.map-container {
    border-radius: 0.5rem;
    overflow: hidden;
    box-shadow: 0 2px 15px -3px rgba(0, 0, 0, 0.07);
}

/* ===========================================
   Premium Overlay
   =========================================== */
.premium-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1040;
}

[data-mdb-theme="dark"] .premium-overlay {
    background: rgba(0, 0, 0, 0.8);
}

.premium-overlay .upgrade-card {
    max-width: 400px;
    text-align: center;
}

/* ===========================================
   Loading States
   =========================================== */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
}

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

[data-mdb-theme="dark"] .skeleton {
    background: linear-gradient(90deg, #2d2d2d 25%, #3d3d3d 50%, #2d2d2d 75%);
    background-size: 200% 100%;
}

/* ===========================================
   Responsive Adjustments
   =========================================== */
@media (max-width: 767.98px) {
    .search-hero {
        padding: 1.25rem;
    }

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

/* ===========================================
   Utility Classes
   =========================================== */
.text-gold {
    color: var(--cgi-gold) !important;
}

.text-silver {
    color: var(--cgi-silver) !important;
}

.bg-gold {
    background-color: var(--cgi-gold) !important;
}

.bg-gold-subtle {
    background-color: rgba(212, 175, 55, 0.15) !important;
}

.border-gold {
    border-color: var(--cgi-gold) !important;
}

/* ===========================================
   Fix for Leaflet in MDB
   =========================================== */
.leaflet-container {
    font-family: inherit;
}

.leaflet-popup-content-wrapper {
    border-radius: 0.5rem;
}

/* ===========================================
   Product Image Grid
   =========================================== */
.product-image {
    width: 100%;
    height: 180px;
    object-fit: contain;
    background: var(--mdb-body-bg-alt, #f8f9fa);
    border-radius: 0.25rem;
}

[data-mdb-theme="dark"] .product-image {
    background: #2d2d2d;
}

/* ===========================================
   Text Line Clamping Utilities
   =========================================== */
.text-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
}

/* ===========================================
   Availability Headers (Buy to Flip)
   =========================================== */
.availability-header {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    padding: 0.5rem 1rem;
    text-transform: uppercase;
    background-color: var(--mdb-primary);
    color: #fff;
}

/* ===========================================
   Broker/Profit Tables
   =========================================== */
.broker-table {
    font-size: 0.95rem;
    margin-bottom: 0;
}

.broker-table th {
    font-weight: 500;
    background-color: var(--mdb-body-bg-alt, #f8f9fa);
    white-space: nowrap;
}

[data-mdb-theme="dark"] .broker-table th {
    background-color: #2d2d2d;
}

.broker-table td {
    vertical-align: middle;
}

.broker-header-cell {
    min-width: 100px;
    text-align: center;
}

.broker-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.broker-price {
    font-size: 0.85rem;
    color: #6c757d;
}

.profile-cell {
    font-weight: 500;
    font-size: 0.9rem;
    white-space: nowrap;
}

.profit-cell {
    min-width: 80px;
    text-align: center;
    font-size: 0.95rem;
}

/* ===========================================
   Profile Card Stats
   =========================================== */
.profile-stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem 0;
    font-size: 0.875rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.profile-stat:last-of-type {
    border-bottom: none;
}

.profile-stat-label {
    color: #6c757d;
}

.profile-stat-value {
    font-weight: 600;
}

.profile-stat-value.positive {
    color: #198754;
}

.profile-stat-value.negative {
    color: #dc3545;
}

/* Profile Total Summary */
.profile-total {
    border-top: 2px solid rgba(0, 0, 0, 0.1);
    padding-top: 0.75rem;
    margin-top: 0.5rem;
}

.profile-total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.875rem;
}

.profile-total-label {
    font-weight: 600;
}

.profile-total-value {
    font-weight: 700;
}

/* Dark mode */
[data-mdb-theme="dark"] .profile-stat {
    border-bottom-color: rgba(255, 255, 255, 0.05);
}

[data-mdb-theme="dark"] .profile-stat-label {
    color: #adb5bd;
}

[data-mdb-theme="dark"] .profile-total {
    border-top-color: rgba(255, 255, 255, 0.1);
}

/* ===========================================
   Modal Dark Mode Fixes
   =========================================== */
[data-mdb-theme="dark"] .modal-content {
    background-color: #1a1a1a;
    color: #e0e0e0;
}

[data-mdb-theme="dark"] .modal-header {
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

[data-mdb-theme="dark"] .modal-footer {
    border-top-color: rgba(255, 255, 255, 0.1);
}

[data-mdb-theme="dark"] .modal .bg-light {
    background-color: #2d2d2d !important;
}

[data-mdb-theme="dark"] .modal .card {
    background-color: #2d2d2d;
}

[data-mdb-theme="dark"] .modal .card-header.bg-light {
    background-color: #3d3d3d !important;
}

[data-mdb-theme="dark"] .modal .table {
    color: #e0e0e0;
}

[data-mdb-theme="dark"] .modal .table thead th {
    background-color: #2d2d2d;
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

[data-mdb-theme="dark"] .modal .table td {
    border-bottom-color: rgba(255, 255, 255, 0.05);
}

[data-mdb-theme="dark"] .modal .stat-card {
    background: linear-gradient(135deg, #2d2d2d 0%, #1a1a1a 100%);
}

/* ===========================================
   System Status Indicator
   =========================================== */
.system-status {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.system-status-dot {
    width: 10px;
    height: 10px;
    background: #22c55e;
    border-radius: 50%;
    animation: system-pulse 2s infinite;
    flex-shrink: 0;
    margin-top: 3px;
}

@keyframes system-pulse {
    0%, 100% {
        opacity: 1;
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.4);
    }
    50% {
        opacity: 0.7;
        box-shadow: 0 0 0 4px rgba(34, 197, 94, 0);
    }
}

.system-status-content {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.system-status-text {
    font-size: 0.75rem;
    font-weight: 600;
    color: rgb(25, 48, 61);
}

.system-status-version {
    font-size: 0.65rem;
    color: #6c757d;
}

/* Warning state - scanner hasn't updated in over an hour */
.system-status.warning .system-status-dot {
    background: #f59e0b;
    animation: system-pulse-warning 2s infinite;
}

.system-status.warning .system-status-text {
    color: #f59e0b;
}

@keyframes system-pulse-warning {
    0%, 100% {
        opacity: 1;
        box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.4);
    }
    50% {
        opacity: 0.7;
        box-shadow: 0 0 0 4px rgba(245, 158, 11, 0);
    }
}

/* Dark mode */
[data-mdb-theme="dark"] .system-status {
    border-bottom-color: rgba(255, 255, 255, 0.08);
}

[data-mdb-theme="dark"] .system-status-dot {
    background: #22c55e;
}

[data-mdb-theme="dark"] .system-status-text {
    color: #22c55e;
}

[data-mdb-theme="dark"] .system-status-version {
    color: #adb5bd;
}

/* Dark mode warning state */
[data-mdb-theme="dark"] .system-status.warning .system-status-dot {
    background: #f59e0b;
}

[data-mdb-theme="dark"] .system-status.warning .system-status-text {
    color: #f59e0b;
}

/* Mobile status - more compact */
.mobile-system-status {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0.5rem 1rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    font-size: 0.7rem;
}

.mobile-system-status .system-status-dot {
    width: 8px;
    height: 8px;
}

.mobile-system-status .system-status-text {
    font-size: 0.7rem;
}

.mobile-system-status .system-status-version {
    font-size: 0.6rem;
    margin-left: auto;
}

/* Mobile warning state */
.mobile-system-status.warning .system-status-dot {
    background: #f59e0b;
    animation: system-pulse-warning 2s infinite;
}

.mobile-system-status.warning .system-status-text {
    color: #f59e0b;
}

[data-mdb-theme="dark"] .mobile-system-status {
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

/* ===========================================
   Collapse Toggle Arrow Rotation
   =========================================== */
[data-mdb-collapse-init] i {
    transition: transform 0.3s ease;
}

[data-mdb-collapse-init][aria-expanded="true"] i {
    transform: rotate(180deg);
}

/* ===========================================
   Product Filter List (Dark Mode Fix)
   =========================================== */
.product-filter-list label {
    color: var(--mdb-body-color);
}

[data-mdb-theme="dark"] .product-filter-list label {
    color: #e0e0e0;
}

[data-mdb-theme="dark"] #productFilterBody .text-muted {
    color: #adb5bd !important;
}

/* ===========================================
   Collapse Animation Fix
   =========================================== */
.collapsing {
    height: 0;
    overflow: hidden;
    transition: height 0.35s ease;
}

.collapsing.collapse-horizontal {
    width: 0;
    height: auto;
    transition: width 0.35s ease;
}

/* ===========================================
   Glowing Subscription Button
   =========================================== */
.glow-button {
    --glow-red: #FF6565;
    --glow-pink: #FF64F9;
    --glow-purple: #6B5FFF;
    --glow-blue: #4D8AFF;
    --glow-green: #5BFF89;
    --glow-yellow: #FFEE55;
    --glow-orange: #FF6D1B;

    position: relative;
    border: 3px solid transparent !important;
    border-radius: 8px;
    background:
        linear-gradient(#1a1a2e, #1a1a2e),
        linear-gradient(#1a1a2e 50%, rgba(26, 26, 46, 0.6) 80%, rgba(26, 26, 46, 0)),
        linear-gradient(90deg, var(--glow-orange), var(--glow-yellow), var(--glow-green), var(--glow-blue), var(--glow-purple), var(--glow-pink), var(--glow-red)) !important;
    background-origin: border-box;
    background-clip: padding-box, border-box, border-box;
    background-size: 200%;
    animation: glow-animate 2s infinite linear, glow-shadow 2s infinite linear;
    color: #f3f3f3 !important;
}


@keyframes glow-animate {
    0% { background-position: 0 }
    100% { background-position: 200% }
}

/* Box-shadow glow that works on mobile (not clipped by overflow) */
@keyframes glow-shadow {
    0%, 100% { box-shadow: 0 4px 20px rgba(255, 109, 27, 0.6), 0 0 40px rgba(255, 109, 27, 0.3); }
    14% { box-shadow: 0 4px 20px rgba(255, 238, 85, 0.6), 0 0 40px rgba(255, 238, 85, 0.3); }
    28% { box-shadow: 0 4px 20px rgba(91, 255, 137, 0.6), 0 0 40px rgba(91, 255, 137, 0.3); }
    42% { box-shadow: 0 4px 20px rgba(77, 138, 255, 0.6), 0 0 40px rgba(77, 138, 255, 0.3); }
    57% { box-shadow: 0 4px 20px rgba(107, 95, 255, 0.6), 0 0 40px rgba(107, 95, 255, 0.3); }
    71% { box-shadow: 0 4px 20px rgba(255, 100, 249, 0.6), 0 0 40px rgba(255, 100, 249, 0.3); }
    85% { box-shadow: 0 4px 20px rgba(255, 101, 101, 0.6), 0 0 40px rgba(255, 101, 101, 0.3); }
}
