:root {
    --primary: #818cf8;
    --primary-dark: #6366f1;
    --success: #34d399;
    --warning: #fbbf24;
    --danger: #f87171;
    --background: #0f172a;
    --surface: #1e293b;
    --surface-light: #334155;
    --text: #e2e8ff;
    --text-muted: #94a3b8;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--background);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

.dashboard-section {
    padding: 2rem;
    max-width: 1600px;
    margin: 0 auto;
}

.dashboard-header {
    background-color: var(--surface);
    border-radius: 1rem;
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-content h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

.header-actions {
    display: flex;
    gap: 1rem;
}

.action-button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    background-color: var(--surface-light);
    color: var(--text);
    border: none;
    cursor: pointer;
    font-size: 0.875rem;
    text-decoration: none;
    transition: all 0.2s ease;
}

.action-button:hover {
    background-color: var(--primary);
    transform: translateY(-1px);
}

.action-button svg {
    width: 1.25rem;
    height: 1.25rem;
}

.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.card {
    background-color: var(--surface);
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.card h3 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    color: var(--text);
}

.overview-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1.5rem;
}

.stat {
    text-align: center;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.performance-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 1.5rem;
    text-align: center;
}

.performance-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-circle {
    position: relative;
    width: 100px;
    height: 100px;
    margin-bottom: 1rem;
}

.stat-circle canvas {
    position: absolute;
    top: 0;
    left: 0;
}

.stat-circle .stat-value {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.25rem;
    margin: 0;
}

.activity-list, .alerts-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.activity-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background-color: var(--surface-light);
    border-radius: 0.5rem;
}

.activity-icon {
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 1rem;
}

.activity-icon.success {
    background-color: rgba(52, 211, 153, 0.2);
    color: var(--success);
}

.activity-icon.warning {
    background-color: rgba(251, 191, 36, 0.2);
    color: var(--warning);
}

.activity-icon.info {
    background-color: rgba(129, 140, 248, 0.2);
    color: var(--primary);
}

.activity-content {
    flex: 1;
}

