/* =====================================================
   Product Hub - Main Stylesheet
   Modern dark theme with glassmorphism and gradients
   ===================================================== */

:root {
    /* Brand Colors */
    --primary: #6366f1;
    --primary-hover: #818cf8;
    --primary-glow: rgba(99, 102, 241, 0.25);

    /* Accent */
    --accent-teal: #2dd4bf;
    --accent-rose: #f43f5e;
    --accent-amber: #f59e0b;
    --accent-emerald: #10b981;

    /* Surfaces */
    --surface-0: #0a0a0f;
    --surface-1: #111118;
    --surface-2: #1a1a24;
    --surface-3: #232330;
    --surface-4: #2d2d3d;

    /* Text */
    --text-primary: #f0f0f5;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;

    /* Borders */
    --border-color: rgba(255, 255, 255, 0.06);
    --border-hover: rgba(255, 255, 255, 0.12);

    /* Sidebar */
    --sidebar-width: 260px;
    --sidebar-collapsed: 0px;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 250ms ease;
    --transition-slow: 350ms ease;

    /* Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 20px;
}

/* ─── Reset & Base ───────────────────────────────── */
*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--surface-0);
    color: var(--text-primary);
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: var(--primary-hover);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--primary);
}

/* ─── App Layout ─────────────────────────────────── */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

.app-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left var(--transition-base);
}

.app-content {
    flex: 1;
    padding: 24px 32px;
}

/* ─── Sidebar ────────────────────────────────────── */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--surface-1);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 1040;
    transition: transform var(--transition-base);
}

.sidebar-header {
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--text-primary);
}

.brand-icon {
    font-size: 24px;
    background: linear-gradient(135deg, var(--primary), var(--accent-teal));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.brand-text {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.sidebar-close {
    color: var(--text-secondary);
    font-size: 20px;
}

/* Sidebar Navigation */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px 0;
}

.nav-section {
    padding: 0 12px;
    margin-bottom: 8px;
}

.nav-section-title {
    display: block;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    padding: 12px 12px 6px;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 450;
    transition: all var(--transition-fast);
    margin-bottom: 2px;
}

.sidebar-nav .nav-link i {
    font-size: 18px;
    width: 20px;
    text-align: center;
}

.sidebar-nav .nav-link:hover {
    color: var(--text-primary);
    background: var(--surface-3);
}

.sidebar-nav .nav-link.active {
    color: #fff;
    background: linear-gradient(135deg, var(--primary), rgba(99, 102, 241, 0.7));
    box-shadow: 0 4px 12px var(--primary-glow);
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar-sm {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--accent-teal));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    flex-shrink: 0;
}

.user-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

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

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

/* Sidebar Overlay (mobile) */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1039;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-base);
}

.sidebar-overlay.show {
    opacity: 1;
    visibility: visible;
}

/* ─── Topbar ─────────────────────────────────────── */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    height: 64px;
    background: var(--surface-1);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 1020;
    backdrop-filter: blur(12px);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topbar-title {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.3px;
}

.topbar-toggle {
    color: var(--text-secondary);
    font-size: 24px;
    padding: 0;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* User dropdown */
.user-dropdown {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
    text-decoration: none;
    padding: 6px 12px;
    border-radius: var(--radius-md);
    transition: background var(--transition-fast);
}

.user-dropdown:hover {
    background: var(--surface-3);
    color: var(--text-primary);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--accent-teal));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    color: #fff;
}

/* ─── Auth Pages ─────────────────────────────────── */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-0);
}

.auth-container {
    display: flex;
    width: 100%;
    max-width: 1000px;
    min-height: 600px;
    border-radius: var(--radius-xl);
    overflow: hidden;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    margin: 20px;
}

.auth-card {
    flex: 1;
    padding: 48px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    background: var(--surface-1);
}

.auth-header {
    text-align: center;
    margin-bottom: 32px;
}

.auth-logo {
    font-size: 48px;
    background: linear-gradient(135deg, var(--primary), var(--accent-teal));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 16px;
}

.auth-header h1 {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
    margin-bottom: 8px;
}

.auth-form .form-control {
    background: var(--surface-2);
    border-color: var(--border-color);
    color: var(--text-primary);
    border-radius: var(--radius-md);
    height: 56px;
}

.auth-form .form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
    background: var(--surface-3);
}

.auth-form .form-floating label {
    color: var(--text-muted);
}

.auth-footer {
    text-align: center;
    margin-top: 24px;
}

