:root {
    --sage: #9CAF96;
    --terracotta: #D17B61;
    --sand: #E3D8C5;
    --charcoal: #1E1E1E;
    --cream: #F5F3F0;
    --white: #FFFFFF;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-700: #374151;
    --success: #10B981;
    --warning: #F59E0B;
    --info: #3B82F6;
    --error: #EF4444;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--gray-100);
    color: var(--charcoal);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Login Screen */
#loginScreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--charcoal);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    overflow-y: auto;
    padding: 1rem;
}

.login-card {
    background: var(--white);
    padding: 3rem;
    border-radius: 15px;
    width: 100%;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
}

.admin-logo {
    font-family: 'Playfair Display', serif;
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--charcoal);
    letter-spacing: 2px;
}

.admin-subtitle {
    color: var(--terracotta);
    font-size: 0.9rem;
    letter-spacing: 1px;
    margin-bottom: 2rem;
    font-weight: 600;
}

.login-form input {
    width: 100%;
    padding: 1rem;
    margin-bottom: 1rem;
    border: 2px solid var(--gray-200);
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.3s;
}

.login-form input:focus {
    outline: none;
    border-color: var(--sage);
}

.login-btn {
    width: 100%;
    padding: 1rem;
    background: var(--charcoal);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.login-btn:hover {
    background: var(--terracotta);
}

.login-btn:disabled {
    background: var(--gray-300);
    cursor: not-allowed;
}

/* Dashboard Layout */
.dashboard-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--charcoal);
    color: var(--cream);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 2rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-logo {
    font-family: 'Playfair Display', serif;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 1px;
}

.nav-menu {
    padding: 2rem 1rem;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 1rem;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    transition: all 0.3s;
    cursor: pointer;
}

.nav-item:hover,
.nav-item.active {
    background: rgba(255, 255, 255, 0.1);
    color: var(--white);
}

.nav-item i {
    margin-right: 1rem;
    width: 20px;
    text-align: center;
}

.sidebar-footer {
    padding: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.logout-btn {
    display: flex;
    align-items: center;
    color: var(--terracotta);
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    width: 100%;
    padding: 0.5rem;
}

.logout-btn:hover {
    color: var(--white);
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 2rem;
    min-height: 100vh;
    overflow-y: auto;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.page-title {
    font-family: 'Playfair Display', serif;
    font-size: 2rem;
    color: var(--charcoal);
}

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: var(--charcoal);
    font-size: 1.5rem;
    cursor: pointer;
}

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.stat-card {
    background: var(--white);
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-right: 1rem;
}

.stat-icon.revenue {
    background: rgba(156, 175, 150, 0.2);
    color: var(--sage);
}

.stat-icon.orders {
    background: rgba(209, 123, 97, 0.2);
    color: var(--terracotta);
}

.stat-icon.pending {
    background: rgba(245, 158, 11, 0.2);
    color: var(--warning);
}

.stat-icon.customers {
    background: rgba(59, 130, 246, 0.2);
    color: var(--info);
}

.stat-icon.events {
    background: rgba(156, 175, 150, 0.2);
    color: var(--sage);
}

.stat-icon.conversion {
    background: rgba(16, 185, 129, 0.2);
    color: var(--success);
}

.stat-icon.abandonment {
    background: rgba(239, 68, 68, 0.2);
    color: var(--error);
}

.stat-info h3 {
    font-size: 0.9rem;
    color: var(--gray-700);
    margin-bottom: 0.3rem;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--charcoal);
}

.stat-change {
    font-size: 0.8rem;
    margin-top: 0.3rem;
}

.stat-change.positive {
    color: var(--success);
}

.stat-change.negative {
    color: var(--error);
}

/* Orders Table */
.table-container {
    background: var(--white);
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    overflow: hidden;
}

.table-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.table-title {
    font-size: 1.2rem;
    font-weight: 600;
}

.search-box {
    position: relative;
}

