/* Grenholm Frys - Main Stylesheet */

:root {
    --primary: #e11d48;
    --primary-dark: #be123c;
    --secondary: #1e40af;
    --success: #22c55e;
    --warning: #f59e0b;
    --error: #ef4444;
    --bg: #f8fafc;
    --surface: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    --radius: 12px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Navigation */
.navbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand a {
    text-decoration: none;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.25rem;
    font-weight: 600;
}

.brand-icon {
    font-size: 1.5rem;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nav-link {
    color: var(--text);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    transition: background 0.2s;
}

.nav-link:hover {
    background: var(--bg);
}

.cart-link {
    position: relative;
    text-decoration: none;
    padding: 0.5rem;
}

.cart-icon {
    font-size: 1.5rem;
}

.cart-count {
    position: absolute;
    top: -2px;
    right: -2px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
}

.main-content {
    flex: 1;
    max-width: 900px;
    margin: 0 auto;
    padding: 1.5rem;
    width: 100%;
}

.footer {
    text-align: center;
    padding: 1rem;
    color: var(--text-muted);
    font-size: 0.875rem;
    border-top: 1px solid var(--border);
}

/* Hero Section */
.hero-section {
    text-align: center;
    padding: 2rem 0;
}

.hero-section h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.hero-subtitle {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.employee-info {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-top: 1.5rem;
    box-shadow: var(--shadow);
}

.balance-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin: 1rem 0;
}

.balance-card {
    text-align: center;
    padding: 1rem;
    background: var(--bg);
    border-radius: var(--radius);
}

.balance-card .label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.balance-card .value {
    font-size: 1.25rem;
    font-weight: 600;
}

.balance-card .value.warning {
    color: var(--primary);
}

.guest-actions, .employee-info .btn-large {
    margin-top: 1rem;
}

.guest-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius);
    border: none;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-primary:disabled, .btn-primary.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

.btn-secondary:hover {
    background: var(--border);
}

.btn-swish {
    background: linear-gradient(135deg, #00a0d2 0%, #0084a5 100%);
    color: white;
}

.btn-swish:hover {
    background: linear-gradient(135deg, #0084a5 0%, #006680 100%);
}

.btn-scanner {
    background: var(--secondary);
    color: white;
    width: 100%;
    margin-top: 1rem;
}

.btn-scanner:hover {
    background: #1e3a8a;
}

.btn-large {
    font-size: 1.1rem;
    padding: 1rem 2rem;
}

.btn-add-cart {
    width: 100%;
    background: var(--success);
    color: white;
    margin-top: 0.5rem;
}

.btn-add-cart:hover {
    background: #16a34a;
}

.btn-quantity {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface);
    cursor: pointer;
    font-size: 1.25rem;
}

.btn-remove {
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.5rem;
}

/* Scanner Section */
.scanner-section {
    margin: 1.5rem 0;
}

.scanner-box {
    position: relative;
    background: #1e293b;
    border-radius: var(--radius);
    overflow: hidden;
    aspect-ratio: 4/3;
    display: none;
}

.scanner-box.active {
    display: block;
}

.scan-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    pointer-events: none;
}

.scan-line {
    width: 60%;
    height: 2px;
    background: var(--success);
    box-shadow: 0 0 10px var(--success);
    animation: scan 2s ease-in-out infinite;
}

@keyframes scan {
    0%, 100% { transform: translateY(-100px); opacity: 0; }
    50% { transform: translateY(100px); opacity: 1; }
}

.scan-text {
    position: absolute;
    bottom: 20px;
    color: white;
    background: rgba(0,0,0,0.7);
    padding: 0.5rem 1rem;
    border-radius: 20px;
}

#scanner-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* QR Section */
.qr-section {
    background: var(--surface);
    padding: 1.5rem;
    border-radius: var(--radius);
    text-align: center;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
}

.qr-code-display {
    margin: 1rem 0;
}

.qr-code-display img {
    max-width: 200px;
    border: 4px solid white;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
}

.qr-url {
    font-size: 0.75rem;
    color: var(--text-muted);
    word-break: break-all;
}

/* Products Grid */
.products-section {
    margin-top: 2rem;
}

.products-section h2 {
    margin-bottom: 1rem;
}

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

.product-card {
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
}

.product-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.product-card.low-stock {
    border: 2px solid var(--warning);
}

.product-image {
    aspect-ratio: 1;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

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

.product-image .placeholder {
    font-size: 3rem;
}

.stock-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: var(--warning);
    color: white;
    font-size: 0.7rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-weight: 600;
}

.product-info {
    padding: 1rem;
}

.product-info h3 {
    font-size: 0.95rem;
    margin-bottom: 0.25rem;
}

.product-info .barcode {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.product-info .description {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.product-footer .price {
    font-weight: 600;
    font-size: 1.1rem;
}

.product-footer .stock {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.product-footer .stock.warning {
    color: var(--warning);
    font-weight: 600;
}

/* Cart Page */
.cart-page {
    max-width: 600px;
    margin: 0 auto;
}

.cart-items {
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
    margin: 1rem 0;
}

.cart-item {
    display: flex;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    gap: 1rem;
}

.cart-item.unavailable {
    opacity: 0.6;
    background: #fef2f2;
}

.cart-item .item-info {
    flex: 1;
}

.cart-item .item-info h3 {
    font-size: 1rem;
    margin-bottom: 0.25rem;
}

.cart-item .price {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.cart-item .stock-warning {
    color: var(--error);
    font-size: 0.8rem;
}

.cart-item .item-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.quantity-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.quantity-input {
    width: 50px;
    text-align: center;
    padding: 0.25rem;
    border: 1px solid var(--border);
    border-radius: 6px;
}

.item-total {
    font-weight: 600;
    min-width: 70px;
    text-align: right;
}

.cart-summary {
    background: var(--surface);
    padding: 1rem;
    border-radius: var(--radius);
    margin: 1rem 0;
}

.total-row {
    display: flex;
    justify-content: space-between;
    font-size: 1.25rem;
}

.total-value {
    font-weight: 700;
    color: var(--primary);
}

.cart-actions {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
}

.employee-login-prompt {
    text-align: center;
    margin-top: 2rem;
    padding: 1.5rem;
    background: var(--surface);
    border-radius: var(--radius);
}

.employee-login-prompt p {
    margin-bottom: 1rem;
}

.empty-cart {
    text-align: center;
    padding: 3rem;
}

.empty-icon {
    font-size: 4rem;
    opacity: 0.5;
}

.empty-cart p {
    margin: 1rem 0;
    color: var(--text-muted);
}

/* Checkout Pages */
.checkout-page {
    max-width: 600px;
    margin: 0 auto;
}

.checkout-summary {
    background: var(--surface);
    padding: 1.5rem;
    border-radius: var(--radius);
    margin: 1rem 0;
    box-shadow: var(--shadow);
}

.checkout-summary h2 {
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.checkout-items {
    margin-bottom: 1rem;
}

.checkout-item {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px dashed var(--border);
}

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

.checkout-total {
    display: flex;
    justify-content: space-between;
    padding-top: 1rem;
    border-top: 2px solid var(--border);
    font-size: 1.1rem;
}

.total-amount {
    color: var(--primary);
    font-weight: 700;
}

.employee-info-card {
    background: var(--surface);
    padding: 1.5rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
}

.employee-info-card h2 {
    margin-bottom: 1rem;
}

.balance-preview {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.balance-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
}

.balance-row.total {
    font-weight: 600;
    border-bottom: 2px solid var(--border);
}

.balance-row.limit.over-limit {
    color: var(--error);
}

.limit-warning {
    color: var(--error);
    text-align: center;
    margin-top: 1rem;
}

.billing-info {
    background: var(--bg);
    padding: 1.5rem;
    border-radius: var(--radius);
    margin: 1rem 0;
}

.billing-info h3 {
    margin-bottom: 0.5rem;
}

.billing-info ul {
    margin-top: 0.5rem;
    padding-left: 1.5rem;
}

.billing-info li {
    margin-bottom: 0.25rem;
}

.swish-form {
    background: var(--surface);
    padding: 1.5rem;
    border-radius: var(--radius);
    margin: 1rem 0;
    box-shadow: var(--shadow);
}

.swish-form h2 {
    margin-bottom: 0.5rem;
}

.form-hint {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.form-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
}

.form-input:focus {
    outline: none;
    border-color: var(--secondary);
    box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.1);
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

.form-actions .btn {
    flex: 1;
}

.error-message {
    background: #fef2f2;
    color: var(--error);
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
}

.swish-info {
    background: #eff6ff;
    padding: 1.5rem;
    border-radius: var(--radius);
    margin-bottom: 2rem;
}

.swish-info h3 {
    margin-bottom: 0.5rem;
}

.swish-info ul {
    padding-left: 1.5rem;
}

.swish-info li {
    margin-bottom: 0.25rem;
}

/* Swish Pending */
.swish-pending-page {
    text-align: center;
    padding: 2rem 1rem;
}

.status-container {
    margin: 2rem 0;
}

.status-loading {
    margin-bottom: 2rem;
}

.spinner {
    width: 64px;
    height: 64px;
    border: 4px solid var(--border);
    border-top-color: var(--success);
    border-radius: 50%;
    margin: 0 auto 1rem;
    animation: spin 1s linear infinite;
}

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

.status-text {
    color: var(--text-muted);
}

.qr-display img {
    max-width: 280px;
    margin: 1rem 0;
    border: 8px solid white;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
}

.qr-hint {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.payment-details {
    background: var(--surface);
    padding: 1rem;
    border-radius: var(--radius);
    margin: 1.5rem 0;
}

.payment-details p {
    margin: 0.5rem 0;
}

.payment-details code {
    background: var(--bg);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-family: monospace;
}

.timer-section {
    margin: 1.5rem 0;
}

.countdown {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
}

.swish-app-hint {
    background: var(--bg);
    padding: 1.5rem;
    border-radius: var(--radius);
    margin-top: 1rem;
}

.swish-app-hint ol {
    text-align: left;
    padding-left: 1.5rem;
    margin-top: 0.5rem;
}

.swish-app-hint li {
    margin-bottom: 0.5rem;
}

.status .success {
    color: var(--success);
}

.status .error {
    color: var(--error);
}

/* Employee Dashboard */
.dashboard-page {
    max-width: 800px;
    margin: 0 auto;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin: 1.5rem 0;
}

.dashboard-card {
    background: var(--surface);
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.dashboard-card h2 {
    font-size: 1rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.balance-display {
    display: flex;
    flex-direction: column;
}

.balance-display .amount {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary);
}

.balance-display .limit {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.progress-bar {
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    margin-top: 0.75rem;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--primary);
    transition: width 0.3s;
}

.uninvoiced-amount {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--secondary);
}

.card-hint {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

.dashboard-card .btn {
    width: 100%;
    margin-bottom: 0.5rem;
}

.dashboard-card .btn:last-child {
    margin-bottom: 0;
}

.dashboard-section {
    background: var(--surface);
    padding: 1.5rem;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
}

.dashboard-section h2 {
    margin-bottom: 1rem;
}

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

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

.data-table th {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.85rem;
}

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

.status {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.85rem;
}

.status.success {
    background: #dcfce7;
    color: #166534;
}

.status.sent {
    background: #dbeafe;
    color: #1e40af;
}

.status.pending {
    background: #fef3c7;
    color: #92400e;
}

.btn-small {
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
}

.empty-state {
    color: var(--text-muted);
    text-align: center;
    padding: 2rem;
}

/* Login */
.login-page {
    max-width: 400px;
    margin: 2rem auto;
    text-align: center;
}

.login-form {
    background: var(--surface);
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin: 1.5rem 0;
    text-align: left;
}

.login-info {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Checkout Complete */
.checkout-complete-page {
    text-align: center;
    max-width: 500px;
    margin: 0 auto;
    padding: 2rem;
}

.success-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.checkout-complete-page h1 {
    margin-bottom: 1.5rem;
}

.receipt {
    background: var(--surface);
    padding: 2rem;
    border-radius: var(--radius);
    margin: 1.5rem 0;
    box-shadow: var(--shadow);
    text-align: left;
}

.receipt h2 {
    text-align: center;
    margin-bottom: 0.5rem;
}

.receipt-id {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 1.5rem;
}

.receipt-items {
    border-top: 1px dashed var(--border);
    border-bottom: 1px dashed var(--border);
    padding: 1rem 0;
    margin-bottom: 1rem;
}

.receipt-item {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
}

.receipt-total {
    display: flex;
    justify-content: space-between;
    font-size: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.employee-notice {
    background: #dcfce7;
    padding: 1rem;
    border-radius: var(--radius);
    margin-top: 1rem;
    text-align: center;
}

.employee-notice p {
    margin: 0.25rem 0;
}

.payment-method {
    text-align: center;
    margin-top: 1rem;
    color: var(--text-muted);
}

/* Messages */
.messages {
    margin-bottom: 1rem;
}

.message {
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
}

.message.error {
    background: #fef2f2;
    color: var(--error);
}

.message.success {
    background: #dcfce7;
    color: var(--success);
}

.message.warning {
    background: #fef3c7;
    color: var(--warning);
}

/* Error page */
.error-container {
    text-align: center;
    padding: 3rem 1rem;
}

.error-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.error-container h1 {
    margin-bottom: 1rem;
}

.error-container p {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

/* Responsive */
@media (max-width: 640px) {
    .main-content {
        padding: 1rem;
    }
    
    .balance-cards {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.5rem;
    }
    
    .balance-card {
        padding: 0.75rem;
    }
    
    .products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }
    
    .cart-actions {
        flex-direction: column;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}