.auth-footer a {
    font-weight: 600;
}

/* Auth Decoration Panel */
.auth-decoration {
    width: 420px;
    background: linear-gradient(135deg, var(--primary), #4338ca, #1e1b4b);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px;
    position: relative;
    overflow: hidden;
}

.auth-decoration::before {
    content: '';
    position: absolute;
    width: 300px;
    height: 300px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    top: -80px;
    right: -80px;
}

.auth-decoration::after {
    content: '';
    position: absolute;
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.03);
    bottom: -60px;
    left: -60px;
}

.decoration-content {
    position: relative;
    z-index: 1;
}

.decoration-content h2 {
    font-size: 28px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 16px;
}

.decoration-content p {
    color: rgba(255, 255, 255, 0.7);
    font-size: 15px;
    line-height: 1.6;
    margin-bottom: 32px;
}

.decoration-features {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.decoration-features .feature {
    display: flex;
    align-items: center;
    gap: 10px;
    color: rgba(255, 255, 255, 0.85);
    font-size: 14px;
    font-weight: 500;
}

.decoration-features .feature i {
    color: var(--accent-teal);
}

/* ─── Cards & Stat Cards ─────────────────────────── */
.stat-card {
    background: var(--surface-2);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
}

.stat-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
}

.stat-card.primary::before {
    background: linear-gradient(90deg, var(--primary), var(--accent-teal));
}

.stat-card.success::before {
    background: linear-gradient(90deg, var(--accent-emerald), var(--accent-teal));
}

.stat-card.warning::before {
    background: linear-gradient(90deg, var(--accent-amber), #ef4444);
}

.stat-card.info::before {
    background: linear-gradient(90deg, var(--accent-teal), var(--primary));
}

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    margin-bottom: 16px;
}

.stat-card.primary .stat-icon {
    background: var(--primary-glow);
    color: var(--primary-hover);
}

.stat-card.success .stat-icon {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-emerald);
}

.stat-card.warning .stat-icon {
    background: rgba(245, 158, 11, 0.15);
    color: var(--accent-amber);
}

.stat-card.info .stat-icon {
    background: rgba(45, 212, 191, 0.15);
    color: var(--accent-teal);
}

.stat-card .stat-value {
    font-size: 32px;
    font-weight: 700;
    letter-spacing: -0.5px;
    line-height: 1;
    margin-bottom: 4px;
}

.stat-card .stat-label {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
}

/* ─── Content Card ───────────────────────────────── */
.content-card {
    background: var(--surface-2);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.content-card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.content-card-header h5 {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}

.content-card-body {
    padding: 24px;
}

/* ─── Buttons ────────────────────────────────────── */
.btn-primary {
    background: linear-gradient(135deg, var(--primary), #4f46e5);
    border: none;
    font-weight: 600;
    border-radius: var(--radius-md);
    padding: 10px 20px;
    transition: all var(--transition-fast);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-hover), #6366f1);
    box-shadow: 0 4px 16px var(--primary-glow);
    transform: translateY(-1px);
}

.btn-outline-primary {
    border-color: var(--primary);
    color: var(--primary-hover);
    border-radius: var(--radius-md);
    font-weight: 500;
}

.btn-outline-primary:hover {
    background: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 4px 16px var(--primary-glow);
}

.btn-glass {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    border-radius: var(--radius-md);
    backdrop-filter: blur(8px);
    transition: all var(--transition-fast);
}

.btn-glass:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--border-hover);
    color: var(--text-primary);
}

/* ─── Tables ─────────────────────────────────────── */
.table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--text-primary);
}

.table thead th {
    background: var(--surface-3);
    border-bottom-color: var(--border-color);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    padding: 12px 16px;
    white-space: nowrap;
}

.table tbody td {
    padding: 14px 16px;
    border-bottom-color: var(--border-color);
    font-size: 14px;
    vertical-align: middle;
}

.table tbody tr:hover {
    background: var(--surface-3);
}

/* DataTables override */
.dataTables_wrapper .dataTables_filter input {
    background: var(--surface-2) !important;
    border: 1px solid var(--border-color) !important;
    color: var(--text-primary) !important;
    border-radius: var(--radius-md) !important;
    padding: 6px 12px !important;
}

.dataTables_wrapper .dataTables_length select {
    background: var(--surface-2) !important;
    border: 1px solid var(--border-color) !important;
    color: var(--text-primary) !important;
    border-radius: var(--radius-sm) !important;
}

