/* ============================================
   BRANDING VARIABLES - Change these to rebrand
   ============================================ */
:root {
    /* Primary Brand Colors */
    --brand-primary: #6366f1;
    --brand-primary-dark: #4f46e5;
    --brand-primary-light: #818cf8;
    --brand-accent: #8b5cf6;
    --brand-success: #10b981;
    --brand-danger: #ef4444;
    
    /* Background Colors */
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    
    /* Text Colors */
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-tertiary: #64748b;
    --text-light: #94a3b8;
    
    /* Border & Shadow */
    --border-color: #e2e8f0;
    --border-color-hover: #cbd5e1;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    
    /* Spacing & Sizing */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;
    
    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 200ms ease;
    --transition-slow: 300ms ease;
}

/* ============================================
   BASE RESET & TYPOGRAPHY
   ============================================ */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    overflow-x: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
    color: var(--text-primary);
    background: var(--bg-secondary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

/* ============================================
   BACKGROUND PATTERN
   ============================================ */
.bg-pattern {
    position: fixed;
    inset: 0;
    z-index: -1;
    background: linear-gradient(135deg, var(--bg-secondary) 0%, #e0e7ff 100%);
    opacity: 0.7;
}

.bg-pattern::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: 
        radial-gradient(circle at 25px 25px, var(--border-color) 2%, transparent 0%),
        radial-gradient(circle at 75px 75px, var(--border-color) 2%, transparent 0%);
    background-size: 100px 100px;
    opacity: 0.3;
}

/* ============================================
   NAVBAR
   ============================================ */
.navbar {
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    gap: 20px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 700;
    font-size: 20px;
    color: var(--text-primary);
}

.brand-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--brand-primary), var(--brand-accent));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: var(--shadow-md);
}

.brand-name {
    background: linear-gradient(135deg, var(--brand-primary), var(--brand-accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav-links {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-base);
    font-weight: 500;
    font-size: 14px;
}

.nav-link:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.nav-link.active {
    background: var(--brand-primary);
    color: white;
}

/* ============================================
   UPLOAD PAGE
   ============================================ */
.main-content {
    padding: 40px 20px;
    position: relative;
    z-index: 1;
}

.page-header {
    text-align: center;
    margin-bottom: 40px;
}

.header-icon {
    font-size: 48px;
    margin-bottom: 16px;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
}

.page-title {
    font-size: clamp(32px, 5vw, 48px);
    font-weight: 800;
    background: linear-gradient(135deg, var(--brand-primary), var(--brand-accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 12px;
    line-height: 1.2;
}

.page-subtitle {
    font-size: clamp(16px, 2vw, 18px);
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto;
}

.upload-card {
    background: var(--bg-primary);
    border-radius: var(--radius-xl);
    padding: 40px;
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border-color);
    max-width: 700px;
    margin: 0 auto;
}

.uploader {
    margin-bottom: 24px;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ============================================
   PREVIEW SECTION
   ============================================ */
.preview-section {
    margin: 24px 0;
}

.previews {
    list-style: none;
    display: grid;
    gap: 16px;
}

.preview-item {
    position: relative;
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 12px;
    overflow: hidden;
    transition: all var(--transition-base);
}

.preview-item:hover {
    border-color: var(--brand-primary);
    box-shadow: var(--shadow-md);
}

.preview-thumb {
    display: block;
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
}

.preview-actions {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    border: none;
    background: rgba(255, 255, 255, 0.95);
    color: var(--text-primary);
    backdrop-filter: blur(10px);
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition: all var(--transition-base);
}

.icon-btn:hover {
    background: white;
    transform: scale(1.05);
}

.icon-btn:active {
    transform: scale(0.95);
}

/* ============================================
   BUTTONS
   ============================================ */
.button-section {
    margin: 24px 0;
}

.button-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 24px;
    border-radius: var(--radius-md);
    border: 2px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    transition: all var(--transition-base);
    box-shadow: var(--shadow-sm);
    font-family: inherit;
}

.btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--brand-primary);
}

.btn:active:not(:disabled) {
    transform: translateY(0);
}

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

.btn.primary {
    background: linear-gradient(135deg, var(--brand-primary), var(--brand-primary-dark));
    border-color: var(--brand-primary);
    color: white;
}

.btn.primary:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--brand-primary-dark), var(--brand-primary));
    box-shadow: 0 8px 16px rgba(99, 102, 241, 0.3);
}

