:root {
    --primary: #1a1a2e;
    --secondary: #16213e;
    --accent: #0f3460;
    --highlight: #e94560;
    --text: #eaeaea;
    --text-muted: #a0a0a0;
    --success: #00c853;
    --warning: #ffc107;
    --danger: #ff5252;
    --white: #ffffff;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    --radius: 12px;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    min-height: 100vh;
    color: var(--text);
    line-height: 1.6;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.container-sm {
    max-width: 500px;
    margin: 0 auto;
    padding: 20px;
}

/* Cards */
.card {
    background: var(--secondary);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 20px;
    border: 1px solid var(--accent);
}

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

.card-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--white);
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text);
}

.form-control {
    width: 100%;
    padding: 14px 16px;
    font-size: 16px;
    border: 2px solid var(--accent);
    border-radius: var(--radius);
    background: var(--primary);
    color: var(--text);
    transition: all 0.3s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--highlight);
    box-shadow: 0 0 0 3px rgba(233, 69, 96, 0.2);
}

.form-control::placeholder {
    color: var(--text-muted);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 28px;
    font-size: 16px;
    font-weight: 600;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
}

.btn-primary {
    background: var(--highlight);
    color: var(--white);
}

.btn-primary:hover {
    background: #d63d56;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(233, 69, 96, 0.4);
}

.btn-secondary {
    background: var(--accent);
    color: var(--text);
}

.btn-secondary:hover {
    background: #1a4a7a;
    transform: translateY(-2px);
}

.btn-success {
    background: var(--success);
    color: var(--white);
}

.btn-success:hover {
    background: #00a344;
    transform: translateY(-2px);
}

.btn-danger {
    background: var(--danger);
    color: var(--white);
}

.btn-danger:hover {
    background: #e04545;
}

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 14px;
}

.btn-lg {
    padding: 18px 36px;
    font-size: 18px;
}

/* Navigation */
.navbar {
    background: var(--secondary);
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 1000;
    border-bottom: 1px solid var(--accent);
}

.navbar-brand {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--highlight);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
}

.navbar-nav {
    display: flex;
    gap: 15px;
    list-style: none;
}

.nav-link {
    color: var(--text);
    text-decoration: none;
    padding: 10px 16px;
    border-radius: var(--radius);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-link:hover,
.nav-link.active {
    background: var(--accent);
    color: var(--highlight);
}

/* Scanner */
.scanner-container {
    position: relative;
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
    border-radius: var(--radius);
    overflow: hidden;
    background: #000;
}

#scanner-video {
    width: 100%;
    height: auto;
    display: block;
}

.scanner-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 250px;
    height: 150px;
    border: 3px solid var(--highlight);
    border-radius: 10px;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
}

.scanner-line {
    position: absolute;
    width: 100%;
    height: 2px;
    background: var(--highlight);
    animation: scan 2s linear infinite;
}

@keyframes scan {
    0% { top: 0; }
    50% { top: 100%; }
    100% { top: 0; }
}

/* Scanned Items List */
.items-list {
    list-style: none;
    max-height: 400px;
    overflow-y: auto;
}

.item-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    background: var(--primary);
    border-radius: var(--radius);
    margin-bottom: 10px;
    border: 1px solid var(--accent);
    transition: all 0.3s ease;
}

.item-card:hover {
    border-color: var(--highlight);
}

.item-info {
    flex: 1;
}

.item-name {
    font-weight: 600;
    color: var(--white);
    margin-bottom: 4px;
}

.item-barcode {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-family: monospace;
}

.item-quantity {
    display: flex;
    align-items: center;
    gap: 10px;
}

.quantity-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: var(--accent);
    color: var(--text);
    font-size: 18px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.quantity-btn:hover {
    background: var(--highlight);
}

.quantity-value {
    font-size: 1.2rem;
    font-weight: 600;
    min-width: 30px;
    text-align: center;
}

.item-remove {
    margin-left: 15px;
    color: var(--danger);
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.3s ease;
}

.item-remove:hover {
    transform: scale(1.2);
}

/* Orders Table */
.table-responsive {
    overflow-x: auto;
}

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

.table th,
.table td {
    padding: 14px;
    text-align: left;
    border-bottom: 1px solid var(--accent);
}

.table th {
    background: var(--accent);
    font-weight: 600;
    color: var(--white);
}

.table tr:hover {
    background: rgba(15, 52, 96, 0.3);
}

