/* Sleek, professional dark theme for ticket scanner */
:root {
    /* Color palette */
    --primary-color: #3d5afe;
    --primary-dark: #2a3eb1;
    --success-color: #00e676;
    --error-color: #ff1744;
    --background-color: #121212;
    --surface-color: #1e1e1e;
    --text-color: #ffffff;
    --text-secondary: #b0b0b0;
    
    /* UI elements */
    --border-radius: 16px;
    --border-radius-sm: 8px;
    --shadow: 0 8px 16px rgba(0, 0, 0, 0.4);
    --shadow-sm: 0 4px 8px rgba(0, 0, 0, 0.3);
    --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    --app-height: 100vh;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Rajdhani', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
}

html {
    height: -webkit-fill-available;
}

body {
    padding: 10px;
    background-color: var(--background-color);
    color: var(--text-color);
    min-height: 100vh;
    min-height: -webkit-fill-available;
    display: flex;
    flex-direction: column;
    transition: background-color 0.5s ease;
}

body.success-scan {
    background-color: rgba(0, 204, 0, 0.3);
    animation: success-background 3s ease;
}

body.error-scan {
    background-color: rgba(204, 0, 0, 0.3);
    animation: error-background 3s ease;
}

@keyframes success-background {
    0% { background-color: var(--background-color); }
    20% { background-color: rgba(0, 204, 0, 0.3); }
    100% { background-color: rgba(0, 204, 0, 0.3); }
}

@keyframes error-background {
    0% { background-color: var(--background-color); }
    20% { background-color: rgba(204, 0, 0, 0.3); }
    100% { background-color: rgba(204, 0, 0, 0.3); }
}

#scanner-container {
    position: relative;
    width: 100%;
    height: 50vh;
    overflow: hidden;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    background-color: #000;
    margin-bottom: 15px;
    border: 2px solid #2d2d2d;
}

#top-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    z-index: 20;
    background: linear-gradient(to bottom, rgba(0,0,0,0.7) 0%, rgba(0,0,0,0) 100%);
}

#logo-container {
    padding: 8px;
    background-color: rgba(0, 0, 0, 0.5);
    border-radius: var(--border-radius);
}

#logo {
    height: 32px;
    width: auto;
    display: block;
    transition: var(--transition);
}

#toggleButton {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: var(--border-radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

#toggleButton:disabled {
    background-color: #666;
    cursor: not-allowed;
}

#toggleButton.scanning {
    background-color: #f44336;
}

#result-container {
    padding: 20px;
    background-color: rgba(30, 30, 30, 0.9);
    border-radius: var(--border-radius);
    margin-bottom: 15px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
}

/* Improve result display for better readability on mobile */
#result {
    white-space: pre-line;
    text-align: center;
    line-height: 1.4;
    margin-top: 10px;
    max-height: 300px;
    overflow-y: auto;
    padding: 12px;
    background-color: rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    border-radius: var(--border-radius-sm);
    font-size: 22px;
    font-weight: 500;
    color: white;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Make the result container even more transparent when showing status */
body.success #result {
    background-color: rgba(0, 0, 0, 0.05);
    box-shadow: 0 0 20px rgba(74, 255, 81, 0.5);
    border: 1px solid rgba(74, 255, 81, 0.3);
}

body.warning #result {
    background-color: rgba(0, 0, 0, 0.05);
    box-shadow: 0 0 20px rgba(255, 167, 38, 0.5);
    border: 1px solid rgba(255, 167, 38, 0.3);
}

body.error #result {
    background-color: rgba(0, 0, 0, 0.05);
    box-shadow: 0 0 20px rgba(255, 77, 77, 0.5);
    border: 1px solid rgba(255, 77, 77, 0.3);
}

#name-display {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 8px;
    text-align: center;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* Make important status messages stand out */
.result .status-line {
    font-size: 26px;
    font-weight: 700;
    margin: 5px 0 10px 0;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* Highlight specific information */
.ticket-id, .price, .note, .payment {
    font-weight: 600;
    margin: 3px 0;
}

.note {
    font-size: 24px;
    margin: 8px 0;
    padding: 5px;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
}

.price {
    font-size: 24px;
    font-weight: 700;
}

/* Reduce spacing between items */
#result div {
    margin: 3px 0;
}

/* Hide less important information on smaller screens */
@media (max-width: 768px) {
    .secondary-info {
        display: none;
    }
    
    #result {
        font-size: 24px;
        padding: 15px;
        margin-top: 12px;
        line-height: 1.5;
    }
    
    #name-display {
        font-size: 30px;
    }
    
    .result .status-line {
        font-size: 28px;
        margin: 5px 0 12px 0;
    }
    
    .note {
        font-size: 26px;
    }
}

/* Status colors for different ticket states */
.result.success {
    color: #4AFF51;
    font-weight: 600;
    text-shadow: 0 0 10px rgba(74, 255, 81, 0.3);
}

.result.warning {
    color: #FFA726;
    font-weight: 600;
    text-shadow: 0 0 10px rgba(255, 167, 38, 0.3);
}

.result.error {
    color: #FF4D4D;
    font-weight: 600;
    text-shadow: 0 0 10px rgba(255, 77, 77, 0.3);
}

