/* ============================================
   MODERN RESPONSIVE DESIGN
   ============================================ */

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

/* Header */
header {
    text-align: center;
    color: white;
    margin-bottom: 30px;
    animation: fadeInDown 0.6s ease-out;
}

header h1 {
    font-size: clamp(1.8rem, 5vw, 3rem);
    font-weight: 700;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.subtitle {
    font-size: clamp(0.9rem, 2vw, 1.1rem);
    opacity: 0.95;
    font-weight: 300;
}

/* Main Container */
.main-container {
    max-width: 1200px;
    margin: 0 auto;
}

/* Card Styles */
.card {
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    padding: clamp(20px, 4vw, 30px);
    margin-bottom: 25px;
    animation: fadeInUp 0.6s ease-out;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
    /* transform: translateY(-2px); */
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.2);
}

.controls-card {
    animation: none;
    transition: none;
}

.controls-card:hover {
    transform: none;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
}

.card h2 {
    color: #667eea;
    font-size: clamp(1.3rem, 3vw, 1.8rem);
    margin-bottom: 20px;
    font-weight: 600;
}

.card h3 {
    color: #555;
    font-size: clamp(1rem, 2.5vw, 1.2rem);
    margin-bottom: 12px;
    font-weight: 500;
}

/* License Card */
.info-text {
    color: #666;
    margin-bottom: 15px;
    font-size: 0.95rem;
}

.info-text a {
    color: #667eea;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s ease;
}

.info-text a:hover {
    color: #764ba2;
    text-decoration: underline;
}

/* Input Group */
.input-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.input-group input {
    flex: 1;
    min-width: 200px;
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 0.95rem;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.input-group input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Buttons */
button {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: #f8f9fa;
    color: #667eea;
    border: 2px solid #667eea;
}

.btn-secondary:hover {
    background: #667eea;
    color: white;
}

.btn-capture {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(245, 87, 108, 0.4);
    display: none;
}

.btn-capture:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(245, 87, 108, 0.5);
}

/* Controls */
.controls-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.control-label {
    font-weight: 600;
    color: #555;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.select-modern {
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 0.95rem;
    background: white;
    cursor: pointer;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.select-modern:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Mode Selector */
.mode-selector {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.radio-card {
    flex: 1;
    min-width: 100px;
    position: relative;
    cursor: pointer;
    display: flex;
}

.radio-card input[type="radio"] {
    position: absolute;
    opacity: 0;
}

.radio-label {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 12px 16px;
    background: #f8f9fa;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    text-align: center;
    font-weight: 500;
    transition: all 0.3s ease;
    width: 100%;
    flex: 1;
    line-height: 1.5;
}

.radio-card input[type="radio"]:checked+.radio-label {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: #667eea;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.radio-card:hover .radio-label {
    border-color: #667eea;
    transform: translateY(-2px);
}

/* Upload Area */
.view-container {
    position: relative;
}

.upload-area {
    margin-bottom: 20px;
}

.image-container {
    display: none;
    cursor: pointer;
}

.view-container.show-image .upload-area {
    display: none;
}

.view-container.show-image .image-container {
    display: block;
}

.file-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    border: 3px dashed #d0d0d0;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #fafafa;
}

.file-label:hover {
    border-color: #667eea;
    background: #f0f4ff;
}

.upload-area.drag-over .file-label {
    border-color: #667eea;
    background: linear-gradient(135deg, #f0f4ff 0%, #e8f0ff 100%);
    transform: scale(1.02);
    box-shadow: 0 8px 30px rgba(102, 126, 234, 0.3);
    animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        border-color: #667eea;
    }

    50% {
        border-color: #764ba2;
    }
}

.upload-icon {
    font-size: 3rem;
    margin-bottom: 10px;
}

.file-label span {
    color: #666;
    font-size: 0.95rem;
    font-weight: 500;
}

#pick_file {
    display: none;
}

.imageview {
    width: 100%;
    max-width: 100%;
    aspect-ratio: 1 / 1;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    position: relative;
    overflow: hidden;
}

.imageview img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: auto;
}

/* Camera Controls */
.camera-controls {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 20px;
}

.video-wrapper {
    margin: 20px 0;
}

#videoview {
    position: relative;
    width: 100%;
    height: 50vh;
    min-height: 300px;
    border-radius: 12px;
    overflow: hidden;
    background: #000;
}

#camera_view {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Result Container */
.result-container {
    margin-top: 20px;
}

textarea {
    width: 100%;
    min-height: 120px;
    padding: 16px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    resize: vertical;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Loading Indicator */
.loading-indicator {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 6px solid rgba(255, 255, 255, 0.3);
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    animation: fadeIn 0.3s ease-out;
    overflow-y: auto;
    padding: 20px;
}

.modal-content {
    background: white;
    margin: auto;
    max-width: 900px;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.3s ease-out;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    border-bottom: 2px solid #f0f0f0;
}

.modal-header h2 {
    margin: 0;
    color: #667eea;
}

.close-btn {
    background: none;
    border: none;
    font-size: 2rem;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.close-btn:hover {
    background: #f0f0f0;
    color: #333;
}

.modal-body {
    padding: 30px;
}

.editor-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.editor-view {
    display: grid;
    gap: 20px;
}

/* Visibility Controls */
#camera_container {
    display: none;
}

#rectify_view {
    display: none;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .card {
        padding: 20px;
    }

    .controls-grid {
        grid-template-columns: 1fr;
    }

    .mode-selector {
        flex-direction: column;
    }

    .input-group {
        flex-direction: column;
    }

    .input-group input {
        width: 100%;
    }

    #videoview {
        height: 40vh;
        min-height: 250px;
    }

    .modal-content {
        margin: 0;
        max-width: 100%;
        border-radius: 12px;
    }

    .modal-header,
    .modal-body {
        padding: 15px;
    }

    .editor-controls {
        flex-direction: column;
    }

    .editor-controls button {
        width: 100%;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 1.5rem;
    }

    .subtitle {
        font-size: 0.85rem;
    }

    .card h2 {
        font-size: 1.2rem;
    }

    button {
        padding: 10px 16px;
        font-size: 0.85rem;
    }

    .file-label {
        padding: 30px 20px;
    }

    .upload-icon {
        font-size: 2rem;
    }
}
/* Demo footer: attribution, tutorial link, and trial CTA */
.demo-footer {
    max-width: 1200px;
    margin: 30px auto 0;
    text-align: center;
    color: #fff;
    font-size: 0.9rem;
    line-height: 1.8;
}

.demo-footer a {
    color: #fff;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.demo-footer a:hover {
    text-decoration: none;
}

.demo-footer .demo-footer-cta {
    display: inline-block;
    margin-left: 6px;
    padding: 8px 16px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.18);
    text-decoration: none;
}

.demo-footer .demo-footer-cta:hover {
    background: rgba(255, 255, 255, 0.32);
}