.dataTables_info,
.dataTables_length label,
.dataTables_filter label {
    color: var(--text-muted) !important;
    font-size: 13px !important;
}

.page-item .page-link {
    background: var(--surface-2);
    border-color: var(--border-color);
    color: var(--text-secondary);
}

.page-item.active .page-link {
    background: var(--primary);
    border-color: var(--primary);
}

/* ─── Status Badges ──────────────────────────────── */
.badge-status {
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.badge-active {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-emerald);
}

.badge-draft {
    background: rgba(156, 163, 175, 0.15);
    color: var(--text-secondary);
}

.badge-archived {
    background: rgba(245, 158, 11, 0.15);
    color: var(--accent-amber);
}

/* ─── Forms ──────────────────────────────────────── */
.form-control,
.form-select {
    background: var(--surface-2);
    border-color: var(--border-color);
    color: var(--text-primary);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.form-control:focus,
.form-select:focus {
    background: var(--surface-3);
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
    color: var(--text-primary);
}

.form-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

/* ─── Modals ─────────────────────────────────────── */
.modal-content {
    background: var(--surface-2);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
}

.modal-header {
    border-bottom-color: var(--border-color);
    padding: 20px 24px;
}

.modal-header .modal-title {
    font-weight: 600;
    font-size: 18px;
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    border-top-color: var(--border-color);
    padding: 16px 24px;
}

.modal-backdrop.show {
    opacity: 0.7;
}

/* ─── Dropdown ───────────────────────────────────── */
.dropdown-menu {
    background: var(--surface-2);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.3);
    padding: 8px;
}

.dropdown-item {
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    font-size: 14px;
    transition: all var(--transition-fast);
}

.dropdown-item:hover {
    background: var(--surface-3);
    color: var(--text-primary);
}

.dropdown-divider {
    border-color: var(--border-color);
}

/* ─── Product Images ─────────────────────────────── */
.product-thumb {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    border: 1px solid var(--border-color);
}

.product-thumb-placeholder {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    background: var(--surface-3);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 20px;
    border: 1px solid var(--border-color);
}

/* Image upload zone */
.upload-zone {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-lg);
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-base);
}

.upload-zone:hover,
.upload-zone.drag-over {
    border-color: var(--primary);
    background: var(--primary-glow);
}

.upload-zone i {
    font-size: 48px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

/* Image gallery */
.image-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
    margin-top: 16px;
}

.image-gallery-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.image-gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-gallery-item .image-actions {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.image-gallery-item:hover .image-actions {
    opacity: 1;
}

/* ─── API Key Display ────────────────────────────── */
.api-key-display {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface-3);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 14px;
}

.api-key-display .key-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--accent-teal);
}

/* ─── Empty State ────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 60px 20px;
}

.empty-state>i {
    font-size: 64px;
    color: var(--text-muted);
    margin-bottom: 20px;
    opacity: 0.5;
    display: block;
}

.empty-state h5 {
    font-weight: 600;
    margin-bottom: 8px;
}

.empty-state p {
    color: var(--text-muted);
    font-size: 14px;
    max-width: 400px;
    margin: 0 auto 24px;
}

/* ─── Utilities ──────────────────────────────────── */
.text-gradient {
    background: linear-gradient(135deg, var(--primary), var(--accent-teal));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.glass-card {
    background: rgba(255, 255, 255, 0.02);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
}

/* Action buttons in table */
.action-btns {
    display: flex;
    gap: 6px;
}

.action-btns .btn {
    padding: 5px 10px;
    font-size: 14px;
}

/* ─── Scrollbar ──────────────────────────────────── */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--surface-4);
    border-radius: 3px;
}

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

/* ─── Animations ─────────────────────────────────── */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

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

.fade-in-up {
    animation: fadeInUp 0.4s ease forwards;
}

@keyframes pulse-glow {

    0%,
    100% {
        box-shadow: 0 0 0 0 var(--primary-glow);
    }

    50% {
        box-shadow: 0 0 0 8px transparent;
    }
}

/* ─── Responsive ─────────────────────────────────── */
@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.show {
        transform: translateX(0);
    }

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

    .app-content {
        padding: 16px;
    }

    .topbar {
        padding: 0 16px;
    }

    .auth-decoration {
        display: none;
    }

    .auth-container {
        max-width: 480px;
    }
}

@media (max-width: 576px) {
    .stat-card .stat-value {
        font-size: 24px;
    }

    .content-card-header {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }
}