/* RESET & BASE STYLES */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #2c3e50;
    --secondary: #3498db;
    --success: #27ae60;
    --warning: #f39c12;
    --danger: #e74c3c;
    --light: #ecf0f1;
    --dark: #2c3e50;
    --gray: #95a5a6;
    --light-gray: #f8f9fa;
    --border: #ddd;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --radius: 8px;
    --redabf: #cb1515;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: var(--dark);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

/* LOGIN SCREEN */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

.login-card {
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    width: 100%;
    max-width: 450px;
    overflow: hidden;
}

.login-header {
    background: linear-gradient(135deg, #2c3e50 0%, #3498db 100%);
    color: white;
    padding: 40px 30px;
    text-align: center;
}

.login-header h1 {
    font-size: 1.8rem;
    margin-bottom: 10px;
}

.login-header .subtitle {
    opacity: 0.9;
    font-size: 1rem;
}

.login-body {
    padding: 40px 30px;
}

.form-group {
    margin-bottom: 25px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-group input {
    width: 100%;
    padding: 14px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    transition: all 0.3s ease;
}

.form-group input:focus {
    outline: none;
    border-color: var(--secondary);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.btn {
    padding: 14px 28px;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 600;
    font-size: 1rem;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.btn-login {
    width: 100%;
    background: linear-gradient(135deg, #27ae60 0%, #2ecc71 100%);
    color: white;
    font-size: 1.1rem;
    padding: 16px;
    margin-top: 10px;
}

.btn-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(39, 174, 96, 0.3);
}

.login-hint {
    margin-top: 25px;
    padding: 15px;
    background: var(--light-gray);
    border-radius: var(--radius);
    font-size: 0.9rem;
}

.login-hint p {
    margin-bottom: 5px;
}

.login-footer {
    padding: 20px;
    text-align: center;
    color: var(--gray);
    font-size: 0.9rem;
    border-top: 1px solid var(--border);
}

/* MAIN APP */
.container {
    max-width: 1200px;
    margin: 0 auto;
}

.hidden {
    display: none !important;
}

/* HEADER */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding: 20px;
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.header-left h1 {
    color: var(--primary);
    font-size: 2rem;
    margin-bottom: 5px;
}

.subtitle {
    color: var(--gray);
    font-size: 1.1rem;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

#currentUser {
    font-weight: 600;
    color: var(--secondary);
}

.btn-logout {
    background: var(--danger);
    color: white;
    padding: 8px 16px;
    font-size: 0.9rem;
}

.btn-logout:hover {
    background: #c0392b;
}

/* CARD STYLES */
.card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 25px;
    margin-bottom: 25px;
}

.card h2 {
    color: var(--primary);
    margin-bottom: 20px;
    font-size: 1.4rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.card h2 i {
    color: var(--secondary);
}

/* UPLOAD SECTION */
.upload-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: center;
    margin-bottom: 20px;
}

.file-input-container {
    flex: 1;
    min-width: 300px;
}

.file-input-container input[type="file"] {
    display: none;
}

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

.btn-primary:hover {
    background: #2980b9;
    transform: translateY(-2px);
}

.btn-scan {
    background: var(--success);
    color: white;
    padding: 12px 30px;
}

.btn-scan:hover {
    background: #219653;
}

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

.btn-export:hover {
    background: #e67e22;
}

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

#fileName {
    margin-left: 15px;
    color: var(--gray);
    font-style: italic;
}

.upload-info {
    display: flex;
    gap: 30px;
    flex-wrap: wrap;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.info-label {
    font-size: 0.9rem;
    color: var(--gray);
}

.info-value {
    font-weight: 600;
    color: var(--primary);
    font-size: 1.1rem;
}

/* FILE SIZE WARNING */
.warning-box {
    margin-top: 20px;
    padding: 20px;
    background: #fff8e1;
    border-left: 5px solid var(--warning);
    border-radius: var(--radius);
}

.warning-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
    color: #e65100;
    font-weight: 600;
}

.warning-content {
    line-height: 1.6;
}

.warning-content p {
    margin-bottom: 8px;
}

.warning-content ul {
    margin-left: 20px;
    margin-bottom: 15px;
}

.warning-content li {
    margin-bottom: 5px;
}

/* AUDIO CONTROLS */
.audio-controls {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px dashed var(--border);
}

.control-group {
    background: var(--light-gray);
    padding: 20px;
    border-radius: var(--radius);
}

.control-group h4 {
    margin-bottom: 15px;
    color: var(--primary);
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.control-row {
    display: flex;
    gap: 30px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.control-item {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
}

/* Switch toggle */
.switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 30px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--success);
}

input:checked + .slider:before {
    transform: translateX(30px);
}

.switch-label {
    font-weight: 500;
    min-width: 120px;
}

.control-item input[type="range"] {
    width: 200px;
    height: 6px;
    border-radius: 3px;
    background: var(--border);
    outline: none;
    opacity: 0.7;
    transition: opacity .2s;
}

.control-item input[type="range"]:hover {
    opacity: 1;
}

#rateValue {
    min-width: 40px;
    font-weight: 600;
    color: var(--secondary);
    margin-left: 10px;
}

.hint {
    color: var(--gray);
    font-size: 0.9rem;
    font-style: italic;
    margin-top: 10px;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

/* TABS */
.tabs {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-bottom: 25px;
}

.tab-buttons {
    display: flex;
    background: var(--light);
    border-bottom: 1px solid var(--border);
}

.tab-btn {
    flex: 1;
    padding: 18px;
    background: none;
    border: none;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--gray);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.tab-btn.active {
    background: white;
    color: var(--secondary);
    border-bottom: 3px solid var(--secondary);
}

.tab-btn:hover:not(.active) {
    background: rgba(255, 255, 255, 0.7);
}

.tab-content {
    display: none;
    padding: 25px;
}

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

/* SCAN TAB */
.scan-container {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 30px;
}

@media (max-width: 768px) {
    .scan-container {
        grid-template-columns: 1fr;
    }
}

.scan-input-section h3 {
    margin-bottom: 15px;
    color: var(--primary);
}

.input-group {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

#qrInput {
    flex: 1;
    padding: 15px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

#qrInput:focus {
    outline: none;
    border-color: var(--secondary);
}

.input-info {
    margin-bottom: 20px;
}

/* RAW DATA DISPLAY */
.raw-data {
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.raw-data h4 {
    margin-bottom: 10px;
    color: var(--primary);
    font-size: 1rem;
}

.raw-data-box {
    background: var(--dark);
    color: white;
    padding: 15px;
    border-radius: var(--radius);
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    margin-bottom: 10px;
    min-height: 60px;
    word-break: break-all;
}

.parsed-info {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    color: var(--gray);
}

.extracted-id {
    font-weight: 600;
    color: var(--success);
    font-size: 1.1rem;
    padding: 3px 10px;
    background: var(--light-gray);
    border-radius: 4px;
}

/* RECENT SCANS */
.recent-scans h4 {
    margin-bottom: 15px;
    color: var(--primary);
}

.scans-list {
    max-height: 300px;
    overflow-y: auto;
}

.scan-item {
    background: var(--light-gray);
    padding: 10px 15px;
    border-radius: var(--radius);
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-left: 4px solid var(--success);
}

.scan-item.duplicate {
    border-left-color: var(--warning);
}

.empty-state {
    text-align: center;
    color: var(--gray);
    font-style: italic;
    padding: 30px;
}

/* PREVIEW TAB */
.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.preview-header h3 {
    color: var(--primary);
}

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

#previewTable {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

#previewTable th {
    background: var(--primary);
    color: white;
    padding: 15px;
    text-align: left;
    font-weight: 600;
}

#previewTable td {
    padding: 12px 15px;
    border-bottom: 1px solid var(--border);
}

#previewTable tr:hover {
    background: var(--light-gray);
}

