/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.container {
    width: 100%;
    max-width: 700px;
}

.card {
    background: white;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    text-align: center;
}

.admin-card {
    max-width: 900px;
    margin: 0 auto;
}

.undian-card {
    max-width: 800px;
}

/* Typography */
h1 {
    color: #333;
    font-size: 32px;
    margin-bottom: 10px;
}

h2 {
    color: #555;
    font-size: 24px;
    margin-bottom: 15px;
}

h3 {
    color: #666;
    font-size: 20px;
    margin-bottom: 15px;
}

h4 {
    color: #777;
    font-size: 16px;
    margin-bottom: 10px;
}

.subtitle {
    color: #888;
    margin-bottom: 25px;
}

/* QR Reader */
#reader-container {
    margin: 20px 0;
    border-radius: 15px;
    overflow: hidden;
}

#reader {
    width: 100% !important;
    border: none !important;
}

#reader video {
    border-radius: 10px;
    width: 100% !important;
    max-height: 400px;
    object-fit: cover;
}

#reader__dashboard_section_csr span {
    color: #667eea !important;
}

#reader__camera_permission_button,
#reader__dashboard_section_swaplink {
    background: #667eea !important;
    color: white !important;
    padding: 10px 20px !important;
    border-radius: 8px !important;
    text-decoration: none !important;
}

/* Scan region highlight */
#reader__scan_region {
    background: rgba(102, 126, 234, 0.1) !important;
}

#reader__scan_region > img {
    display: none !important;
}

/* Status */
.status {
    margin: 20px 0;
    padding: 20px;
    border-radius: 15px;
    transition: all 0.3s ease;
}

.status.success {
    background: #d4edda;
    border: 2px solid #28a745;
}

.status.error {
    background: #f8d7da;
    border: 2px solid #dc3545;
}

.status-icon {
    font-size: 50px;
    margin-bottom: 10px;
}

.status.success .status-icon::before {
    content: "✅";
}

.status.error .status-icon::before {
    content: "❌";
}

#status-message {
    font-size: 16px;
    font-weight: 600;
    white-space: pre-line;
}

.status.success #status-message {
    color: #155724;
}

.status.error #status-message {
    color: #721c24;
}

/* Camera Select */
#camera-select-container {
    margin: 15px 0;
}

#camera-select-container label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #555;
}

#camera-select {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 16px;
    background: white;
    cursor: pointer;
}

#camera-select:focus {
    outline: none;
    border-color: #667eea;
}

/* Debug Info */
.debug-info {
    margin-top: 15px;
    font-size: 12px;
    color: #888;
}

.debug-info small {
    display: block;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 8px;
}

/* Buttons */
.button-group {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 20px;
}

.btn {
    padding: 12px 25px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-link {
    background: transparent;
    color: #667eea;
    text-decoration: underline;
}

.btn-large {
    padding: 18px 45px;
    font-size: 22px;
}

.btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

.btn-small {
    padding: 6px 12px;
    font-size: 12px;
}

/* Links */
.link-admin {
    display: block;
    margin-top: 15px;
    color: #667eea;
    text-decoration: none;
    font-weight: 500;
}

.link-admin:hover {
    text-decoration: underline;
}

.divider {
    height: 1px;
    background: #e0e0e0;
    margin: 25px 0;
}

/* Hidden Class */
.hidden {
    display: none !important;
}

/* Admin Tabs */
.tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 25px;
    border-bottom: 2px solid #e0e0e0;
    overflow-x: auto;
}

.tab-btn {
    padding: 12px 20px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: #666;
    border-bottom: 3px solid transparent;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.tab-btn:hover {
    color: #667eea;
}

.tab-btn.active {
    color: #667eea;
    border-bottom-color: #667eea;
}

.tab-content {
    display: none;
    text-align: left;
}

.tab-content.active {
    display: block;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #555;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 16px;
    transition: border-color 0.3s ease;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #667eea;
}

/* Table */
.table-container {
    overflow-x: auto;
    margin-bottom: 20px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

th, td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #e0e0e0;
}

th {
    background: #f8f9fa;
    font-weight: 600;
    color: #555;
}

tr:hover {
    background: #f8f9fa;
}

.badge {
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.badge-success {
    background: #d4edda;
    color: #155724;
}

.badge-secondary {
    background: #e2e3e5;
    color: #383d41;
}

/* QR Result */
.qr-result {
    margin-top: 25px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 15px;
    text-align: center;
}

#qrcode {
    display: flex;
    justify-content: center;
    margin-bottom: 15px;
}

#qrcode img {
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.qr-info {
    color: #666;
    font-size: 14px;
    margin-bottom: 15px;
}

.qr-all-result {
    margin-top: 25px;
}

#qr-all-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.qr-item {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 10px;
    text-align: center;
    page-break-inside: avoid;
}

.qr-item img {
    max-width: 100%;
    height: auto;
}

.qr-item-info {
    margin-top: 10px;
    font-size: 12px;
    color: #666;
}

/* ===== UNDIAN PAGE STYLES ===== */

