/* Admin Styles - Premium Tan & Gold Palette */
@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,300;0,400;0,500;0,600;0,700;1,400;1,500&family=Outfit:wght@300;400;500;600;700;800&display=swap');

:root {
    /* Premium Tan & Gold Palette */
    --bg-main: #fdfbf7;
    --bg-secondary: #f5eee3;
    --bg-tertiary: #ebe3d7;
    --bg-card: #ffffff;
    --bg-elevated: #faf8f4;

    --color-gold: #c8a96e;
    --color-gold-light: #d4b87d;
    --color-gold-dark: #a88d5a;
    --color-gold-deep: #8b734a;

    --color-bronze: #8c7350;
    --color-bronze-dark: #6b573d;
    --color-bronze-light: #a68e6d;

    --color-espresso: #3d342c;
    --color-espresso-light: #5a4e42;
    --color-taupe: #8a8176;
    --color-taupe-light: #b8b0a6;

    --color-text-primary: #2d2620;
    --color-text-secondary: #6b6258;
    --color-text-muted: #9a9187;
    --color-text-inverse: #fdfbf7;

    --color-border: #e5ddd3;
    --color-border-light: #efe8df;
    --color-border-dark: #d4cabd;

    --shadow-soft: 0 2px 12px rgba(61, 52, 44, 0.04);
    --shadow-medium: 0 8px 30px rgba(61, 52, 44, 0.08);
    --shadow-strong: 0 16px 48px rgba(61, 52, 44, 0.12);
    --shadow-gold: 0 8px 30px rgba(200, 169, 110, 0.25);
    --shadow-gold-strong: 0 16px 48px rgba(200, 169, 110, 0.35);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-xl: 28px;
    --radius-pill: 100px;

    --transition-fast: 150ms ease;
    --transition-base: 250ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
    --transition-slow: 400ms cubic-bezier(0.25, 0.46, 0.45, 0.94);

    --font-display: 'Cormorant Garamond', Georgia, serif;
    --font-body: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    --sidebar-width: 260px;
    --topbar-height: 70px;
}

/* Reset */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-body);
    line-height: 1.6;
    color: var(--color-text-primary);
    background-color: var(--bg-main);
    overflow-x: hidden;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

a {
    color: inherit;
    text-decoration: none;
}

button {
    font-family: inherit;
    font-size: inherit;
    border: none;
    background: none;
    cursor: pointer;
}

input,
select,
textarea {
    font-family: inherit;
    font-size: inherit;
    color: inherit;
}

ul,
ol {
    list-style: none;
}

/* Focus states */
*:focus-visible {
    outline: 3px solid var(--color-gold);
    outline-offset: 2px;
}

/* Selection */
::selection {
    background: var(--color-gold);
    color: var(--color-text-inverse);
}

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

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

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

::-webkit-scrollbar-thumb:hover {
    background: var(--color-bronze);
}

/* ========================================
   SIDEBAR
   ======================================== */
.e-sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-card);
    position: fixed;
    left: 0;
    top: 0;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--color-border);
    z-index: 1000;
}

.e-logo-container {
    padding: 24px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--color-border-light);
}

.e-logo-circle {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--color-gold) 0%, var(--color-gold-dark) 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-inverse);
    font-weight: 700;
    font-size: 1.25rem;
    font-family: var(--font-display);
    box-shadow: var(--shadow-gold);
}

.e-logo-text {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.5rem;
    color: var(--color-espresso);
    letter-spacing: 0.5px;
}

.e-sidebar-menu {
    margin-top: 16px;
    flex: 1;
    padding: 0 12px;
    overflow-y: auto;
}

.e-menu-item {
    display: flex;
    align-items: center;
    padding: 14px 18px;
    color: var(--color-text-secondary);
    text-decoration: none;
    transition: all var(--transition-fast);
    cursor: pointer;
    border-left: 3px solid transparent;
    font-weight: 500;
    font-size: var(--text-sm);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    margin-bottom: 4px;
}

.e-menu-item i {
    width: 28px;
    font-size: 1.1rem;
    text-align: center;
    transition: color var(--transition-fast);
}

.e-menu-item:hover,
.e-menu-item.active {
    background: var(--bg-secondary);
    color: var(--color-gold-dark);
    border-left-color: var(--color-gold);
}

