/* Modern Refile Styles - Glassmorphism & Professional */
:root {
    --primary-bg: #1a1a2e;
    --card-bg: rgba(255, 255, 255, 0.05);
    --card-border: rgba(255, 255, 255, 0.1);
    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    --accent-color: #00d2ff;
    /* Cyan/Blue accent */
    --accent-hover: #3a7bd5;
    --danger-color: #ff4b4b;
    --success-color: #00c853;
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --font-main: 'Inter', 'Segoe UI', sans-serif;
}

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

body {
    font-family: var(--font-main);
    background-color: var(--primary-bg);
    background-image:
        radial-gradient(circle at 10% 20%, rgba(0, 210, 255, 0.1) 0%, transparent 20%),
        radial-gradient(circle at 90% 80%, rgba(58, 123, 213, 0.1) 0%, transparent 20%);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* --- Header --- */
header {
    background: rgba(26, 26, 46, 0.95);
    backdrop-filter: blur(10px);
    padding: 1rem 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid var(--card-border);
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    /* Left, Center, Right */
    align-items: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-center {
    display: flex;
    justify-content: center;
}

.header-right {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    align-items: center;
}

.app-title {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(45deg, #fff, var(--accent-color));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
    margin: 0;
}

/* --- Total Badge --- */
.total-badge {
    background: rgba(0, 210, 255, 0.1);
    border: 1px solid rgba(0, 210, 255, 0.3);
    padding: 0.5rem 1.5rem;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

.total-badge .label {
    font-size: 0.7rem;
    color: var(--accent-color);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.total-badge .amount {
    font-size: 1.5rem;
    font-weight: 700;
    color: #fff;
}

.reset-btn {
    background: var(--danger-color);
    color: white;
    border: none;
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-size: 0.75rem;
    cursor: pointer;
    margin-top: 0.3rem;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.reset-btn:hover {
    opacity: 1;
}

/* --- Buttons --- */
.btn {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    color: var(--text-primary);
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
}

.btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

.btn-primary {
    background: var(--accent-color);
    color: #000;
    border: none;
    font-weight: 600;
}

.btn-primary:hover {
    background: #33d9ff;
    box-shadow: 0 0 15px rgba(0, 210, 255, 0.4);
}

.btn-icon {
    padding: 0.6rem;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    justify-content: center;
}

/* --- Main Layout --- */
main {
    flex: 1;
    padding: 2rem;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 350px;
    /* Grid + Sidebar */
    gap: 2rem;
}

/* --- Slot Grid --- */
.slot-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1.5rem;
    align-content: start;
}

.slot-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    overflow: hidden;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    backdrop-filter: blur(5px);
    display: flex;
    flex-direction: column;
}

.slot-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--glass-shadow);
    border-color: var(--accent-color);
}

.slot-header-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 0.5rem;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.8), transparent);
    display: flex;
    justify-content: center;
    z-index: 2;
}

.slot-number-badge {
    background: var(--accent-color);
    color: #000;
    font-weight: 800;
    font-size: 1.8rem;
    /* Increased from 1.2rem */
    padding: 0.4rem 1.2rem;
    /* Increased padding */
    border-radius: 0 0 12px 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.3);
}

.slot-image {
    height: 180px;
    width: 100%;
    object-fit: cover;
    border-bottom: 1px solid var(--card-border);
}

.slot-info {
    padding: 1rem;
    text-align: center;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.slot-name {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.slot-action {
    margin-top: auto;
    font-size: 0.8rem;
    color: var(--accent-color);
    font-weight: 500;
    opacity: 0.8;
}

/* --- Recent Activity Sidebar --- */
.recent-activity {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 1.5rem;
    height: fit-content;
    max-height: calc(100vh - 150px);
    overflow-y: auto;
}

.recent-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--card-border);
    color: var(--text-secondary);
}