/* Peserta Banner */
.peserta-banner {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 25px;
    border-radius: 15px;
    margin-bottom: 25px;
    animation: slideDown 0.5s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.peserta-label {
    font-size: 12px;
    opacity: 0.9;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.peserta-nama {
    font-size: 28px;
    font-weight: 700;
    margin: 10px 0;
}

.peserta-nik {
    font-size: 14px;
    opacity: 0.9;
}

/* Waiting Area */
.waiting-area {
    padding: 40px 20px;
    background: #f8f9fa;
    border-radius: 15px;
    margin: 20px 0;
}

.waiting-icon {
    font-size: 60px;
    margin-bottom: 15px;
    animation: pulse 2s infinite;
}

/* Rolling Area */
.rolling-area {
    padding: 20px;
    margin: 20px 0;
}

.rolling-label {
    font-size: 14px;
    color: #888;
    margin-bottom: 15px;
    letter-spacing: 2px;
}

.rolling-display {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    padding: 50px 30px;
    border-radius: 20px;
    margin-bottom: 25px;
    box-shadow: 0 10px 30px rgba(240, 147, 251, 0.3);
    position: relative;
    overflow: hidden;
}

.rolling-display::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        45deg,
        transparent 30%,
        rgba(255, 255, 255, 0.1) 50%,
        transparent 70%
    );
    animation: shimmer 3s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%) rotate(45deg); }
    100% { transform: translateX(100%) rotate(45deg); }
}

.rolling-text {
    font-size: 42px;
    font-weight: 800;
    color: white;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
    transition: transform 0.1s ease;
    position: relative;
    z-index: 1;
}

/* Controls Hint */
.controls-hint {
    margin: 20px 0;
}

.key-hint {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: #f8f9fa;
    padding: 10px 20px;
    border-radius: 10px;
}

.key {
    display: inline-block;
    padding: 8px 15px;
    background: #333;
    color: white;
    border-radius: 8px;
    font-weight: 700;
    font-size: 14px;
    box-shadow: 0 4px 0 #000;
}

#hint-text {
    font-weight: 600;
    color: #555;
}

/* Hasil Area */
.hasil-area {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    color: white;
    padding: 40px;
    border-radius: 20px;
    margin: 20px 0;
    animation: celebrate 0.6s ease;
}

@keyframes celebrate {
    0% { transform: scale(0.8); opacity: 0; }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); opacity: 1; }
}

.hasil-icon {
    font-size: 60px;
    margin-bottom: 10px;
}

.hasil-peserta {
    font-size: 28px;
    font-weight: 700;
    margin: 15px 0;
}

.hasil-text {
    font-size: 18px;
    opacity: 0.9;
    margin: 10px 0;
}

.hasil-hadiah {
    font-size: 36px;
    font-weight: 800;
    margin: 15px 0;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
    background: rgba(255, 255, 255, 0.2);
    padding: 15px 30px;
    border-radius: 15px;
    display: inline-block;
}

.hasil-waktu {
    font-size: 14px;
    opacity: 0.9;
    margin-top: 15px;
}

/* Stats Container */
.stats-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin: 25px 0;
}

.stat-box {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 12px;
    text-align: center;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: #667eea;
}

.stat-label {
    font-size: 12px;
    color: #888;
    margin-top: 5px;
}

/* Hadiah Tersedia */
.hadiah-tersedia {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 15px;
    margin-top: 20px;
    text-align: left;
}

.list-hadiah {
    max-height: 150px;
    overflow-y: auto;
}

.hadiah-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    border-bottom: 1px solid #e0e0e0;
}

.hadiah-item:last-child {
    border-bottom: none;
}

.hadiah-item.habis {
    opacity: 0.5;
}

.hadiah-nama {
    font-weight: 500;
    color: #555;
}

.hadiah-sisa {
    font-size: 12px;
    padding: 4px 10px;
    background: #d4edda;
    color: #155724;
    border-radius: 20px;
}

.hadiah-sisa.habis {
    background: #f8d7da;
    color: #721c24;
}

/* Manual Input Section */
.manual-input {
    margin-top: 20px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 10px;
}

.manual-input h4 {
    margin-bottom: 10px;
    color: #555;
}

.manual-input input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
    margin-bottom: 10px;
}

.manual-input input:focus {
    outline: none;
    border-color: #667eea;
}

/* Print Area */
#print-area {
    background: white;
}

/* Print Styles */
@media print {
    body {
        background: white;
    }
    
    .container {
        max-width: 100%;
    }
    
    .card {
        box-shadow: none;
    }
    
    .no-print {
        display: none !important;
    }
}

/* Responsive */
@media (max-width: 600px) {
    .card {
        padding: 20px;
    }
    
    h1 {
        font-size: 24px;
    }
    
    .peserta-nama {
        font-size: 22px;
    }
    
    .rolling-text {
        font-size: 28px;
    }
    
    .hasil-hadiah {
        font-size: 24px;
    }
    
    .stats-container {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .btn-large {
        padding: 15px 30px;
        font-size: 18px;
    }
    
    #reader video {
        max-height: 300px;
    }
    
    .rolling-display {
        padding: 30px 20px;
    }
}

@media (max-width: 480px) {
    .stats {
        gap: 15px;
    }
    
    .stat-number {
        font-size: 28px;
    }
    
    .btn {
        padding: 10px 20px;
        font-size: 14px;
    }
}