.e-menu-item:hover i,
.e-menu-item.active i {
    color: var(--color-gold);
}

.e-logout-btn {
    margin: 16px;
    padding: 12px 20px;
    background: linear-gradient(135deg, var(--color-espresso) 0%, var(--color-bronze-dark) 100%);
    color: var(--color-text-inverse);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-weight: 600;
    font-size: var(--text-sm);
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-soft);
}

.e-logout-btn:hover {
    background: linear-gradient(135deg, var(--color-bronze-dark) 0%, var(--color-espresso) 100%);
    transform: translateY(-1px);
    box-shadow: var(--shadow-gold);
}

/* ========================================
   TOPBAR
   ======================================== */
.e-topbar {
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    height: var(--topbar-height);
    background: rgba(253, 251, 247, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0 32px;
    gap: 24px;
    border-bottom: 1px solid var(--color-border);
    z-index: 999;
    box-shadow: var(--shadow-soft);
}

.e-topbar-icon {
    color: var(--color-text-secondary);
    font-size: 1.25rem;
    cursor: pointer;
    transition: color var(--transition-fast);
    padding: 8px;
    border-radius: var(--radius-sm);
}

.e-topbar-icon:hover {
    color: var(--color-gold-dark);
    background: var(--bg-secondary);
}

.e-user-avatar {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--color-gold) 0%, var(--color-gold-dark) 100%);
    color: var(--color-text-inverse);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-family: var(--font-display);
    font-size: 1rem;
    box-shadow: var(--shadow-gold);
}

/* ========================================
   MAIN CONTENT
   ======================================== */
.e-main {
    margin-left: var(--sidebar-width);
    margin-top: var(--topbar-height);
    width: calc(100% - var(--sidebar-width));
    padding: 40px 48px;
    box-sizing: border-box;
}

.e-section-title {
    font-family: var(--font-display);
    font-weight: 500;
    font-size: var(--text-h1);
    margin-bottom: 32px;
    color: var(--color-espresso);
}

/* ========================================
   STATS GRID
   ======================================== */
.e-stats-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 20px;
    margin-bottom: 40px;
}

.e-stat-card {
    background: var(--bg-secondary);
    padding: 28px 24px;
    border-radius: var(--radius-lg);
    text-align: center;
    box-shadow: var(--shadow-soft);
    border: 1px solid var(--color-border-light);
    transition: all var(--transition-base);
}

.e-stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-medium);
    border-color: var(--color-border);
}

.e-stat-card i {
    font-size: 1.75rem;
    color: var(--color-gold);
    margin-bottom: 16px;
}

.e-stat-card p {
    font-family: var(--font-body);
    font-size: var(--text-sm);
    color: var(--color-text-muted);
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 500;
}

.e-stat-card h3 {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.75rem;
    margin: 12px 0 0;
    color: var(--color-espresso);
}

/* ========================================
   GRAPH CARD
   ======================================== */
.e-graph-card {
    background: var(--bg-card);
    padding: 32px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    border: 1px solid var(--color-border-light);
}

.e-graph-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}

.e-graph-header h3 {
    font-family: var(--font-display);
    font-weight: 500;
    font-size: 1.25rem;
    color: var(--color-espresso);
}

/* ========================================
   ADMIN SECTIONS
   ======================================== */
.admin-section {
    display: none;
}

.admin-section.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ========================================
   TABLES
   ======================================== */
.products-table-container,
.orders-table-container,
.users-table-container,
.bills-list {
    background: var(--bg-card);
    padding: 24px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    border: 1px solid var(--color-border-light);
    overflow-x: auto;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 16px;
}

