/* ==================== CUSTOM PROPERTIES ==================== */
:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --accent: #06b6d4;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --surface: #ffffff;
    --surface-2: #f3f5f9;
    --text: #0f172a;
    --text-secondary: #64748b;
    --border: #b8c4d0;
    --shadow: rgba(0, 0, 0, 0.08);
}

.dark {
    --primary: #818cf8;
    --primary-dark: #6366f1;
    --primary-light: #a5b4fc;
    --accent: #22d3ee;
    --success: #34d399;
    --warning: #fbbf24;
    --danger: #f87171;
    --surface: #0f172a;
    --surface-2: #1e293b;
    --text: #f1f5f9;
    --text-secondary: #94a3b8;
    --border: #334155;
    --shadow: rgba(0, 0, 0, 0.3);
}

/* ==================== BASE STYLES ==================== */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: var(--surface-2);
    color: var(--text);
    transition: background-color 0.3s, color 0.3s;
}

/* Ensure all text inherits color properly without breaking Tailwind dark: utilities */
body,
.card,
.sidebar,
.table-container,
.stat-card {
    color: var(--text);
}

select,
option,
textarea,
input {
    color: var(--text);
}

::placeholder {
    color: var(--text-secondary);
    opacity: 0.6;
}

.dark select option {
    background: var(--surface);
    color: var(--text);
}

.dark ::placeholder {
    opacity: 0.5;
}

/* ==================== ANIMATIONS ==================== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse-glow {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.4);
    }

    50% {
        box-shadow: 0 0 0 10px rgba(99, 102, 241, 0);
    }
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }

    100% {
        background-position: 200% 0;
    }
}

.animate-fade-in {
    animation: fadeIn 0.5s ease-out forwards;
}

.animate-slide-up {
    animation: slideUp 0.6s ease-out forwards;
}

.stagger-1 {
    animation-delay: 0.1s;
}

.stagger-2 {
    animation-delay: 0.2s;
}

.stagger-3 {
    animation-delay: 0.3s;
}

.stagger-4 {
    animation-delay: 0.4s;
}

/* ==================== GLASSMORPHISM ==================== */
.glass {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.18);
}

.dark .glass {
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

/* ==================== CARD STYLES ==================== */
.card {
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: 1rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 40px var(--shadow);
}

.card-product {
    position: relative;
    overflow: hidden;
}

.card-product .card-image {
    height: 200px;
    object-fit: cover;
    transition: transform 0.5s;
}

.card-product:hover .card-image {
    transform: scale(1.05);
}

/* ==================== BUTTONS ==================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border-radius: 0.75rem;
    font-weight: 600;
    font-size: 0.875rem;
    transition: all 0.2s;
    cursor: pointer;
    border: none;
    text-decoration: none;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
}

.btn-primary:hover {
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--border);
}

.btn-success {
    background: linear-gradient(135deg, var(--success), #059669);
    color: white;
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger), #dc2626);
    color: white;
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
}

.btn-outline:hover {
    background: var(--primary);
    color: white;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
}

.btn-lg {
    padding: 0.875rem 1.75rem;
    font-size: 1rem;
}

/* ==================== BADGE ==================== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success {
    background: rgba(16, 185, 129, 0.12);
    color: var(--success);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.12);
    color: var(--warning);
}

.badge-danger {
    background: rgba(239, 68, 68, 0.12);
    color: var(--danger);
}

.badge-info {
    background: rgba(6, 182, 212, 0.12);
    color: var(--accent);
}

.badge-secondary {
    background: rgba(100, 116, 139, 0.12);
    color: var(--text-secondary);
}

/* ==================== FORM STYLES ==================== */
.form-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1.5px solid var(--border);
    border-radius: 0.75rem;
    background: var(--surface);
    color: var(--text);
    font-size: 0.875rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

/* Search bar */
.search-bar {
    width: 100%;
    padding: 0.625rem 1rem 0.625rem 2.5rem;
    border: 1.5px solid var(--border);
    border-radius: 9999px;
    background: var(--surface);
    color: var(--text);
    font-size: 0.875rem;
    transition: border-color 0.2s, box-shadow 0.2s, width 0.3s;
}

.search-bar:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* Currency switcher */
.currency-select {
    padding: 0.375rem 0.5rem;
    border: 1.5px solid var(--border);
    border-radius: 0.5rem;
    background: var(--surface);
    color: var(--text);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.2s;
}

.currency-select:focus {
    outline: none;
    border-color: var(--primary);
}

.form-label {
    display: block;
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--text);
    margin-bottom: 0.375rem;
}

/* ==================== SIDEBAR ==================== */
.sidebar {
    background: var(--surface);
    border-right: 2px solid var(--border);
    transition: all 0.3s;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.04);
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.875rem;
    transition: all 0.2s;
    text-decoration: none;
}

.sidebar-link:hover {
    background: rgba(99, 102, 241, 0.08);
    color: var(--primary);
}

.sidebar-link.active {
    background: rgba(99, 102, 241, 0.12);
    color: var(--primary);
    font-weight: 600;
}

/* ==================== TABLE ==================== */
.table-container {
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: 1rem;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}

.table-container table {
    width: 100%;
    border-collapse: collapse;
}

.table-container th {
    padding: 0.875rem 1rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
}

.table-container td {
    padding: 0.875rem 1rem;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--border);
}

.table-container tr:last-child td {
    border-bottom: none;
}

.table-container tr:hover td {
    background: rgba(99, 102, 241, 0.03);
}

/* ==================== STATS CARD ==================== */
.stat-card {
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: 1rem;
    padding: 1.5rem;
    position: relative;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    opacity: 0.08;
}