/* Background animations for different states - make them more visible */
@keyframes success-background {
    0% { background-color: rgba(0, 102, 0, 0.9); }
    50% { background-color: rgba(0, 204, 0, 0.9); }
    100% { background-color: var(--background-color); }
}

@keyframes warning-background {
    0% { background-color: rgba(102, 60, 0, 0.9); }
    50% { background-color: rgba(204, 122, 0, 0.9); }
    100% { background-color: var(--background-color); }
}

@keyframes error-background {
    0% { background-color: rgba(102, 0, 0, 0.9); }
    50% { background-color: rgba(204, 0, 0, 0.9); }
    100% { background-color: var(--background-color); }
}

body.success {
    animation: success-background 3s ease;
    background-color: rgba(0, 204, 0, 0.3);
}

body.warning {
    animation: warning-background 3s ease;
    background-color: rgba(204, 122, 0, 0.3);
}

body.error {
    animation: error-background 3s ease;
    background-color: rgba(204, 0, 0, 0.3);
}

.status-indicator {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 10px;
    z-index: 1000;
    transition: all 0.3s ease;
}

body.success .status-indicator {
    background-color: #4AFF51;
    box-shadow: 0 0 15px rgba(74, 255, 81, 0.5);
}

body.warning .status-indicator {
    background-color: #FFA726;
    box-shadow: 0 0 15px rgba(255, 167, 38, 0.5);
}

body.error .status-indicator {
    background-color: #FF4D4D;
    box-shadow: 0 0 15px rgba(255, 77, 77, 0.5);
}

#controls {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
    background-color: var(--background-color);
    z-index: 1000;
}

.control-button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: var(--border-radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    font-family: 'Rajdhani', sans-serif;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    position: relative;
    overflow: hidden;
}

.control-button:hover {
    background-color: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 6px 8px rgba(0, 0, 0, 0.15);
}

.control-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.control-button.loading {
    pointer-events: none;
    position: relative;
    color: transparent;
}

.control-button.loading::after {
    content: "";
    position: absolute;
    width: 20px;
    height: 20px;
    top: 50%;
    left: 50%;
    margin-left: -10px;
    margin-top: -10px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
}

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

.control-button.ready {
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); box-shadow: 0 8px 15px rgba(61, 90, 254, 0.3); }
    100% { transform: scale(1); }
}

.control-button:disabled {
    background-color: #424242;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    opacity: 0.7;
}

/* Success animation */
@keyframes success-pulse {
    0% { transform: scale(1); opacity: 0.8; }
    50% { transform: scale(1.05); opacity: 1; }
    100% { transform: scale(1); opacity: 0.8; }
}

.success-animation {
    animation: success-pulse 0.5s ease-in-out;
    color: var(--success-color);
    text-shadow: 0 0 15px var(--success-color);
}

/* Media queries for responsive design */
@media (max-height: 700px) {
    #scanner-container {
        height: 50vh;
    }
}

@media (max-width: 600px) {
    .control-button {
        padding: 12px 24px;
        font-size: 14px;
    }
    
    #name-display {
        font-size: 20px;
    }
    
    :root {
        --border-radius: 12px;
        --border-radius-sm: 6px;
    }
}

@media (max-width: 768px) {
    #result {
        font-size: 20px;
        padding: 15px;
        margin-top: 15px;
    }
    
    #name-display {
        font-size: 26px;
    }
    
    .result .status-line {
        font-size: 22px;
    }
}

#focus-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 200px;
    height: 200px;
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 20px;
    box-shadow: 0 0 0 4000px rgba(0, 0, 0, 0.3);
    pointer-events: none;
    z-index: 10;
    transition: all 0.3s ease;
}

#scanner-container.scanning #focus-indicator {
    animation: pulse 2s infinite;
}

#focus-indicator.success-scan {
    border-color: var(--success-color);
    box-shadow: 0 0 20px var(--success-color), 0 0 0 4000px rgba(0, 0, 0, 0.5);
    animation: success-pulse 0.5s ease !important;
}

@keyframes pulse {
    0% {
        opacity: 0.5;
        transform: translate(-50%, -50%) scale(0.95);
    }
    50% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    100% {
        opacity: 0.5;
        transform: translate(-50%, -50%) scale(0.95);
    }
}

@keyframes success-pulse {
    0% {
        transform: translate(-50%, -50%) scale(1);
    }
    50% {
        transform: translate(-50%, -50%) scale(1.1);
    }
    100% {
        transform: translate(-50%, -50%) scale(1);
    }
}

/* Optimize video rendering */
video {
    object-fit: cover;
    transform: translateZ(0); /* Hardware acceleration */
    backface-visibility: hidden;
    perspective: 1000;
    will-change: transform; /* Hint for browser optimization */
}

/* Improve button responsiveness */
button {
    touch-action: manipulation; /* Removes delay on mobile */
    -webkit-tap-highlight-color: transparent; /* Remove tap highlight on mobile */
}

/* Add scanning animation to the scanner container */
#scanner-container.scanning {
    box-shadow: 0 0 0 2px var(--primary-color);
}

/* Add a scanning line animation */
#scanner-container.scanning::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--primary-color);
    box-shadow: 0 0 8px 2px var(--primary-color);
    animation: scan-line 2s infinite linear;
    z-index: 5;
}

@keyframes scan-line {
    0% {
        top: 0;
    }
    50% {
        top: 100%;
    }
    100% {
        top: 0;
    }
}
