/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(135deg, #ee3f4a 0%, #c73742 50%, #a02a33 100%);
    min-height: 100vh;
    color: #333;
    line-height: 1.6;
}

/* Container and Layout */
.container {
    max-width: 400px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* State Management */
.state {
    display: none;
    width: 100%;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.1);
    padding: 30px;
    text-align: center;
}

.state.active {
    display: block;
}

/* Header Section */
.header {
    margin-bottom: 30px;
}

/* Center expired title vertically */
#expired-state .header {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    margin-bottom: 15px;
}

#expired-state .logo {
    margin-bottom: 15px;
}

#expired-state .expired-title {
    margin: 0;
}

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

.logo-image {
    height: 150px;
    width: auto;
    max-width: 320px;
    object-fit: contain;
    margin: 0 auto;
    display: block;
    filter: none;
    transition: filter 0.3s ease;
}

.logo-image.expired {
    filter: grayscale(50%) opacity(0.7);
}

.logo-image.error {
    filter: grayscale(80%) opacity(0.6);
}

/* Keep placeholder styles for fallback */
.logo-placeholder {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    font-size: 24px;
    color: white;
}

.logo-placeholder.expired {
    background: linear-gradient(135deg, #ff6b6b 0%, #ffa500 100%);
}

.logo-placeholder.error {
    background: linear-gradient(135deg, #ff4757 0%, #ff3838 100%);
}

h1 {
    font-size: 28px;
    font-weight: 700;
    color: #2c3e50;
    margin: 0;
}

.expired-title {
    color: #e74c3c;
}

.error-title {
    color: #e74c3c;
}

/* QR Code Section */
.qr-section {
    margin-bottom: 30px;
}

.qr-container {
    background: white;
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.08);
    border: 2px solid #f8f9fa;
    position: relative;
}

.qr-container.expired {
    display: none;
}

.expired-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(231, 76, 60, 0.9);
    color: white;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 18px;
    z-index: 10;
}

#qr-code canvas {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
}

/* Discount Code Display */
.discount-code {
    margin-bottom: 20px;
}

.discount-code-label {
    font-size: 14px;
    color: #2c3e50;
    font-weight: 700;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.code-display {
    font-size: 32px;
    font-weight: 700;
    color: #2c3e50;
    letter-spacing: 3px;
    padding: 15px 20px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 12px;
    border: 2px solid #dee2e6;
    display: inline-block;
    font-family: 'Monaco', 'Consolas', monospace;
}

.code-display.expired {
    opacity: 0.5;
    color: #6c757d;
}

/* Expiration Section */
.expiration-section {
    margin-bottom: 15px;
}

.expiration-info {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.expires-label {
    font-size: 14px;
    color: #6c757d;
    margin-bottom: 0;
    font-weight: 500;
}

.expiration-date {
    font-size: 16px;
    font-weight: 600;
    color: #495057;
    margin-bottom: 0;
}

/* Countdown Timer */
.countdown {
    display: flex;
    justify-content: space-between;
    gap: 10px;
}

.countdown-item {
    flex: 1;
    background: white;
    border-radius: 8px;
    padding: 12px 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.countdown-number {
    display: block;
    font-size: 20px;
    font-weight: 700;
    color: #2c3e50;
    line-height: 1;
}

.countdown-label {
    display: block;
    font-size: 12px;
    color: #6c757d;
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Instructions */
.instructions {
    color: #6c757d;
    font-size: 16px;
    font-weight: 500;
}

/* Expired State Messages */
.expired-message {
    font-size: 18px;
    color: #e74c3c;
    font-weight: 600;
    margin: 0;
}

.sorry-message {
    font-size: 16px;
    color: #6c757d;
}

/* Error State */
.error-section {
    text-align: center;
    padding: 20px 0;
}

.error-message {
    font-size: 18px;
    color: #e74c3c;
    margin-bottom: 15px;
    font-weight: 500;
}

.help-message {
    font-size: 16px;
    color: #6c757d;
}

/* Loading State */
.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

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

#loading-state p {
    color: #6c757d;
    font-size: 16px;
}

/* Responsive Design */
@media (max-width: 480px) {
    .container {
        padding: 15px;
    }
    
    .state {
        padding: 20px;
    }
    
    .logo-image {
        height: 120px;
        max-width: 280px;
    }
    
    h1 {
        font-size: 24px;
    }
    
    .code-display {
        font-size: 24px;
        letter-spacing: 2px;
        padding: 12px 16px;
    }
    
    .countdown-item {
        padding: 10px 6px;
    }
    
    .countdown-number {
        font-size: 18px;
    }
    
    .countdown-label {
        font-size: 11px;
    }
}

@media (max-width: 360px) {
    .logo-image {
        height: 100px;
        max-width: 240px;
    }
    
    .countdown {
        gap: 6px;
    }
    
    .countdown-item {
        padding: 8px 4px;
    }
    
    .countdown-number {
        font-size: 16px;
    }
    
    .code-display {
        font-size: 20px;
        letter-spacing: 1px;
    }
}

/* High Contrast Mode for Better QR Scanning */
@media (prefers-contrast: high) {
    .qr-container {
        background: #ffffff;
        border: 3px solid #000000;
    }
    
    .code-display {
        background: #ffffff;
        border: 2px solid #000000;
        color: #000000;
    }
}

/* Accessibility Improvements */
@media (prefers-reduced-motion: reduce) {
    .loading-spinner {
        animation: none;
    }
    
    * {
        transition: none !important;
        animation: none !important;
    }
}

/* Print Styles for Emergency Backup */
@media print {
    body {
        background: white;
        color: black;
    }
    
    .state:not(.active) {
        display: none !important;
    }
    
    .container {
        padding: 0;
        max-width: none;
    }
    
    .qr-container {
        border: 2px solid #000;
    }
    
    .countdown, .instructions {
        display: none;
    }
}