.activity-list {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.activity-item {
    background: rgba(0, 0, 0, 0.2);
    padding: 0.8rem;
    border-radius: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-left: 3px solid var(--accent-color);
    transition: all 0.2s;
}

.activity-item:hover {
    background: rgba(0, 0, 0, 0.3);
}

.activity-info {
    display: flex;
    flex-direction: column;
}

.activity-slot {
    font-weight: 600;
    font-size: 0.9rem;
}

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

.activity-amount {
    font-weight: 700;
    color: var(--success-color);
    margin-right: 1rem;
}

.delete-refill-btn {
    color: var(--danger-color);
    background: none;
    border: none;
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 0.2s;
    padding: 0.2rem;
}

.delete-refill-btn:hover {
    opacity: 1;
}

/* --- Modals --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

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

.modal {
    background: #252540;
    border: 1px solid var(--card-border);
    border-radius: 20px;
    padding: 2rem;
    width: 90%;
    max-width: 450px;
    box-shadow: var(--glass-shadow);
    transform: scale(0.9);
    transition: all 0.3s ease;
}

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

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

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

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

.close-modal:hover {
    color: #fff;
}

/* --- Quick Add Buttons --- */
.quick-amounts {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.amount-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--card-border);
    color: #fff;
    padding: 1rem;
    border-radius: 12px;
    font-size: 1.2rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.amount-btn:hover {
    background: var(--accent-color);
    color: #000;
    border-color: var(--accent-color);
}

.custom-input-group {
    display: flex;
    gap: 0.5rem;
}

.custom-input {
    flex: 1;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--card-border);
    padding: 0.8rem;
    border-radius: 8px;
    color: #fff;
    font-size: 1rem;
}

/* --- Toast Notification --- */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #333;
    color: #fff;
    padding: 1rem 2rem;
    border-radius: 50px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 2000;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

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

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

/* --- Settings Page Styles --- */
main.settings-layout {
    display: block;
    max-width: 1000px;
    margin: 0 auto;
}

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

.settings-item {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: all 0.2s;
}

.settings-item:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-color);
}

.settings-item img {
    width: 80px;
    height: 80px;
    border-radius: 8px;
    object-fit: cover;
    border: 1px solid var(--card-border);
    background: #000;
}

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

.settings-item-title {
    font-weight: 600;
    font-size: 1.1rem;
    margin-bottom: 0.2rem;
}

.settings-item-subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* --- Actions --- */
.settings-actions {
    display: flex;
    gap: 0.5rem;
}

/* --- Special Events --- */
.event-item {
    background: rgba(255, 75, 75, 0.1);
    border-left: 3px solid var(--danger-color);
}

.event-item .activity-amount {
    color: var(--danger-color);
}

.event-badge {
    background: var(--danger-color);
    color: white;
    font-size: 0.6rem;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 0.5rem;
    text-transform: uppercase;
    font-weight: bold;
}

.section-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 1.5rem 0 0.5rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--card-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.form-select,
.form-textarea {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--card-border);
    padding: 0.8rem;
    padding-right: 2.5rem;
    /* Space for arrow */
    border-radius: 8px;
    color: #fff;
    font-size: 1rem;
    font-family: var(--font-main);
    transition: all 0.2s;

    /* Custom Arrow */
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1.2em;
}

.form-select:focus,
.form-input:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--accent-color);
    background: rgba(0, 0, 0, 0.5);
    box-shadow: 0 0 0 2px rgba(0, 210, 255, 0.2);
}

/* For dropdown options - browser support varies but this covers Chrome/Firefox basic dark mode */
.form-select option {
    background-color: #252540;
    color: #ffffff;
    padding: 10px;
}

.form-textarea {
    resize: vertical;
    min-height: 80px;
}

.btn-ai {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.75rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    transition: all 0.2s;
    box-shadow: 0 2px 10px rgba(118, 75, 162, 0.3);
}

.btn-ai:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(118, 75, 162, 0.5);
}

.btn-ai i {
    font-size: 0.8rem;
}

/* Responsive */

.btn-voice {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-voice:hover {
    background: rgba(255, 255, 255, 0.2);
}

.btn-voice.recording {
    background: #ff4444;
    border-color: #ff4444;
    animation: pulse-red 1.5s infinite;
}

@keyframes pulse-red {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 68, 68, 0.4);
    }

    70% {
        box-shadow: 0 0 0 6px rgba(255, 68, 68, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(255, 68, 68, 0);
    }
}

