/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 40px;
    color: white;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
    margin-bottom: 0;
}

/* Main sections */
section {
    background: white;
    border-radius: 12px;
    padding: 30px;
    margin-bottom: 20px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

/* Upload section */
.upload-section {
    text-align: center;
}

.upload-area {
    border: 3px dashed #ddd;
    border-radius: 12px;
    padding: 40px 20px;
    transition: all 0.3s ease;
    cursor: pointer;
    margin-bottom: 20px;
}

.upload-area:hover,
.upload-area.dragover {
    border-color: #667eea;
    background-color: #f8f9ff;
    transform: translateY(-2px);
}

.upload-content {
    pointer-events: none;
}

.upload-icon {
    font-size: 4rem;
    margin-bottom: 20px;
}

.upload-area h3 {
    margin-bottom: 10px;
    color: #333;
}

.upload-area p {
    color: #666;
    margin-bottom: 20px;
}

.upload-btn {
    background: #667eea;
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    pointer-events: all;
}

.upload-btn:hover {
    background: #5a67d8;
    transform: translateY(-1px);
}

.upload-info {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 0.9rem;
    color: #666;
}

/* Camera section */
.camera-section {
    text-align: center;
}

.camera-controls {
    margin: 20px 0;
}

.camera-btn {
    background: #48bb78;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    margin: 0 5px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.camera-btn:hover {
    background: #38a169;
}

.camera-btn.secondary {
    background: #e53e3e;
}

.camera-btn.secondary:hover {
    background: #c53030;
}

#cameraContainer {
    margin-top: 20px;
    border-radius: 8px;
    overflow: hidden;
    display: inline-block;
}

#cameraVideo {
    max-width: 100%;
    max-height: 400px;
    border-radius: 8px;
}

/* Results section */
.results-section {
    background: #f7fafc;
    border-left: 4px solid #48bb78;
}

.otp-result {
    background: white;
    border-radius: 8px;
    padding: 20px;
    margin: 15px 0;
    border-left: 4px solid #667eea;
}

.otp-header {
    display: flex;
    justify-content: between;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 10px;
}

.otp-type {
    background: #667eea;
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: bold;
}

.otp-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 15px;
}

.detail-item {
    display: flex;
    flex-direction: column;
}

.detail-label {
    font-weight: bold;
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 4px;
}

.detail-value {
    font-family: 'Courier New', monospace;
    background: #f7fafc;
    padding: 8px 12px;
    border-radius: 4px;
    word-break: break-all;
    position: relative;
}

.copy-btn {
    background: #e2e8f0;
    border: none;
    padding: 2px 6px;
    border-radius: 3px;
    margin-left: 8px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.3s ease;
}

.copy-btn:hover {
    background: #cbd5e0;
}

.validation-info {
    margin-top: 15px;
    padding: 15px;
    border-radius: 6px;
}

.validation-success {
    background: #f0fff4;
    border: 1px solid #68d391;
}

.validation-error {
    background: #fed7d7;
    border: 1px solid #fc8181;
}

.validation-warning {
    background: #fefcbf;
    border: 1px solid #f6e05e;
}

/* Loading section */
.loading-section {
    text-align: center;
    background: #f7fafc;
}

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

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

/* Error section */
.error-section {
    background: #fed7d7;
    border-left: 4px solid #e53e3e;
}

.error-content {
    text-align: center;
}

.error-icon {
    font-size: 3rem;
    margin-bottom: 15px;
}

.error-section h3 {
    color: #c53030;
    margin-bottom: 10px;
}

.retry-btn {
    background: #e53e3e;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    margin-top: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.retry-btn:hover {
    background: #c53030;
}

/* API Info section */
.api-info {
    background: #edf2f7;
}

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