.status-badge {
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.status-pending {
    background: #fff3cd;
    color: #856404;
}

.status-scanned {
    background: #d4edda;
    color: #155724;
}

/* BACKUP TAB */
.backup-container {
    padding: 20px;
}

.backup-section h3 {
    margin-bottom: 20px;
    color: var(--primary);
}

.backup-info {
    background: var(--light-gray);
    padding: 15px;
    border-radius: var(--radius);
    margin-bottom: 25px;
}

.backup-info p {
    margin-bottom: 8px;
}

.backup-controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.backup-item {
    background: white;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
}

.backup-item h4 {
    margin-bottom: 10px;
    color: var(--primary);
}

.backup-item p {
    color: var(--gray);
    margin-bottom: 20px;
    font-size: 0.9rem;
}

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

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

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

.btn-backup:hover, .btn-restore:hover, .btn-clear:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.backup-status {
    background: var(--light-gray);
    padding: 20px;
    border-radius: var(--radius);
}

.backup-status h4 {
    margin-bottom: 15px;
    color: var(--primary);
}

.status-content {
    padding: 15px;
    background: white;
    border-radius: var(--radius);
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    max-height: 200px;
    overflow-y: auto;
}

/* INFORMATION DISPLAY */
.info-grid {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.info-row {
    display: grid;
    gap: 15px;
    padding: 15px;
    background: var(--light-gray);
    border-radius: var(--radius);
    align-items: center;
}

.row-1 {
    grid-template-columns: repeat(4, 1fr);
}

.row-2 .full-width {
    grid-column: 1 / -1;
}

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

.row-4 .full-width {
    grid-column: 1 / -1;
}

@media (max-width: 768px) {
    .row-1 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .row-3 {
        grid-template-columns: 1fr;
    }
}

.info-cell {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.cell-label {
    font-size: 0.9rem;
    color: var(--gray);
    font-weight: 600;
}

.cell-value {
    font-size: 1.1rem;
    color: var(--primary);
    font-weight: 600;
}
.cell-value-1 {
    font-size: 2rem;
    color: var(--redabf);
    font-weight: 700;
}

.status-cell {
    text-align: center;
    padding: 10px;
}

.status-text {
    font-size: 1.1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

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

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

/* AUTO SAVE STATUS */
.save-status {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--success);
    color: white;
    padding: 10px 20px;
    border-radius: var(--radius);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    animation: slideIn 0.3s ease;
}

.save-status-content {
    display: flex;
    align-items: center;
    gap: 10px;
}

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

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

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

/* INSTRUCTIONS */
.steps {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 15px;
}

.step {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: var(--light-gray);
    border-radius: var(--radius);
}

.step-number {
    width: 40px;
    height: 40px;
    background: var(--secondary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.step-text {
    color: var(--dark);
}

/* FOOTER */
.footer {
    text-align: center;
    padding: 20px;
    color: var(--gray);
    font-size: 0.9rem;
    margin-top: 30px;
}