.stat-card-primary::before {
    background: var(--primary);
}

.stat-card-success::before {
    background: var(--success);
}

.stat-card-warning::before {
    background: var(--warning);
}

.stat-card-accent::before {
    background: var(--accent);
}

/* ==================== RATING STARS ==================== */
.stars {
    display: flex;
    gap: 2px;
}

.star {
    width: 16px;
    height: 16px;
}

.star-filled {
    color: #f59e0b;
}

.star-empty {
    color: var(--border);
}

/* ==================== SCROLLBAR ==================== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 768px) {
    .sidebar {
        display: none;
    }

    .sidebar.open {
        display: block;
        position: fixed;
        z-index: 50;
        top: 0;
        left: 0;
        height: 100vh;
        width: 260px;
    }
}

/* ==================== LOADING SKELETON ==================== */
.skeleton {
    background: linear-gradient(90deg, var(--border) 25%, transparent 50%, var(--border) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 0.5rem;
}

/* ==================== NOTIFICATION TOAST ==================== */
.toast {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    padding: 1rem 1.5rem;
    border-radius: 0.75rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    animation: slideUp 0.4s ease-out;
    max-width: 400px;
}

/* ==================== NOTIFICATION DROPDOWN ==================== */
.notif-dropdown {
    border-radius: 1rem !important;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15), 0 0 0 1px var(--border) !important;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.dark .notif-dropdown {
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4), 0 0 0 1px var(--border) !important;
}

.notif-dropdown .notif-item {
    position: relative;
}

.notif-dropdown .notif-item::after {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 0;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    opacity: 0;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.notif-dropdown .notif-item:hover::after {
    width: 3px;
    opacity: 1;
}

@keyframes notifSlideIn {
    from {
        opacity: 0;
        transform: translateX(8px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.notif-dropdown .notif-item:nth-child(1) { animation: notifSlideIn 0.3s ease-out 0.05s both; }
.notif-dropdown .notif-item:nth-child(2) { animation: notifSlideIn 0.3s ease-out 0.1s both; }
.notif-dropdown .notif-item:nth-child(3) { animation: notifSlideIn 0.3s ease-out 0.15s both; }

@media (max-width: 640px) {
    .notif-dropdown {
        position: fixed !important;
        left: 0.75rem !important;
        right: 0.75rem !important;
        width: auto !important;
        top: 4rem !important;
    }
}

/* ==================== MOBILE & TABLET PREMIUM REDESIGN ==================== */

/* Sticky Bottom Navigation for Mobile */
.mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 50;
    box-shadow: 0 -4px 16px var(--shadow);
    padding-bottom: env(safe-area-inset-bottom);
}

.dark .mobile-bottom-nav {
    background: rgba(15, 23, 42, 0.85);
    border-top: 1px solid var(--border);
}

.mobile-bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 0.65rem;
    font-weight: 500;
    text-decoration: none;
    flex: 1;
    height: 100%;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    gap: 3px;
    padding-top: 4px;
}

.mobile-bottom-nav-item i {
    width: 20px;
    height: 20px;
    stroke-width: 2px;
    transition: transform 0.2s ease, color 0.2s;
}

.mobile-bottom-nav-item.active {
    color: var(--primary);
    font-weight: 600;
}

.mobile-bottom-nav-item.active i {
    transform: translateY(-2px) scale(1.1);
    color: var(--primary);
}

/* Swipe Tabs for Mobile/Tablet Dashboard Sidebar Replacement */
.swipe-tabs {
    display: flex;
    overflow-x: auto;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Firefox */
    gap: 0.5rem;
    padding: 0.5rem 0.25rem;
    width: 100%;
}

.swipe-tabs::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}

.swipe-tab-item {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 9999px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.swipe-tab-item i {
    width: 16px;
    height: 16px;
}

.swipe-tab-item.active {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white !important;
    border-color: transparent;
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
    font-weight: 600;
}

/* Sticky Purchase Bar for Mobile Product Details Page */
.sticky-buy-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border);
    padding: 0.75rem 1rem;
    z-index: 45; /* Below bottom-nav (50) but above content */
    box-shadow: 0 -6px 20px var(--shadow);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    transform: translateY(105%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    padding-bottom: calc(0.75rem + env(safe-area-inset-bottom));
}

.dark .sticky-buy-bar {
    background: rgba(15, 23, 42, 0.9);
}

.sticky-buy-bar.show {
    transform: translateY(0);
}

/* Page padding adjustments when sticky bars are visible */
@media (max-width: 768px) {
    body {
        padding-bottom: 64px; /* Space for bottom nav bar */
    }
    .has-sticky-buy {
        padding-bottom: 128px; /* Space for bottom nav AND buy bar */
    }
    
    /* Product card structural scale-down for 2-column mobile view */
    .card-product .card-image {
        height: 130px !important;
    }
    .card-product .p-4 {
        padding: 0.75rem !important;
    }
    .card-product h3 {
        font-size: 0.75rem !important;
        line-height: 1.25 !important;
        margin-bottom: 0.25rem !important;
        height: 2.5rem; /* fixed height for alignment */
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
    .card-product .text-xs {
        font-size: 0.65rem !important;
    }
    .card-product .text-lg {
        font-size: 0.9rem !important;
    }
    .card-product .text-sm {
        font-size: 0.7rem !important;
    }
    .card-product .btn-sm {
        padding: 0.35rem 0.5rem !important;
        font-size: 0.7rem !important;
        border-radius: 0.5rem !important;
        gap: 0.25rem !important;
    }
    .card-product .px-4.pb-4 {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
        padding-bottom: 0.75rem !important;
    }
}