.admin-table th {
    background: var(--bg-elevated);
    text-align: left;
    padding: 16px 20px;
    border-bottom: 2px solid var(--color-border);
    font-family: var(--font-body);
    font-weight: 600;
    font-size: var(--text-sm);
    color: var(--color-espresso);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.admin-table td {
    padding: 16px 20px;
    border-bottom: 1px solid var(--color-border-light);
    vertical-align: middle;
    font-family: var(--font-body);
    font-size: var(--text-sm);
    color: var(--color-text-primary);
}

.admin-table tr:hover td {
    background: var(--bg-elevated);
}

.admin-table tr:last-child td {
    border-bottom: none;
}

/* Status Badges */
.status-badge {
    padding: 6px 14px;
    border-radius: var(--radius-pill);
    font-family: var(--font-body);
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.status-confirmed { background: rgba(200, 169, 110, 0.15); color: var(--color-gold-dark); }
.status-pending { background: rgba(139, 115, 74, 0.15); color: var(--color-bronze); }
.status-shipped { background: rgba(166, 142, 109, 0.15); color: var(--color-bronze-light); }
.status-completed { background: rgba(61, 52, 44, 0.1); color: var(--color-espresso); }

/* Product Image in Table */
.admin-table td:first-child img {
    width: 50px;
    height: 50px;
    object-fit: contain;
    background: var(--bg-secondary);
    padding: 6px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border-light);
}

/* Action Buttons in Tables */
.admin-table .btn-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-muted);
    background: var(--bg-secondary);
    transition: all var(--transition-fast);
    margin-right: 8px;
}

.admin-table .btn-icon:hover {
    background: var(--bg-tertiary);
    color: var(--color-gold-dark);
}

.admin-table .btn-icon.delete:hover {
    background: rgba(229, 57, 53, 0.1);
    color: #e53935;
}

/* ========================================
   SECTION HEADER
   ======================================== */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.section-header .e-section-title {
    margin-bottom: 0;
}

.section-header .btn-primary {
    height: 45px;
    padding: 0 24px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-body);
    font-weight: 600;
    font-size: var(--text-sm);
    border-radius: var(--radius-pill);
}

/* ========================================
   FORMS
   ======================================== */
.form-group {
    margin-bottom: 20px;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-family: var(--font-body);
    font-weight: 600;
    font-size: var(--text-sm);
    color: var(--color-espresso);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: var(--text-body);
    background: var(--bg-card);
    transition: all var(--transition-fast);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--color-text-muted);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--color-gold);
    box-shadow: 0 0 0 4px rgba(200, 169, 110, 0.15);
    background: var(--bg-card);
}

/* Form Row Grid */
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
    margin-bottom: 16px;
}

/* Color Variants & Stock */
#colorVariantsList,
#additionalImagesList,
#powerPricingList,
#billItemsList {
    margin-top: 16px;
}

.color-variant-row,
.additional-image-row,
.power-price-row,
.bill-item-row {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 12px;
    padding: 12px;
    background: var(--bg-elevated);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border-light);
}

.color-variant-row input,
.additional-image-row input,
.power-price-row input,
.power-price-row select,
.bill-item-row input,
.bill-item-row select {
    flex: 1;
    min-width: 140px;
}

.remove-variant-btn {
    background: var(--color-text-muted);
    color: var(--color-text-inverse);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.remove-variant-btn:hover {
    background: #e53935;
    transform: scale(1.1);
}

/* Lens Pricing Section */
#lensPricingSection {
    margin-top: 16px;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
}

/* Image Preview */
#productImagePreview {
    width: 120px;
    height: 120px;
    object-fit: cover;
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border-light);
}

/* ========================================
   MODALS
   ======================================== */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(45, 38, 32, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.modal-content {
    background-color: var(--bg-card);
    margin: 3rem auto;
    padding: 0;
    border-radius: var(--radius-xl);
    width: 95%;
    max-width: 680px;
    position: relative;
    box-shadow: var(--shadow-strong);
    animation: modalFadeIn 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    max-height: 90vh;
    overflow-y: auto;
}

@keyframes modalFadeIn {
    from {
        transform: translateY(-20px) scale(0.98);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-elevated);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    position: sticky;
    top: 0;
    z-index: 10;
}

.modal-header h3 {
    margin: 0;
    font-family: var(--font-display);
    font-weight: 500;
    font-size: 1.375rem;
    color: var(--color-espresso);
}

.close {
    color: var(--color-text-muted);
    font-size: 1.5rem;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition-fast);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--bg-secondary);
}

.close:hover {
    color: var(--color-espresso);
    background: var(--bg-tertiary);
}

.modal-body {
    padding: 24px;
}

/* ========================================
   COUPON MANAGEMENT
   ======================================== */