.activity-title {
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.activity-time {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.alert-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    border-radius: 0.5rem;
}

.alert-item.high {
    background-color: rgba(248, 113, 113, 0.2);
    border: 1px solid rgba(248, 113, 113, 0.3);
}

.alert-item.medium {
    background-color: rgba(251, 191, 36, 0.2);
    border: 1px solid rgba(251, 191, 36, 0.3);
}

.alert-item.low {
    background-color: rgba(129, 140, 248, 0.2);
    border: 1px solid rgba(129, 140, 248, 0.3);
}

.alert-content {
    flex: 1;
}

.alert-title {
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.alert-description {
    font-size: 0.875rem;
    color: var(--text-muted);
}

@media (max-width: 768px) {
    .dashboard-section {
        padding: 1rem;
    }
    
    .grid-container {
        grid-template-columns: 1fr;
    }
    
    .header-content {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }
    
    .header-actions {
        width: 100%;
        flex-wrap: wrap;
    }
    
    .action-button {
        flex: 1;
        justify-content: center;
    }
}

.dashboard-container {
    display: flex;
    height: 100vh;
    position: relative;
    z-index: 1;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.dashboard-nav {
    width: 260px;
    background: rgba(10, 13, 28, 0.95);
    border-right: 1px solid var(--border-color);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
}

.nav-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

.nav-logo {
    width: 40px;
    height: 40px;
    border-radius: 8px;
}

.nav-header h1 {
    font-size: 1.2rem;
    margin: 0;
    color: var(--text-color);
}

.nav-button {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    color: var(--text-color);
    text-decoration: none;
    transition: all 0.3s ease;
    background: rgba(67, 56, 202, 0.1);
    border: 1px solid rgba(67, 56, 202, 0.2);
}

.nav-button svg {
    width: 20px;
    height: 20px;
}

.nav-button:hover {
    background: var(--message-bg-user);
    transform: translateY(-1px);
}

.nav-divider {
    height: 1px;
    background: var(--border-color);
    margin: 1.5rem 0;
}

.nav-links {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-link {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    color: var(--text-color);
    text-decoration: none;
    transition: all 0.3s ease;
}

.nav-link:hover, .nav-link.active {
    background: rgba(67, 56, 202, 0.1);
}

.dashboard-content {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
}

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

.content-header h2 {
    margin: 0;
    font-size: 1.5rem;
}

.date-range select {
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.9rem;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
    margin-bottom: 2rem;
}

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

.stat-item {
    background: rgba(255, 255, 255, 0.05);
    padding: 1rem;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.stat-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

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

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

.view-all-link {
    color: var(--accent-color);
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.view-all-link:hover {
    text-decoration: underline;
}

.recent-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.fresh-products-section {
    margin-top: 2rem;
}

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

.section-header h2 {
    margin: 0;
    font-size: 1.5rem;
}

.section-actions {
    display: flex;
    gap: 1rem;
}

.fresh-products-grid {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 1.5rem;
}

.fresh-products-form {
    height: fit-content;
    position: sticky;
    top: 1.5rem;
}

.tracking-section {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

.performance-card {
    grid-column: span 2;
    padding: 2rem;
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.95) 0%, rgba(30, 41, 59, 0.8) 100%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.performance-card h3 {
    margin-bottom: 2rem;
    font-size: 1.25rem;
    color: #e2e8ff;
}

.performance-stats {
    display: flex;
    justify-content: space-around;
    margin-bottom: 2rem;
}

.performance-stat {
    text-align: center;
}

.stat-circle {
    width: 120px;
    height: 120px;
    margin: 0 auto 1rem;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-circle canvas {
    position: absolute;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 600;
    color: #e2e8ff;
}

.stat-label {
    font-size: 0.9rem;
    color: #94a3b8;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

@media (min-width: 1400px) {
    .form-row {
        grid-template-columns: 1fr 1fr;
    }
}

.form-group input {
    width: 100%;
    box-sizing: border-box;
}

.monitoring-section {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

.alert-list, .scan-list {
    max-height: 400px;
}

.card {
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    animation: fadeIn 0.5s ease-out;
}

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

.card h3 {
    margin: 0 0 1rem 0;
    font-size: 1.1rem;
    color: var(--text-color);
}

.fresh-product-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

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

.form-group label {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.form-group input {
    padding: 0.75rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: var(--input-bg);
    color: var(--text-color);
    font-size: 0.95rem;
    transition: all 0.3s ease;
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(129, 140, 248, 0.1);
}

.action-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    border: none;
    background: var(--message-bg-user);
    color: var(--text-color);
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.action-button svg {
    width: 20px;
    height: 20px;
}

.action-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
}

.qr-result {
    margin-top: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.qr-preview {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    margin-top: 1rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
}

.qr-preview #qrCode {
    background: white;
    padding: 1rem;
    border-radius: 8px;
}

.qr-preview #qrCode img {
    display: block;
    max-width: 100%;
    height: auto;
}

.download-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: #4CAF50;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.download-btn:hover {
    background: #45a049;
}

.download-btn i {
    font-size: 1.2rem;
}

.scan-list, .alert-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.scan-item, .alert-item {
    padding: 0.75rem;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.scrollable {
    max-height: 300px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.scrollable::-webkit-scrollbar {
    width: 6px;
}

.scrollable::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

.scrollable::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.scrollable::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

.metric {
    display: flex;
    align-items: baseline;
    gap: 1rem;
    margin-bottom: 1rem;
}

.metric .value {
    font-size: 2rem;
    font-weight: 600;
    color: var(--text-color);
}

.change.positive {
    color: #34D399;
    background: rgba(52, 211, 153, 0.1);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

.change.negative {
    color: #EF4444;
    background: rgba(239, 68, 68, 0.1);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

.product-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

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

.product-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.product-name {
    color: var(--text-color);
}

.product-sales {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.progress-bar {
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
}

.progress {
    height: 100%;
    background: linear-gradient(90deg, var(--message-bg-user), var(--accent-color));
    border-radius: 3px;
    transition: width 0.3s ease;
}

canvas {
    width: 100% !important;
    height: 200px !important;
    margin-top: 1rem;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal.active {
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: var(--card-bg);
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    animation: modalFadeIn 0.3s ease-out;
}

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

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

.modal-header h3 {
    margin: 0;
    font-size: 1.2rem;
}

.close-modal {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-color);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 6px;
    transition: all 0.3s ease;
}

.close-modal:hover {
    background: rgba(255, 255, 255, 0.1);
}

.modal-body {
    padding: 1.5rem;
}

.scan-tabs {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.scan-tab {
    padding: 0.75rem 1.5rem;
    border: none;
    background: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.3s ease;
}

.scan-tab.active {
    background: var(--message-bg-user);
    color: var(--text-color);
}

.scan-content {
    display: none;
    height: 400px;
}

.scan-content.active {
    display: block;
}

#reader {
    width: 100%;
    height: 100%;
}

.product-details {
    padding: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    overflow-y: auto;
}

.details-content {
    display: grid;
    gap: 1rem;
}

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

.detail-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.detail-value {
    font-size: 1.1rem;
    color: var(--text-color);
}

#reader-container {
    position: relative;
    width: 100%;
    height: 300px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 1rem;
}

#reader-container video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
    transition: transform 0.3s ease;
}

.reader-controls {
    display: flex;
    gap: 1rem;
    margin: 1rem 0;
    flex-wrap: wrap;
}

.reader-controls .action-button {
    flex: 1;
    min-width: 150px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem;
    background: var(--button-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.reader-controls .action-button:hover {
    background: var(--button-hover-bg);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.reader-controls .action-button:active {
    transform: translateY(0);
}

.reader-controls .icon {
    font-size: 1.2rem;
    line-height: 1;
}

.reader-instructions {
    margin: 1rem 0;
    padding: 1.25rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.reader-instructions h4 {
    margin: 0 0 1rem 0;
    color: var(--text-color);
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.reader-instructions h4::before {
    content: "💡";
    font-size: 1.2rem;
}

.reader-instructions ol {
    margin: 0;
    padding-left: 1.5rem;
    color: var(--text-secondary);
}

.reader-instructions li {
    margin-bottom: 0.75rem;
    line-height: 1.4;
}

.reader-instructions li:last-child {
    margin-bottom: 0;
}

.reader-status {
    background: rgba(255, 255, 255, 0.05);
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    text-align: center;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    font-size: 0.95rem;
}

.reader-fallback {
    padding: 1.25rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    margin-top: 1rem;
    border: 1px solid var(--border-color);
}

.reader-fallback p {
    margin: 0 0 1rem 0;
    color: var(--text-secondary);
}

.reader-fallback ol {
    margin: 0 0 1.5rem 0;
    padding-left: 1.5rem;
    color: var(--text-secondary);
}

.reader-fallback li {
    margin-bottom: 0.75rem;
    line-height: 1.4;
}

.manual-input {
    border-top: 1px solid var(--border-color);
    padding-top: 1.25rem;
    margin-top: 1.25rem;
}

.manual-input p {
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

.manual-input input {
    width: 100%;
    padding: 0.75rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: var(--input-bg);
    color: var(--text-color);
    margin-bottom: 1rem;
    font-size: 0.95rem;
}

.manual-input input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(129, 140, 248, 0.1);
}

.manual-input .action-button {
    width: 100%;
    padding: 0.75rem;
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.95rem;
    transition: all 0.3s ease;
}

.manual-input .action-button:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

.qr-options {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.qr-options .action-button {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem;
    background: var(--button-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.3s ease;
}

.qr-options .action-button:hover {
    background: var(--button-hover-bg);
    transform: translateY(-1px);
}

.qr-options .icon {
    font-size: 1.2rem;
}

.qr-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    padding: 1rem;
    margin-top: 1rem;
}

.qr-preview img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
}

.qr-preview.empty {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.products-list {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 400px;
    overflow-y: auto;
}

.product-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    margin-bottom: 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    transition: all 0.3s ease;
}

.product-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.product-info {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.product-name {
    font-weight: 600;
    color: #e2e8ff;
}

.product-quantity,
.product-expiry,
.product-invoice {
    font-size: 0.9rem;
    color: #a4b0f5;
}

.product-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-edit,
.btn-delete {
    background: none;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.btn-edit {
    color: #4CAF50;
}

.btn-delete {
    color: #f44336;
}

.btn-edit:hover {
    background: rgba(76, 175, 80, 0.1);
}

.btn-delete:hover {
    background: rgba(244, 67, 54, 0.1);
}