/* Badges */
.badge {
    display: inline-block;
    padding: 6px 12px;
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: 20px;
}

.badge-pending {
    background: var(--warning);
    color: #000;
}

.badge-sent {
    background: var(--success);
    color: var(--white);
}

.badge-completed {
    background: var(--accent);
    color: var(--text);
}

.badge-cancelled {
    background: var(--danger);
    color: var(--white);
}

/* Alerts */
.alert {
    padding: 16px 20px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.alert-success {
    background: rgba(0, 200, 83, 0.15);
    border: 1px solid var(--success);
    color: var(--success);
}

.alert-danger {
    background: rgba(255, 82, 82, 0.15);
    border: 1px solid var(--danger);
    color: var(--danger);
}

.alert-warning {
    background: rgba(255, 193, 7, 0.15);
    border: 1px solid var(--warning);
    color: var(--warning);
}

/* Auth Pages */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.auth-card {
    width: 100%;
    max-width: 450px;
}

.auth-logo {
    text-align: center;
    margin-bottom: 30px;
}

.auth-logo svg {
    width: 80px;
    height: 80px;
    color: var(--highlight);
}

.auth-logo h1 {
    margin-top: 15px;
    font-size: 1.8rem;
}

.auth-footer {
    text-align: center;
    margin-top: 20px;
    color: var(--text-muted);
}

.auth-footer a {
    color: var(--highlight);
    text-decoration: none;
}

.auth-footer a:hover {
    text-decoration: underline;
}

/* Dashboard Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--secondary);
    border-radius: var(--radius);
    padding: 24px;
    border: 1px solid var(--accent);
    text-align: center;
}

.stat-icon {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

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

.stat-label {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 5px;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--secondary);
    border-radius: var(--radius);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.9);
    transition: all 0.3s ease;
}

.modal-overlay.active .modal {
    transform: scale(1);
}

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

.modal-title {
    font-size: 1.3rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    transition: color 0.3s ease;
}

.modal-close:hover {
    color: var(--highlight);
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 20px;
    border-top: 1px solid var(--accent);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state svg {
    width: 80px;
    height: 80px;
    margin-bottom: 20px;
    opacity: 0.5;
}

.empty-state h3 {
    margin-bottom: 10px;
    color: var(--text);
}

/* Loader */
.loader {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: var(--white);
    animation: spin 1s linear infinite;
}

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

/* Key Search Dropdown */
.search-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--primary);
    border: 2px solid var(--accent);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
}

.search-item {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--accent);
    transition: background-color 0.2s ease;
}

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

.search-item:hover,
.search-item.selected {
    background: var(--accent);
}

.search-item-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.search-item-name {
    font-weight: 600;
    color: var(--white);
    flex: 1;
}

.search-item-category {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--secondary);
    padding: 2px 8px;
    border-radius: 4px;
}

.search-item-details {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 4px;
}

.search-item-barcode {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-family: monospace;
}

.search-item-qty {
    font-size: 0.75rem;
    color: var(--highlight);
    font-weight: 600;
}

.search-item mark {
    background: rgba(233, 69, 96, 0.3);
    color: var(--highlight);
    padding: 0 2px;
    border-radius: 2px;
}

.search-hint,
.search-no-results {
    color: var(--text-muted);
    text-align: center;
    cursor: default;
    font-style: italic;
}

.search-hint:hover,
.search-no-results:hover {
    background: transparent;
}

/* Spinner animation */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.spin {
    animation: spin 1s linear infinite;
}

/* Responsive */
@media (max-width: 768px) {
    .navbar {
        flex-direction: column;
        gap: 15px;
    }

    .navbar-nav {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
    }

    .nav-link {
        padding: 8px 12px;
        font-size: 0.9rem;
    }

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

    .table th,
    .table td {
        padding: 10px;
        font-size: 0.9rem;
    }

    .card {
        padding: 16px;
    }

    .btn {
        padding: 12px 20px;
    }
}

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

    .item-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .item-quantity {
        width: 100%;
        justify-content: space-between;
    }
}

/* PWA Install Prompt */
.install-prompt {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--secondary);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    padding: 16px 24px;
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: var(--shadow);
    z-index: 3000;
}

.install-prompt.hidden {
    display: none;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 4000;
}

.toast {
    background: var(--secondary);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 10px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideIn 0.3s ease;
    border-left: 4px solid var(--success);
}

.toast.error {
    border-left-color: var(--danger);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}
