/**
 * Ticket Scanner Styles
 * 
 * @package Divi-child
 * @subpackage Contact Manager
 * @since 1.0.0
 */

/* Scanner Container */
.ticket-scanner-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 0;
    background: #ffffff;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.1);
}

/* Status Bar at Top */
.scanner-status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    font-size: 14px;
}

.status-left {
    flex: 1;
}

.status-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    position: relative;
}

.status-dot.online {
    background: #28a745;
    box-shadow: 0 0 0 2px rgba(40, 167, 69, 0.2);
}

.status-dot.offline {
    background: #dc3545;
    box-shadow: 0 0 0 2px rgba(220, 53, 69, 0.2);
}

.status-text {
    font-size: 12px;
    font-weight: 500;
    color: #6c757d;
}

/* Scanner Header */
.scanner-header {
    text-align: center;
    padding: 32px 20px 24px 20px;
    margin-bottom: 0;
}

.scanner-header h2 {
    margin: 0 0 12px 0;
    font-size: 32px;
    font-weight: 700;
    color: #2c3e50;
    letter-spacing: -0.5px;
}

.scanner-header p {
    margin: 0;
    color: #6c757d;
    font-size: 16px;
    line-height: 1.6;
    font-weight: 400;
}

/* Troubleshooting Button */
.troubleshooting-button {
    margin-top: auto;
    padding: 16px;
    text-align: center;
}

.modal-toggle {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 12px 20px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #6c757d;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.modal-toggle:hover {
    background: #e9ecef;
    border-color: #dee2e6;
}

.toggle-icon {
    font-size: 16px;
}

.toggle-text {
    font-weight: 500;
}

/* Modal Styles */
body.modal-open {
    overflow: hidden;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
}

.modal.active {
    display: block;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
}

.modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    width: 90vw;
    max-width: 90vw;
    max-height: 90vh;
    overflow: hidden;
    animation: modalSlideIn 0.3s ease-out;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid #e9ecef;
    background: #f8f9fa;
}

.modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #212529;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #6c757d;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.modal-close:hover {
    background: #e9ecef;
    color: #495057;
}

.modal-body {
    padding: 24px;
    max-height: 60vh;
    overflow-y: auto;
}

/* Scanner Controls */
.scanner-controls {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

/* Troubleshooting Info */
.troubleshooting-info {
    border-top: 1px solid #e9ecef;
    padding-top: 20px;
}

.troubleshooting-info h4 {
    margin: 0 0 12px 0;
    font-size: 16px;
    font-weight: 600;
    color: #212529;
}

.troubleshooting-info ul {
    margin: 0;
    padding-left: 20px;
    list-style-type: disc;
}

.troubleshooting-info li {
    margin-bottom: 8px;
    font-size: 14px;
    line-height: 1.5;
    color: #495057;
}

.troubleshooting-info strong {
    color: #212529;
}

/* Hide start button since we auto-start */
#start-scan {
    display: none !important;
}

.scanner-btn {
    padding: 14px 28px;
    border: none;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 120px;
    text-align: center;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.scanner-btn.primary {
    background: #007bff;
    color: white;
}

.scanner-btn.primary:hover {
    background: #0056b3;
    transform: translateY(-1px);
}

.scanner-btn.secondary {
    background: #6c757d;
    color: white;
}

.scanner-btn.secondary:hover {
    background: #545b62;
    transform: translateY(-1px);
}

.scanner-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

/* Video Container */
.scanner-video-container {
    position: relative;
    width: 100%;
    max-width: min(400px, 85vw);
    height: 0;
    padding-bottom: 100%; /* Creates a perfect square */
    margin: 0 auto 24px auto;
    background: #f8f9fa;
    overflow: hidden;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

#scanner-video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: #000;
}

#scanner-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    pointer-events: none;
    z-index: 1;
}

/* Placeholder */
.scanner-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 10px;
}

.placeholder-content {
    color: #7f8c8d;
}

.scanner-icon {
    font-size: 48px;
    margin-bottom: 15px;
    display: block;
}

.placeholder-content p {
    margin: 0;
    font-size: 18px;
    font-weight: 500;
}

/* Scan Results */
.scanner-results {
    margin: 0 16px 16px 16px;
}