#couponsTableBody tr td:nth-child(3) {
    font-family: var(--font-display);
    font-weight: 600;
    color: var(--color-gold-dark);
}

/* Type Pills */
#typePill_percent,
#typePill_flat,
#typePill_bogo {
    transition: all var(--transition-fast);
}

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 1200px) {
    .e-stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 1024px) {
    .e-sidebar {
        transform: translateX(-100%);
        transition: transform var(--transition-base);
    }

    .e-sidebar.active {
        transform: translateX(0);
    }

    .e-main,
    .e-topbar {
        left: 0;
        width: 100%;
    }

    .e-topbar {
        justify-content: space-between;
        padding: 0 20px;
    }

    .e-sidebar-toggle {
        display: block;
        background: none;
        border: none;
        font-size: 24px;
        cursor: pointer;
        color: var(--color-text-primary);
        margin-right: auto;
        padding: 8px 16px;
    }

    .e-stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .e-main {
        padding: 24px 16px;
    }

    .e-section-title {
        font-size: var(--text-h2);
    }

    .e-stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }

    .e-stat-card {
        padding: 20px 16px;
    }

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

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

    .e-graph-card {
        padding: 20px 16px;
    }

    .products-table-container,
    .orders-table-container,
    .users-table-container {
        padding: 16px;
    }

    .admin-table th,
    .admin-table td {
        padding: 12px 14px;
        font-size: var(--text-xs);
    }

    .modal-content {
        margin: 1.5rem auto;
        width: 95%;
        max-height: 95vh;
    }

    #productDetails {
        grid-template-columns: 1fr;
        gap: 24px;
    }

    .form-actions {
        flex-direction: column;
    }

    .form-actions button {
        width: 100%;
    }

    .e-topbar {
        height: 60px;
    }

    .e-main {
        margin-top: 60px;
    }

    .color-variant-row,
    .additional-image-row,
    .power-price-row,
    .bill-item-row {
        flex-direction: column;
        align-items: stretch;
    }

    .color-variant-row input,
    .additional-image-row input,
    .power-price-row input,
    .power-price-row select,
    .bill-item-row input,
    .bill-item-row select {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .e-stats-grid {
        grid-template-columns: 1fr;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* ========================================
   TOUCH DEVICES
   ======================================== */
@media (hover: none) {
    .e-stat-card:active {
        transform: scale(0.98);
        transition: transform 0.1s;
    }

    .btn-primary:active,
    .btn-secondary:active {
        transform: scale(0.97);
    }

    .e-menu-item:active {
        background: var(--bg-secondary);
        color: var(--color-gold-dark);
    }
}

/* ========================================
   REDUCED MOTION
   ======================================== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ========================================
   PRINT STYLES
   ======================================== */
@media print {
    .e-sidebar,
    .e-topbar,
    .modal,
    .section-header .btn-primary,
    .admin-table td:last-child,
    .remove-variant-btn {
        display: none !important;
    }

    .e-main {
        margin-left: 0;
        margin-top: 0;
        width: 100%;
        padding: 0;
    }

    body {
        background: white;
    }

    .admin-table {
        page-break-inside: auto;
    }

    .admin-table tr {
        page-break-inside: avoid;
        page-break-after: auto;
    }

    .admin-table th {
        background: #f5f5f5 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}

/* ========================================
   LOGIN PAGE STYLING
   ======================================== */
.login-hero {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4rem 24px;
  background:
    radial-gradient(ellipse 80% 50% at 50% 0%, var(--bg-secondary) 0%, transparent 70%),
    var(--bg-main);
}

.login-container {
  width: 100%;
  max-width: 440px;
  background: var(--bg-card);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-xl);
  padding: 48px 40px;
  box-shadow: var(--shadow-medium);
}

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

.login-header .logo {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 2rem;
  color: var(--color-espresso);
  margin-bottom: 8px;
}

.login-header .logo span {
  color: var(--color-gold);
  font-weight: 700;
}

.login-header p {
  font-family: var(--font-body);
  font-weight: 300;
  font-size: 1rem;
  color: var(--color-text-secondary);
}

.login-form .form-group {
  margin-bottom: 20px;
}

.login-form .btn-primary {
  width: 100%;
  padding: 16px;
  font-size: 1rem;
  margin-top: 8px;
}