.search-box input {
    padding: 0.6rem 1rem 0.6rem 2.5rem;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-size: 0.9rem;
    width: 250px;
}

.search-box i {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-300);
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;
    padding: 1rem 1.5rem;
    background: var(--gray-100);
    color: var(--gray-700);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

td {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--gray-200);
    color: var(--charcoal);
    font-size: 0.95rem;
}

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

tr:hover {
    background-color: #f9fafb;
}

.status-badge {
    padding: 0.3rem 0.8rem;
    border-radius: 50px;
    font-size: 0.8rem;
    font-weight: 600;
    display: inline-block;
}

.status-pending {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
}

.status-shipped {
    background: rgba(59, 130, 246, 0.15);
    color: var(--info);
}

.status-delivered {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
}

.status-cancelled {
    background: rgba(239, 68, 68, 0.15);
    color: #EF4444;
}

.status-test {
    background: rgba(156, 175, 150, 0.15);
    color: var(--sage);
}

.action-btn {
    padding: 0.4rem 0.8rem;
    background: var(--white);
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
    color: var(--gray-700);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.action-btn:hover {
    background: var(--gray-100);
    border-color: var(--gray-700);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    overflow-y: auto;
    padding: 1rem;
}

.modal.active {
    opacity: 1;
    pointer-events: all;
}

.modal-content {
    background: var(--white);
    width: 100%;
    max-width: 700px;
    border-radius: 12px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-family: 'Playfair Display', serif;
    font-size: 1.5rem;
}

.close-modal {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--gray-700);
}

.modal-body {
    padding: 2rem;
}

.order-section {
    margin-bottom: 2rem;
}

.section-label {
    font-size: 0.85rem;
    text-transform: uppercase;
    color: var(--gray-700);
    font-weight: 600;
    margin-bottom: 0.8rem;
    letter-spacing: 0.5px;
}

.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.info-item label {
    display: block;
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 0.3rem;
}

.info-item div {
    font-weight: 500;
    color: var(--charcoal);
}

.order-items-list {
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    overflow: hidden;
}

.order-item {
    display: flex;
    justify-content: space-between;
    padding: 1rem;
    border-bottom: 1px solid var(--gray-200);
}

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

.item-details {
    display: flex;
    gap: 1rem;
}

.item-qty {
    color: var(--sage);
    font-weight: 600;
    width: 30px;
}

.status-select {
    width: 100%;
    padding: 0.8rem;
    border: 2px solid var(--gray-200);
    border-radius: 8px;
    font-size: 1rem;
    margin-top: 0.5rem;
}

.save-btn {
    background: var(--sage);
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    float: right;
    transition: all 0.3s;
}

.save-btn:hover {
    background: #8a9d84;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--charcoal);
    color: white;
    padding: 1rem 2rem;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s;
    z-index: 3000;
    max-width: 350px;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast.error {
    background: var(--error);
}

.toast.success {
    background: var(--success);
}

.toast.warning {
    background: var(--warning);
}

/* Loading States */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
    margin-right: 10px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

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

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

    100% {
        background-position: -200% 0;
    }
}

/* Analytics & Customers Pages */
.page-section {
    display: none;
}

.page-section.active {
    display: block;
}