@media (max-width: 1024px) {
    main {
        grid-template-columns: 1fr;
    }

    .recent-activity {
        order: 2;
        /* Move to bottom on mobile */
        max-height: 300px;
    }

    header {
        grid-template-columns: 1fr auto;
        gap: 1rem;
        flex-wrap: wrap;
    }

    .header-center {
        order: 3;
        width: 100%;
        margin-top: 1rem;
    }
}

@media (max-width: 768px) {
    .header-right span {
        display: none;
    }

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

/* VLT Styles */
.vlt-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-top: 1rem;
}

.vlt-btn {
    background: rgba(0, 255, 255, 0.1);
    border: 1px solid cyan;
    color: cyan;
    padding: 1.5rem 0.5rem;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: bold;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.vlt-btn:hover {
    background: cyan;
    color: #000;
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.4);
}

.vlt-btn:active {
    transform: scale(0.98);
}

.vlt-log-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.vlt-log-item {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(0, 255, 255, 0.2);
    padding: 0.8rem;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    color: #fff;
}

.vlt-log-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.vlt-log-machine {
    color: cyan;
    font-weight: bold;
    font-size: 0.75rem;
}

.vlt-log-time {
    color: #666;
    font-size: 0.7rem;
}

/* --- PRINT STYLES (Optimized for 80mm Thermal) --- */
@media print {
    @page {
        margin: 0;
        size: auto;
        /* Let printer handle size */
    }

    /* Hide specific elements to remove them from flow */
    header,
    main,
    .modal-overlay,
    .toast,
    audio {
        display: none !important;
    }

    /* Reset body styles */
    body {
        background: #fff !important;
        color: #000 !important;
        display: block !important;
        /* Override flex */
        margin: 0 !important;
        padding: 0 !important;
        width: 100%;
        height: auto !important;
        min-height: 0 !important;
        overflow: visible !important;
    }

    /* Show only the print container */
    #printReport {
        display: block !important;
        position: relative;
        width: 100%;
        padding: 0 2mm 0 5mm;
        /* Top Right Bottom Left - More space on left */
        margin: 0;
        font-family: 'Courier New', monospace;
    }

    /* Monospace looks better on receipts */


    /* Print Header */
    .print-header {
        text-align: center;
        margin-bottom: 5mm;
        border-bottom: 1px dashed #000;
        padding-bottom: 2mm;
    }

    .print-title {
        font-size: 16pt;
        font-weight: bold;
        margin: 0;
        color: #000;
        text-transform: uppercase;
    }

    .print-subtitle {
        font-size: 9pt;
        color: #000;
        margin-top: 2mm;
    }

    /* Print Table */
    .print-table {
        width: 100%;
        border-collapse: collapse;
        margin-bottom: 5mm;
    }

    .print-table th,
    .print-table td {
        border-bottom: 1px dotted #000;
        padding: 2mm 0;
        text-align: left;
        font-size: 9pt;
        vertical-align: top;
    }

    .print-table th {
        border-bottom: 1px solid #000;
        font-weight: bold;
        font-size: 8pt;
    }

    /* Column widths for thermal */
    .print-table th:nth-child(1),
    .print-table td:nth-child(1) {
        width: 10%;
    }

    /* # */
    .print-table th:nth-child(2),
    .print-table td:nth-child(2) {
        width: 40%;
    }

    /* Name */
    .print-table th:nth-child(3),
    .print-table td:nth-child(3) {
        width: 25%;
    }

    /* Time */
    .print-table th:nth-child(4),
    .print-table td:nth-child(4) {
        width: 25%;
        text-align: right;
    }

    /* Amount */

    .print-table tfoot td {
        border-top: 2px solid #000;
        padding-top: 3mm;
        font-size: 12pt;
    }

    /* Add space between label and total */
    .print-table tfoot td:first-child {
        padding-right: 5mm;
    }

    /* Print Footer */
    .print-footer {
        text-align: center;
        font-size: 8pt;
        color: #000;
        margin-top: 5mm;
        border-top: 1px dashed #000;
        padding-top: 2mm;
    }

    /* Event Block Styles for Print */
    #printEventTable div {
        page-break-inside: avoid;
    }
}