.api-card {
    background: white;
    padding: 20px;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.api-card h4 {
    color: #667eea;
    margin-bottom: 8px;
    font-family: 'Courier New', monospace;
}

.api-card p {
    margin-bottom: 10px;
    color: #666;
}

.api-card code {
    background: #f7fafc;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.85rem;
    color: #e53e3e;
}

.api-card a {
    color: #667eea;
    text-decoration: none;
    font-weight: bold;
}

.api-card a:hover {
    text-decoration: underline;
}

/* Footer */
footer {
    text-align: center;
    padding: 30px 0;
    color: white;
    opacity: 0.9;
}

.footer-links {
    margin-top: 10px;
}

.footer-links a {
    color: white;
    text-decoration: none;
    opacity: 0.8;
    transition: opacity 0.3s ease;
}

.footer-links a:hover {
    opacity: 1;
    text-decoration: underline;
}

/* Responsive design */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    section {
        padding: 20px;
    }
    
    .upload-area {
        padding: 30px 15px;
    }
    
    .upload-icon {
        font-size: 3rem;
    }
    
    .upload-info {
        flex-direction: column;
        text-align: center;
    }
    
    .otp-details {
        grid-template-columns: 1fr;
    }
    
    .api-grid {
        grid-template-columns: 1fr;
    }
}

/* Utility classes */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.mb-10 {
    margin-bottom: 10px;
}

.mb-20 {
    margin-bottom: 20px;
}

/* Animation for fade in */
.fade-in {
    animation: fadeIn 0.5s ease-in;
}

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

/* Authentication Overlay */
.auth-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(10px);
}

.auth-modal {
    background: white;
    border-radius: 16px;
    padding: 0;
    width: 100%;
    max-width: 400px;
    margin: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

.auth-tabs {
    display: flex;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
}

.auth-tab {
    flex: 1;
    padding: 15px 20px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-weight: 500;
    color: #6c757d;
    transition: all 0.3s ease;
}

.auth-tab.active {
    background: white;
    color: #667eea;
    border-bottom: 2px solid #667eea;
}

.auth-form {
    padding: 30px;
}

.auth-form h2 {
    text-align: center;
    margin-bottom: 30px;
    color: #333;
    font-weight: 600;
}

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

.form-group label {
    display: block;
    margin-bottom: 5px;
    color: #555;
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.3s ease;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-group.checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-group.checkbox input {
    width: auto;
    margin: 0;
}

.btn-primary {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.3);
}

.btn-secondary {
    padding: 8px 16px;
    background: #6c757d;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.btn-secondary:hover {
    background: #5a6268;
}

.auth-error {
    margin-top: 15px;
    padding: 10px;
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 6px;
    color: #721c24;
    font-size: 14px;
}

/* Header with authentication */
.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.header-left {
    text-align: left;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    color: white;
}

#userName {
    font-weight: 500;
}

/* My Codes Section */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.section-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

.search-input {
    padding: 8px 12px;
    border: 2px solid #e9ecef;
    border-radius: 6px;
    font-size: 14px;
    min-width: 200px;
}

.search-input:focus {
    outline: none;
    border-color: #667eea;
}

.codes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.code-card {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 20px;
    transition: all 0.3s ease;
}

.code-card:hover {
    border-color: #667eea;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
}

.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.code-service {
    font-weight: 600;
    color: #333;
}

.code-account {
    color: #6c757d;
    font-size: 14px;
}

.code-display {
    text-align: center;
    margin: 15px 0;
}

.code-value {
    font-family: 'Courier New', monospace;
    font-size: 2rem;
    font-weight: bold;
    color: #667eea;
    letter-spacing: 4px;
}

.code-timer {
    margin-top: 10px;
    font-size: 14px;
    color: #6c757d;
}

.timer-bar {
    width: 100%;
    height: 4px;
    background: #e9ecef;
    border-radius: 2px;
    overflow: hidden;
    margin-top: 5px;
}

.timer-progress {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    transition: width 1s linear;
}

.code-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.code-actions button {
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: background-color 0.2s ease;
}

.copy-code-btn {
    background: #667eea;
    color: white;
}

.copy-code-btn:hover {
    background: #5a6fd8;
}

.delete-code-btn {
    background: #dc3545;
    color: white;
}

.delete-code-btn:hover {
    background: #c82333;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #6c757d;
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 20px;
}

.empty-state h4 {
    margin-bottom: 10px;
    color: #495057;
}

.result-actions {
    margin-top: 20px;
    display: flex;
    gap: 10px;
    justify-content: center;
}

/* Responsive adjustments for auth */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        text-align: center;
    }
    
    .header-left {
        text-align: center;
    }
    
    .section-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .section-controls {
        justify-content: center;
    }
    
    .search-input {
        min-width: auto;
        width: 100%;
    }
    
    .codes-grid {
        grid-template-columns: 1fr;
    }
    
    .auth-modal {
        margin: 10px;
        max-width: calc(100% - 20px);
    }
}
