/*
    Copyright (C) 2025, Paul Hammant

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Affero General Public License as
    published by the Free Software Foundation, either version 3 of the
    License, or (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Affero General Public License for more details.

    You should have received a copy of the GNU Affero General Public License
    along with this program.  If not, see <https://www.gnu.org/licenses/>.
*/

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

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

.container {
    max-width: 900px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

header h1 {
    font-size: 2rem;
    margin-bottom: 10px;
}

header p {
    opacity: 0.9;
    font-size: 1rem;
}

main {
    padding: 30px;
}

.camera-section {
    margin-bottom: 30px;
}

.video-container {
    position: relative;
    width: 100%;
    max-width: 640px;
    margin: 0 auto 20px;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    /* Let the video define its aspect; avoid forced crop */
    aspect-ratio: auto;
}

#video {
    width: 100%;
    height: auto;
    display: block;
    object-fit: contain;
    object-position: center center;
}

#overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* Registration marks removed in full-frame capture UX */

.shutter-btn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: white;
    border: 4px solid #667eea;
    font-size: 48px;
    color: #667eea;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 10;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.shutter-btn:active {
    transform: translate(-50%, -50%) scale(0.95);
    background: #667eea;
    color: white;
}

.shutter-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#debugConsole {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    max-height: 150px;
    background: rgba(0, 0, 0, 0.85);
    color: #0f0;
    font-family: monospace;
    font-size: 10px;
    padding: 8px;
    overflow-y: auto;
    z-index: 100;
    border-radius: 4px;
    pointer-events: none;
    line-height: 1.3;
}

.controls {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

.btn-primary:hover:not(:disabled) {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-success {
    background: #48bb78;
    color: white;
}

.btn-success:hover:not(:disabled) {
    background: #38a169;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(72, 187, 120, 0.4);
}

.btn-secondary {
    background: #cbd5e0;
    color: #2d3748;
}

.btn-secondary:hover:not(:disabled) {
    background: #a0aec0;
}

.btn-small {
    padding: 8px 16px;
    font-size: 0.875rem;
}

.results-section {
    margin-top: 30px;
}

.status-indicator {
    text-align: center;
    padding: 20px;
    background: #f7fafc;
    border-radius: 12px;
    margin-bottom: 20px;
}

.status-icon {
    font-size: 3rem;
    margin-bottom: 10px;
}

.status-text {
    font-size: 1.1rem;
    color: #4a5568;
    font-weight: 500;
}

/* Capture info diagnostics - smaller and less prominent */
#captureInfo {
    padding: 10px;
    margin-bottom: 10px;
}

#captureInfo .status-text {
    font-size: 0.75rem;
    color: #718096;
    font-weight: 400;
    line-height: 1.4;
}

.progress-bar {
    position: relative;
    height: 50px;
    background: #edf2f7;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 20px;
}

.progress-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    animation: progress 2s ease-in-out infinite;
}

.progress-text {
    position: relative;
    z-index: 1;
    line-height: 50px;
    text-align: center;
    font-weight: 600;
    color: #2d3748;
}

@keyframes progress {
    0% { width: 0%; }
    50% { width: 70%; }
    100% { width: 100%; }
}

.result-card {
    background: #f7fafc;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    border-left: 4px solid #667eea;
}

.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    border-bottom: 2px solid #e2e8f0;
}

.tab-btn {
    padding: 10px 20px;
    border: none;
    background: transparent;
    color: #4a5568;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s ease;
}

.tab-btn:hover {
    color: #667eea;
}

.tab-btn.active {
    color: #667eea;
    border-bottom-color: #667eea;
}

.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
}

.result-card h3 {
    margin-bottom: 15px;
    color: #2d3748;
    font-size: 1.1rem;
}

.result-card pre {
    background: white;
    padding: 15px;
    border-radius: 8px;
    overflow-x: auto;
    font-size: 0.9rem;
    line-height: 1.6;
    border: 1px solid #e2e8f0;
}

.hash-value {
    background: white;
    padding: 15px;
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    word-break: break-all;
    margin-bottom: 10px;
    border: 1px solid #e2e8f0;
    font-size: 0.85rem;
    user-select: text;
    -webkit-user-select: text;
    cursor: text;
}

.verification-status {
    padding: 15px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 1.1rem;
    margin-bottom: 10px;
}

.verification-status.verified {
    background: #c6f6d5;
    color: #22543d;
    border: 2px solid #48bb78;
}

.verification-status.not-found {
    background: #fed7d7;
    color: #742a2a;
    border: 2px solid #f56565;
}

.verification-status.denied {
    background: #feebc8;
    color: #7c2d12;
    border: 2px solid #ed8936;
}

.verification-status.revoked {
    background: #e9d8fd;
    color: #44337a;
    border: 2px solid #9f7aea;
}

.verification-url {
    font-size: 0.85rem;
    color: #718096;
    word-break: break-all;
    padding: 10px;
    background: white;
    border-radius: 8px;
}

footer {
    background: #f7fafc;
    padding: 20px 30px;
    border-top: 1px solid #e2e8f0;
}

details {
    cursor: pointer;
}

summary {
    font-weight: 600;
    color: #4a5568;
    padding: 10px;
    background: white;
    border-radius: 8px;
}

details[open] summary {
    margin-bottom: 15px;
}

details ol {
    padding-left: 30px;
    line-height: 1.8;
    color: #4a5568;
}

@media (max-width: 768px) {
    body {
        padding: 0;
    }

    .container {
        border-radius: 0;
    }

    header {
        padding: 20px;
    }

    header h1 {
        font-size: 1.5rem;
    }

    main {
        padding: 20px;
    }

    .controls {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }
}