.scan-result {
    padding: 20px 16px;
    text-align: center;
    animation: slideIn 0.3s ease-out;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.scan-result.success {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}

.scan-result.error {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

.scan-result.warning {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    color: #856404;
}

.result-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.result-icon {
    font-size: 32px;
}

.result-message {
    font-size: 20px;
    font-weight: 600;
    margin: 0;
}

.result-details {
    font-size: 14px;
    line-height: 1.4;
}

.result-details p {
    margin: 5px 0;
}

/* Scanner Status */
.scanner-status {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    margin-top: auto;
}

.status-message {
    font-size: 14px;
    color: #6c757d;
    font-weight: 500;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #6c757d;
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.status-indicator.online {
    background: #28a745;
}

.status-indicator.offline {
    background: #dc3545;
}

.status-text {
    font-weight: 500;
}

/* Animations */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translate(-50%, -60%);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

@keyframes pulse {
    0% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
    100% {
        opacity: 1;
    }
}

/* Scanning State */
.scanning .scanner-video-container {
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .ticket-scanner-container {
        margin: 0;
        padding: 0;
        min-height: 100vh;
    }
    
    .scanner-header h2 {
        font-size: 20px;
        margin-bottom: 5px;
    }
    
    .scanner-header p {
        font-size: 14px;
    }
    
    .scanner-controls {
        gap: 8px;
    }
    
    .modal-toggle {
        padding: 10px 16px;
        font-size: 13px;
    }
    
    .modal-content {
        width: 95vw;
        max-width: 95vw;
        max-height: 85vh;
    }
    
    .modal-header {
        padding: 16px 20px;
    }
    
    .modal-body {
        padding: 20px;
    }
    
    .scanner-btn {
        padding: 12px 20px;
        font-size: 14px;
        min-width: 100px;
    }
    
    .scanner-video-container {
        max-width: min(300px, 85vw);
        margin-bottom: 10px;
        padding-bottom: 100%; /* Maintain square aspect ratio */
    }
    
    .scanner-placeholder {
        padding: 8px;
    }
    
    .scanner-icon {
        font-size: 32px;
    }
    
    .placeholder-content p {
        font-size: 14px;
    }
    
    .result-icon {
        font-size: 24px;
    }
    
    .result-message {
        font-size: 16px;
    }
    
    .result-details {
        font-size: 12px;
    }
    
    .scanner-status {
        flex-direction: column;
        gap: 5px;
        text-align: center;
        padding: 8px 10px;
    }
    
    .status-message {
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .ticket-scanner-container {
        margin: 0;
        padding: 3px;
    }
    
    .scanner-header h2 {
        font-size: 18px;
    }
    
    .scanner-controls {
        flex-direction: column;
        align-items: center;
        gap: 5px;
    }
    
    .scanner-btn {
        width: 100%;
        max-width: 180px;
        padding: 10px 16px;
    }
    
    .scanner-video-container {
        max-width: min(280px, 90vw);
        padding-bottom: 100%; /* Maintain square aspect ratio */
    }
    
    .scanner-placeholder {
        padding: 5px;
    }
    
    .scan-result {
        padding: 8px;
    }
}

/* Landscape Mode */
@media (orientation: landscape) and (max-height: 600px) {
    .ticket-scanner-container {
        padding: 10px;
    }
    
    .scanner-header {
        margin-bottom: 15px;
    }
    
    .scanner-controls {
        margin-bottom: 15px;
    }
    
    .scanner-video-container {
        max-width: 250px;
        margin-bottom: 15px;
        padding-bottom: 100%; /* Maintain square aspect ratio */
    }
    
    .scanner-results {
        margin-bottom: 15px;
    }
}

/* High DPI Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .scanner-btn {
        border-width: 0.5px;
    }
    
    .status-indicator {
        border: 0.5px solid rgba(0, 0, 0, 0.1);
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .ticket-scanner-container {
        background: #2d2d2d;
        color: #ffffff;
    }
    
    .scanner-header h2 {
        color: #ffffff;
    }
    
    .scanner-header p {
        color: #b0b0b0;
    }
    
    .scanner-status {
        background: #1a1a1a;
        border-color: #444;
    }
    
    .status-message {
        color: #b0b0b0;
    }
    
    .connection-status {
        color: #b0b0b0;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .scanner-btn,
    .scan-result,
    .status-indicator {
        animation: none;
        transition: none;
    }
    
    .scanner-btn:hover {
        transform: none;
    }
}

/* Focus States for Accessibility */
.scanner-btn:focus {
    outline: 2px solid #3498db;
    outline-offset: 2px;
}

/* Print Styles */
@media print {
    .ticket-scanner-container {
        box-shadow: none;
        border: 1px solid #ccc;
    }
    
    .scanner-controls,
    .scanner-video-container {
        display: none;
    }
}

/* Status Badges */
.status-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

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

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

.status-badge.status-invalid {
    background: #f8d7da;
    color: #721c24;
}

/* Stats Grid */
.ticket-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    text-align: center;
    border-left: 4px solid #3498db;
}

.stat-card h3 {
    margin: 0 0 10px 0;
    color: #7f8c8d;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-number {
    font-size: 32px;
    font-weight: 700;
    color: #2c3e50;
    margin: 0;
}

.stat-number.success {
    color: #27ae60;
}

.stat-number.warning {
    color: #f39c12;
}

.stat-number.error {
    color: #e74c3c;
}

/* Quick Actions */
.quick-actions {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin-bottom: 30px;
}

.quick-actions h2 {
    margin: 0 0 15px 0;
    color: #2c3e50;
    font-size: 18px;
}

.action-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.action-buttons .button {
    margin: 0;
}

/* Scanner Info */
.scanner-info {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.scanner-info h2 {
    margin: 0 0 10px 0;
    color: #2c3e50;
    font-size: 18px;
}

.scanner-info p {
    margin: 0 0 15px 0;
    color: #7f8c8d;
}

.scanner-url {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-top: 10px;
}

.scanner-url input {
    flex: 1;
    font-family: monospace;
    background: #f8f9fa;
    border: 1px solid #ddd;
    padding: 8px 12px;
    border-radius: 4px;
}

.scanner-url .button {
    margin: 0;
    white-space: nowrap;
} 