/* ===========================
   CSS Variables & Design System
   =========================== */
:root {
    /* Color Palette - Orange, Blue, White Theme */
    --primary-gradient: linear-gradient(135deg, #ff6b35 0%, #ff8c42 100%);
    --secondary-gradient: linear-gradient(135deg, #1e88e5 0%, #42a5f5 100%);
    --success-gradient: linear-gradient(135deg, #ff8c42 0%, #ffa726 100%);
    --dark-gradient: linear-gradient(135deg, #0d1b2a 0%, #1b263b 100%);

    /* Solid Colors */
    --primary-color: #ff6b35;
    --primary-dark: #e85d2a;
    --secondary-color: #1e88e5;
    --accent-color: #42a5f5;

    /* Neutral Colors */
    --bg-primary: #0d1b2a;
    --bg-secondary: #1b263b;
    --bg-tertiary: #2d3e50;
    --bg-card: rgba(255, 255, 255, 0.05);
    --bg-card-hover: rgba(255, 255, 255, 0.08);

    /* Text Colors */
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.8);
    --text-tertiary: rgba(255, 255, 255, 0.6);

    /* Border & Shadow */
    --border-color: rgba(255, 255, 255, 0.1);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.3);
    --shadow-glow: 0 0 40px rgba(255, 107, 53, 0.3);

    /* Spacing */
    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 1.5rem;
    --spacing-lg: 2rem;
    --spacing-xl: 3rem;

    /* Border Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    /* Transitions */
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;

    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    --font-size-3xl: 2rem;
}

/* ===========================
   Global Styles
   =========================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Animated Background */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(circle at 20% 50%, rgba(255, 107, 53, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(30, 136, 229, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 40% 20%, rgba(66, 165, 245, 0.1) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
    animation: backgroundShift 20s ease infinite;
}

@keyframes backgroundShift {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.8;
    }
}

.app-container {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ===========================
   Header Styles
   =========================== */
.app-header {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    padding: var(--spacing-md) var(--spacing-lg);
    position: sticky;
    top: 0;
    z-index: 100;
    animation: slideDown 0.5s ease;
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: var(--primary-gradient);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    animation: pulse 2s ease infinite;
}

.logo-icon svg {
    width: 24px;
    height: 24px;
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }
}

.logo-section h1 {
    font-size: var(--font-size-xl);
    font-weight: 700;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-stats {
    display: flex;
    gap: var(--spacing-lg);
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.stat-value {
    font-size: var(--font-size-2xl);
    font-weight: 700;
    background: var(--success-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-label {
    font-size: var(--font-size-sm);
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ===========================
   Main Content
   =========================== */
.main-content {
    flex: 1;
    padding: var(--spacing-xl) var(--spacing-lg);
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* ===========================
   Upload Section
   =========================== */
.upload-section {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
    animation: fadeIn 0.6s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.upload-card {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: var(--spacing-xl);
    max-width: 600px;
    width: 100%;
    text-align: center;
    box-shadow: var(--shadow-lg);
    transition: all var(--transition-normal);
}

.upload-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-glow);
    border-color: rgba(255, 107, 53, 0.3);
}

.upload-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto var(--spacing-lg);
    background: var(--primary-gradient);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    animation: float 3s ease-in-out infinite;
}

.upload-icon svg {
    width: 40px;
    height: 40px;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

.upload-card h2 {
    font-size: var(--font-size-2xl);
    font-weight: 700;
    margin-bottom: var(--spacing-sm);
}

.upload-description {
    color: var(--text-secondary);
    font-size: var(--font-size-base);
    margin-bottom: var(--spacing-xl);
}

.action-buttons {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

/* ===========================
   Button Styles
   =========================== */
.btn {
    padding: 1rem 2rem;
    border: none;
    border-radius: var(--radius-md);
    font-size: var(--font-size-base);
    font-weight: 600;
    font-family: var(--font-family);
    cursor: pointer;
    transition: all var(--transition-normal);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    position: relative;
    overflow: hidden;
}

.btn svg {
    width: 20px;
    height: 20px;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:hover::before {
    width: 300px;
    height: 300px;
}

.btn-primary {
    background: var(--primary-gradient);
    color: white;
    box-shadow: 0 4px 16px rgba(255, 107, 53, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(255, 107, 53, 0.6);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-card-hover);
    border-color: rgba(255, 107, 53, 0.3);
    transform: translateY(-2px);
}

.btn-close {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.5rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-close svg {
    width: 20px;
    height: 20px;
    color: var(--text-primary);
}

.btn-close:hover {
    background: rgba(245, 87, 108, 0.2);
    border-color: var(--secondary-color);
}

.btn-new-scan {
    background: var(--success-gradient);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
    box-shadow: 0 4px 16px rgba(255, 140, 66, 0.4);
}

.btn-new-scan:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(255, 140, 66, 0.6);
}

/* ===========================
   Camera Section
   =========================== */
.camera-section {
    animation: fadeIn 0.5s ease;
}

.camera-container {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    max-width: 900px;
    margin: 0 auto;
}

.camera-header {
    padding: var(--spacing-md) var(--spacing-lg);
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.camera-header h3 {
    font-size: var(--font-size-lg);
    font-weight: 600;
}

.camera-viewport {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
    overflow: hidden;
}

#cameraVideo {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.camera-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.scan-frame {
    width: 80%;
    max-width: 500px;
    aspect-ratio: 1.6;
    border: 3px solid var(--accent-color);
    border-radius: var(--radius-md);
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
    animation: scanPulse 2s ease-in-out infinite;
}

@keyframes scanPulse {

    0%,
    100% {
        border-color: var(--accent-color);
        box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5), 0 0 20px rgba(0, 242, 254, 0.5);
    }

    50% {
        border-color: rgba(0, 242, 254, 0.6);
        box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5), 0 0 40px rgba(0, 242, 254, 0.8);
    }
}

.camera-controls {
    padding: var(--spacing-lg);
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: center;
}

.btn-capture {
    background: white;
    color: var(--bg-primary);
    padding: 1rem 3rem;
    border-radius: var(--radius-xl);
    font-size: var(--font-size-lg);
    font-weight: 700;
    box-shadow: 0 4px 24px rgba(255, 255, 255, 0.3);
    position: relative;
}

.btn-capture:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 32px rgba(255, 255, 255, 0.5);
}

.capture-ring {
    position: absolute;
    top: -4px;
    left: -4px;
    right: -4px;
    bottom: -4px;
    border: 2px solid var(--accent-color);
    border-radius: var(--radius-xl);
    animation: ringPulse 1.5s ease-in-out infinite;
}

@keyframes ringPulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.1);
        opacity: 0.5;
    }
}

/* ===========================
   Processing Section
   =========================== */
.processing-section {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
    animation: fadeIn 0.5s ease;
}

.processing-card {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: var(--spacing-xl);
    max-width: 500px;
    width: 100%;
    text-align: center;
    box-shadow: var(--shadow-lg);
}

.processing-animation {
    margin-bottom: var(--spacing-lg);
}

.spinner {
    width: 80px;
    height: 80px;
    margin: 0 auto;
    border: 4px solid rgba(255, 107, 53, 0.2);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.processing-card h3 {
    font-size: var(--font-size-xl);
    font-weight: 700;
    margin-bottom: var(--spacing-sm);
}

.processing-card p {
    color: var(--text-secondary);
    margin-bottom: var(--spacing-lg);
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 999px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--primary-gradient);
    border-radius: 999px;
    width: 0%;
    animation: progressAnimation 2s ease-in-out;
}

@keyframes progressAnimation {
    0% {
        width: 0%;
    }

    100% {
        width: 100%;
    }
}

/* ===========================
   Results Section
   =========================== */
.results-section {
    animation: fadeIn 0.6s ease;
}

.results-container {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: var(--spacing-xl);
    box-shadow: var(--shadow-lg);
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-xl);
    padding-bottom: var(--spacing-md);
    border-bottom: 1px solid var(--border-color);
}

.results-header h2 {
    font-size: var(--font-size-2xl);
    font-weight: 700;
}

.results-content {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: var(--spacing-xl);
}

.preview-section h3,
.data-section h3 {
    font-size: var(--font-size-lg);
    font-weight: 600;
    margin-bottom: var(--spacing-md);
    color: var(--text-secondary);
}

.image-preview {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    aspect-ratio: 1.6;
}

.image-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ===========================
   Form Styles
   =========================== */
.contact-form {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--spacing-md);
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-group label {
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.form-group label svg {
    width: 16px;
    height: 16px;
    color: var(--primary-color);
}

.form-group input,
.form-group textarea,
.form-group select {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    font-size: var(--font-size-base);
    font-family: var(--font-family);
    color: var(--text-primary);
    transition: all var(--transition-fast);
}

.form-group select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23ffffff' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    padding-right: 2.5rem;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

/* Navigation Menu */
.nav-menu {
    display: flex;
    gap: var(--spacing-sm);
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: var(--font-size-sm);
    font-weight: 500;
    transition: all var(--transition-fast);
}

.nav-link svg {
    width: 18px;
    height: 18px;
}

.nav-link:hover {
    background: var(--bg-card-hover);
    border-color: rgba(255, 107, 53, 0.3);
    color: var(--text-primary);
}

.nav-link.active {
    background: var(--primary-gradient);
    border-color: transparent;
    color: white;
}

.form-actions {
    grid-column: 1 / -1;
    display: flex;
    gap: var(--spacing-md);
    margin-top: var(--spacing-md);
}

.btn-save,
.btn-export {
    flex: 1;
    padding: 1rem;
    font-size: var(--font-size-base);
}

.btn-save {
    background: var(--primary-gradient);
    color: white;
    box-shadow: 0 4px 16px rgba(255, 107, 53, 0.4);
}

.btn-save:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(255, 107, 53, 0.6);
}

.btn-export {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-export:hover {
    background: var(--bg-card-hover);
    border-color: rgba(255, 107, 53, 0.3);
    transform: translateY(-2px);
}

/* ===========================
   Toast Notification
   =========================== */
.toast {
    position: fixed;
    bottom: var(--spacing-lg);
    right: var(--spacing-lg);
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--spacing-md) var(--spacing-lg);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
    from {
        transform: translateX(400px);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast.hidden {
    display: none;
}

.toast-icon {
    width: 24px;
    height: 24px;
    color: var(--accent-color);
}

.toast-icon svg {
    width: 100%;
    height: 100%;
}

.toast-message {
    font-size: var(--font-size-sm);
    color: var(--text-primary);
}

/* ===========================
   Utility Classes
   =========================== */
.hidden {
    display: none !important;
}

/* ===========================
   Responsive Design
   =========================== */
@media (max-width: 1024px) {
    .results-content {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    :root {
        --spacing-lg: 1.5rem;
        --spacing-xl: 2rem;
    }

    .app-header {
        padding: var(--spacing-sm) var(--spacing-md);
    }

    .header-content {
        flex-direction: column;
        gap: var(--spacing-sm);
    }

    .logo-section h1 {
        font-size: var(--font-size-lg);
    }

    .main-content {
        padding: var(--spacing-lg) var(--spacing-md);
    }

    .upload-card {
        padding: var(--spacing-lg);
    }

    .upload-icon {
        width: 60px;
        height: 60px;
    }

    .upload-icon svg {
        width: 30px;
        height: 30px;
    }

    .upload-card h2 {
        font-size: var(--font-size-xl);
    }

    .contact-form {
        grid-template-columns: 1fr;
    }

    .form-actions {
        flex-direction: column;
    }

    .results-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--spacing-md);
    }

    .toast {
        left: var(--spacing-md);
        right: var(--spacing-md);
        bottom: var(--spacing-md);
    }
}

@media (max-width: 480px) {
    .logo-icon {
        width: 32px;
        height: 32px;
    }

    .logo-icon svg {
        width: 18px;
        height: 18px;
    }

    .stat-value {
        font-size: var(--font-size-xl);
    }

    .btn {
        padding: 0.875rem 1.5rem;
        font-size: var(--font-size-sm);
    }

    .camera-viewport {
        aspect-ratio: 4 / 3;
    }
}