.btn-camera {
    background: linear-gradient(135deg, #f59e0b, #ea580c);
    border-color: #f59e0b;
    color: white;
}

.btn-camera:hover:not(:disabled) {
    background: linear-gradient(135deg, #ea580c, #dc2626);
    box-shadow: 0 8px 16px rgba(245, 158, 11, 0.3);
}

.btn-gallery {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
    border-color: #8b5cf6;
    color: white;
}

.btn-gallery:hover:not(:disabled) {
    background: linear-gradient(135deg, #7c3aed, #6d28d9);
    box-shadow: 0 8px 16px rgba(139, 92, 246, 0.3);
}

.btn-large {
    padding: 18px 32px;
    font-size: 17px;
}

.btn-large {
    padding: 20px 34px;
    font-size: 17px;
}

.btn-ghost {
    background: transparent;
    border-color: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover {
    background: var(--bg-tertiary);
    border-color: var(--border-color);
}

.btn-icon {
    font-size: 18px;
}

.btn-text {
    font-weight: 600;
}

/* ============================================
   STATUS & ACTIONS
   ============================================ */
.actions {
    display: grid;
    gap: 16px;
    margin: 24px 0;
    justify-items: center;
}

.status {
    min-height: 24px;
    font-size: 14px;
    color: var(--text-secondary);
    text-align: center;
}

/* ============================================
   THANK YOU PAGE
   ============================================ */
.thankyou-card {
    background: var(--bg-primary);
    border-radius: var(--radius-xl);
    padding: 60px 40px;
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border-color);
    max-width: 700px;
    margin: 0 auto;
    text-align: center;
}

.success-animation {
    margin-bottom: 32px;
}

.checkmark-circle {
    width: 120px;
    height: 120px;
    margin: 0 auto;
    background: linear-gradient(135deg, var(--brand-success), #059669);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 30px rgba(16, 185, 129, 0.3);
    animation: scaleIn 0.5s ease-out;
}

@keyframes scaleIn {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.checkmark {
    font-size: 60px;
    color: white;
    font-weight: bold;
    animation: checkmarkDraw 0.3s 0.3s ease-out forwards;
    opacity: 0;
}

@keyframes checkmarkDraw {
    to {
        opacity: 1;
    }
}

.thankyou-header {
    margin-bottom: 40px;
}

.thankyou-title {
    font-size: clamp(36px, 6vw, 56px);
    font-weight: 800;
    background: linear-gradient(135deg, var(--brand-primary), var(--brand-accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 16px;
}

.thankyou-message {
    font-size: clamp(16px, 2vw, 18px);
    color: var(--text-secondary);
    max-width: 500px;
    margin: 0 auto;
    line-height: 1.7;
}

/* ============================================
   MODAL (Crop)
   ============================================ */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: grid;
    place-items: center;
    padding: 20px;
}

.modal.hidden {
    display: none;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(8px);
}

.modal-content {
    position: relative;
    background: var(--bg-primary);
    width: 100%;
    max-width: 600px;
    border-radius: var(--radius-xl);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header,
.modal-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    gap: 16px;
    background: var(--bg-tertiary);
}

.modal-header {
    border-bottom: 1px solid var(--border-color);
}

.modal-footer {
    border-top: 1px solid var(--border-color);
}

.modal-title {
    font-weight: 700;
    font-size: 18px;
    color: var(--text-primary);
}

.hint {
    font-size: 13px;
    color: var(--text-tertiary);
    font-weight: 500;
}

.crop-stage {
    background: var(--bg-secondary);
    display: grid;
    place-items: center;
    padding: 24px;
    min-height: 300px;
}

#cropCanvas {
    width: 100%;
    max-width: 520px;
    touch-action: none;
    background: white;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    cursor: move;
}

/* ============================================
   ADMIN PAGE STYLES (kept for compatibility)
   ============================================ */
.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin: 16px 0;
}

.image-item {
    position: relative;
    cursor: pointer;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 2px solid var(--border-color);
    transition: all var(--transition-base);
}

.image-item:hover {
    border-color: var(--brand-primary);
    box-shadow: var(--shadow-md);
}

.image-thumb {
    width: 100%;
    height: 150px;
    object-fit: cover;
    display: block;
}

.image-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.75);
    color: white;
    padding: 8px;
    font-size: 12px;
    backdrop-filter: blur(5px);
}

.image-name {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
    font-weight: 500;
}

.image-time {
    display: block;
    font-size: 10px;
    opacity: 0.8;
}

.modal-image-container {
    display: flex;
    justify-content: center;
    margin-bottom: 16px;
}

.modal-image-wrapper {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    max-width: 100%;
    max-height: 100%;
    overflow: hidden;
}

.modal-image {
    max-width: 100%;
    max-height: 400px;
    object-fit: contain;
}

.modal-download-btn {
    position: absolute;
    bottom: 12px;
    left: 12px;
    z-index: 10;
}

.image-dimensions-overlay {
    position: absolute;
    bottom: 12px;
    right: 12px;
    background: rgba(0, 0, 0, 0.75);
    color: white;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    font-family: 'Courier New', monospace;
    z-index: 10;
    pointer-events: none;
}

.modal-info {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

.image-timestamp {
    font-size: 14px;
    color: var(--text-secondary);
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    align-items: center;
    min-height: 80px;
    padding: 0 16px;
}

.btn.danger {
    background: var(--brand-danger);
    border-color: var(--brand-danger);
    color: white;
}

.btn.danger:hover {
    background: #dc2626;
}

.empty,
.error {
    text-align: center;
    padding: 32px;
    color: var(--text-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
}

.small {
    font-size: 12px;
    color: var(--text-secondary);
}

h1 {
    margin: 16px 0 8px;
    font-size: 28px;
}

.subtitle {
    margin: 0 0 16px;
    color: var(--text-secondary);
}

header .btn {
    margin-top: 8px;
}

.hidden {
    display: none;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */
/* Mobile Navigation Toggle */
.nav-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    z-index: 1001;
}

.hamburger {
    display: block;
    width: 25px;
    height: 3px;
    background: var(--text-primary);
    margin: 5px 0;
    transition: 0.3s;
    border-radius: 3px;
}

.nav-toggle.active .hamburger:nth-child(1) {
    transform: rotate(-45deg) translate(-5px, 6px);
}

.nav-toggle.active .hamburger:nth-child(2) {
    opacity: 0;
}

.nav-toggle.active .hamburger:nth-child(3) {
    transform: rotate(45deg) translate(-5px, -6px);
}

@media (max-width: 768px) {
    .nav-toggle {
        display: block;
    }
    
    .nav-links {
        position: absolute;
        top: 100%;
        right: 16px;
        background: white;
        flex-direction: column;
        gap: 0;
        width: 200px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
        border-radius: 8px;
        overflow: hidden;
        opacity: 0;
        transform: translateY(-10px);
        visibility: hidden;
        transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
        pointer-events: none;
    }
    
    .nav-links.active {
        opacity: 1;
        transform: translateY(0);
        visibility: visible;
        pointer-events: all;
    }
    
    .nav-link {
        padding: 12px 16px;
        border-bottom: 1px solid #f3f4f6;
        font-size: 0.9rem;
    }
    
    .nav-link:last-child {
        border-bottom: none;
    }
    
    .navbar .container {
        position: relative;
    }
    
    .upload-card,
    .thankyou-card {
        padding: 30px 24px;
    }
    
    .button-row {
        flex-direction: column;
        width: 100%;
    }
    
    .btn {
        width: 100%;
        justify-content: center;
    }
    
    .modal-content .btn,
    .modal-actions .btn {
        width: auto;
    }
    
    .thankyou-features {
        grid-template-columns: 1fr;
    }
}

@media (min-width: 768px) {
    h1 {
        font-size: 32px;
    }
}

/* ============================================
   PROGRESS BAR (kept for compatibility)
   ============================================ */
.progress {
    width: 100%;
    height: 10px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.bar {
    height: 100%;
    background: linear-gradient(90deg, var(--brand-success), #059669);
    width: 0%;
    transition: width 0.2s ease;
}

/* ============================================
   UTILITY CLASSES
   ============================================ */
.meta {
    display: none;
}

.remove {
    background: none;
    border: none;
    color: var(--brand-danger);
    cursor: pointer;
    font-size: 12px;
}

.input-label {
    font-size: 12px;
    color: var(--text-secondary);
}

.text-input {
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    width: 100%;
}

/* Portrait mode adjustments */
@media screen and (max-width: 768px) and (orientation: portrait) {
    .modal-content {
        max-width: 95vw !important;
        width: 95vw;
        max-height: 85vh;
        padding: 16px;
        margin: auto;
    }
    
    .modal-image-container {
        margin-bottom: 12px;
    }
    
    .modal-image-wrapper {
        max-width: 100%;
        width: 100%;
        height: 350px;
        display: flex;
        justify-content: center;
        align-items: center;
        border-radius: 8px;
        background: #f5f5f5;
    }
    
    .modal-image {
        max-width: 100%;
        max-height: 100%;
        object-fit: contain;
        width: auto;
        height: auto;
    }
    
    .modal-info {
        padding: 8px 16px;
    }
    
    .modal-actions {
        flex-wrap: wrap;
        gap: 8px;
        min-height: auto;
        padding: 12px 16px;
    }
    
    .modal-actions .btn {
        flex: 1;
        min-width: 120px;
        padding: 12px 16px;
        font-size: 14px;
    }
}