.charts-container {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.chart-card {
    background: var(--white);
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.chart-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.chart-container {
    height: 300px;
    position: relative;
}

.customers-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.customer-card {
    background: var(--white);
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.customer-name {
    font-weight: 600;
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.customer-details {
    color: var(--gray-700);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.customer-stats {
    display: flex;
    justify-content: space-between;
    border-top: 1px solid var(--gray-200);
    padding-top: 1rem;
}

.stat {
    text-align: center;
}

.stat-value {
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--charcoal);
}

.stat-label {
    font-size: 0.8rem;
    color: var(--gray-700);
}

/* Date Range Selector */
.date-range-selector {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.date-range-btn {
    padding: 0.5rem 1rem;
    background: var(--white);
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.date-range-btn.active {
    background: var(--sage);
    color: white;
    border-color: var(--sage);
}

/* Events Page Specific Styles */
.event-type-badge {
    padding: 0.3rem 0.8rem;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-block;
}

.event-website_open {
    background: rgba(156, 175, 150, 0.15);
    color: var(--sage);
}

.event-click_scent_card {
    background: rgba(59, 130, 246, 0.15);
    color: var(--info);
}

.event-scroll_depth {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
}

.event-add_to_cart {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
}

.event-remove_from_cart {
    background: rgba(239, 68, 68, 0.15);
    color: var(--error);
}

.event-abandon_cart {
    background: rgba(147, 51, 234, 0.15);
    color: #9333EA;
}

.event-complete_order {
    background: rgba(156, 175, 150, 0.25);
    color: var(--sage);
    font-weight: 700;
}

.event-click_social_icon {
    background: rgba(219, 39, 119, 0.15);
    color: #DB2777;
}

.event-details {
    font-size: 0.85rem;
    color: var(--gray-700);
    max-width: 300px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.event-value {
    font-weight: 600;
    color: var(--sage);
}

/* Filter Controls */
.filter-controls {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.filter-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--gray-700);
}

.filter-select {
    padding: 0.5rem 1rem;
    border: 2px solid var(--gray-200);
    border-radius: 6px;
    font-size: 0.9rem;
    min-width: 150px;
}

/* Event Details Modal */
.event-detail-item {
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--gray-200);
}

.event-detail-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.event-detail-label {
    font-size: 0.85rem;
    color: var(--gray-700);
    font-weight: 600;
    margin-bottom: 0.3rem;
}

.event-detail-value {
    font-size: 0.95rem;
    color: var(--charcoal);
    word-break: break-word;
}

.json-view {
    background: var(--gray-100);
    padding: 1rem;
    border-radius: 6px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.85rem;
    max-height: 200px;
    overflow-y: auto;
}

/* Responsive Improvements */
@media (max-width: 1024px) {
    .charts-container {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .dashboard-container {
        flex-direction: column;
        min-height: 100vh;
    }

    .sidebar {
        width: 100%;
        position: fixed;
        height: 100%;
        z-index: 100;
        transform: translateX(-100%);
        overflow-y: auto;
    }

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

    .main-content {
        padding: 1rem;
        width: 100%;
        overflow-x: hidden;
    }

    .mobile-menu-btn {
        display: block;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .table-container {
        overflow-x: auto;
    }

    table {
        min-width: 600px;
    }

    .table-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .search-box {
        width: 100%;
    }

    .search-box input {
        width: 100%;
    }

    .info-grid {
        grid-template-columns: 1fr;
    }

    .modal-content {
        margin: 0;
        max-height: calc(100vh - 2rem);
        width: calc(100% - 2rem);
    }

    .date-range-selector {
        flex-wrap: wrap;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .page-title {
        font-size: 1.5rem;
    }

    .customers-grid {
        grid-template-columns: 1fr;
    }

    .chart-container {
        height: 250px;
    }

    .filter-controls {
        flex-direction: column;
    }

    .filter-select {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .login-card {
        padding: 2rem;
        margin: 1rem;
    }

    .admin-logo {
        font-size: 1.5rem;
    }

    .main-content {
        padding: 1rem 0.5rem;
    }

    .stat-card {
        padding: 1rem;
    }

    .stat-icon {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
        margin-right: 0.75rem;
    }

    .stat-value {
        font-size: 1.2rem;
    }

    .modal-body {
        padding: 1.5rem;
    }

    .order-item {
        flex-direction: column;
        gap: 0.5rem;
    }

    .item-details {
        width: 100%;
    }

    .save-btn {
        width: 100%;
        float: none;
    }

    .toast {
        right: 10px;
        left: 10px;
        max-width: none;
    }

    .event-details {
        max-width: 150px;
    }
}