/* ==========================================
   CSS CUSTOM PROPERTIES (DESIGN TOKENS)
   ========================================== */

:root {
  /* Font Families */
  --font-header: 'Manrope', sans-serif;
  --font-body: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;

  /* Colors - Semantic naming based on purpose */
  --background: 30 20% 96%;
  --foreground: 0 0% 20%;

  --card-background: 0 0% 100%;
  --card-foreground: 0 0% 20%;

  --popover-background: 0 0% 100%;
  --popover-foreground: 0 0% 20%;

  --primary: 40 30% 55%;
  --primary-foreground: 0 0% 100%;

  --secondary: 30 25% 70%;
  --secondary-foreground: 0 0% 20%;

  --muted: 30 15% 92%;
  --muted-foreground: 0 0% 40%;

  --accent: 35 20% 88%;
  --accent-foreground: 0 0% 20%;

  --destructive: 0 84.2% 60.2%;
  --destructive-foreground: 0 0% 98%;

  --border: 30 10% 85%;
  --input-border: 30 10% 85%;
  --ring: 40 30% 55%;

  --success: 142 76% 36%;
  --success-foreground: 0 0% 100%;

  --warning: 38 92% 50%;
  --warning-foreground: 0 0% 100%;

  /* Border Radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);

  /* Spacing */
  --spacing-xs: 0.5rem;
  --spacing-sm: 0.75rem;
  --spacing-md: 1rem;
  --spacing-lg: 1.5rem;
  --spacing-xl: 2rem;
  --spacing-2xl: 3rem;

  /* Transitions */
  --transition-fast: 150ms;
  --transition-base: 200ms;
  --transition-slow: 300ms;
}

/* Optional: Dark mode support */
@media (prefers-color-scheme: dark) {
  :root {
    --background: 0 0% 12%;
    --foreground: 0 0% 95%;

    --card-background: 0 0% 15%;
    --card-foreground: 0 0% 95%;

    --popover-background: 0 0% 15%;
    --popover-foreground: 0 0% 95%;

    --primary: 40 25% 50%;
    --primary-foreground: 0 0% 100%;

    --secondary: 30 20% 60%;
    --secondary-foreground: 0 0% 10%;

    --muted: 0 0% 20%;
    --muted-foreground: 0 0% 65%;

    --accent: 30 15% 25%;
    --accent-foreground: 0 0% 95%;

    --destructive: 0 62.8% 30.6%;
    --destructive-foreground: 0 0% 98%;

    --border: 0 0% 25%;
    --input-border: 0 0% 25%;
    --ring: 40 25% 50%;

    --success: 142 76% 36%;
    --success-foreground: 0 0% 98%;

    --warning: 38 92% 50%;
    --warning-foreground: 0 0% 10%;
  }
}

/* ==========================================
   BASE STYLES
   ========================================== */

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

body {
    font-family: var(--font-body);
    background: linear-gradient(135deg, hsl(var(--primary)) 0%, hsl(var(--secondary)) 100%);
    color: hsl(var(--foreground));
    min-height: 100vh;
    padding: var(--spacing-lg);
    display: flex;
    justify-content: center;
    align-items: center;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ==========================================
   CONTAINER
   ========================================== */

.container {
    background: hsl(var(--card-background));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    max-width: 800px;
    width: 100%;
    padding: var(--spacing-2xl);
}

/* ==========================================
   TYPOGRAPHY
   ========================================== */

h1 {
    font-family: var(--font-header);
    color: hsl(var(--foreground));
    margin-bottom: var(--spacing-sm);
    font-size: 2rem;
    font-weight: 600;
    letter-spacing: -0.025em;
}

h3 {
    font-family: var(--font-header);
    color: hsl(var(--foreground));
    margin-bottom: var(--spacing-md);
    font-size: 1.125rem;
    font-weight: 600;
    letter-spacing: -0.015em;
}

.subtitle {
    color: hsl(var(--muted-foreground));
    margin-bottom: var(--spacing-xl);
    font-size: 0.875rem;
    line-height: 1.5;
}

/* ==========================================
   DROP ZONE
   ========================================== */

.drop-zone {
    border: 2px dashed hsl(var(--border));
    border-radius: var(--radius-lg);
    padding: var(--spacing-2xl) var(--spacing-lg);
    text-align: center;
    background: hsl(var(--muted));
    transition: all var(--transition-base) ease;
    cursor: pointer;
    margin-bottom: var(--spacing-lg);
}

.drop-zone:hover {
    border-color: hsl(var(--primary));
    background: hsl(var(--accent));
}

.drop-zone.dragover {
    border-color: hsl(var(--primary));
    background: hsl(var(--accent));
    transform: scale(1.01);
    box-shadow: var(--shadow-md);
}

.drop-zone-icon {
    font-size: 3rem;
    margin-bottom: var(--spacing-md);
    opacity: 0.8;
}

.drop-zone-text {
    color: hsl(var(--foreground));
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: var(--spacing-xs);
}

.drop-zone-hint {
    color: hsl(var(--muted-foreground));
    font-size: 0.875rem;
}

#fileInput {
    display: none;
}

/* ==========================================
   OPTIONS
   ========================================== */

.options {
    background: hsl(var(--muted));
    padding: var(--spacing-lg);
    border-radius: var(--radius-md);
    border: 1px solid hsl(var(--border));
    margin-bottom: var(--spacing-lg);
}

.option-group {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.checkbox-container {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.checkbox-container input[type="checkbox"] {
    width: 1.25rem;
    height: 1.25rem;
    cursor: pointer;
    accent-color: hsl(var(--primary));
    border-radius: var(--radius-sm);
}

.checkbox-container label {
    color: hsl(var(--foreground));
    cursor: pointer;
    user-select: none;
    font-size: 0.9375rem;
}

/* ==========================================
   BUTTONS
   ========================================== */

.process-btn {
    background: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
    border: none;
    padding: var(--spacing-md) var(--spacing-xl);
    font-size: 1rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    cursor: pointer;
    width: 100%;
    transition: all var(--transition-base);
    margin-bottom: var(--spacing-lg);
    box-shadow: var(--shadow-sm);
}

.process-btn:hover:not(:disabled) {
    background: hsl(var(--primary) / 0.9);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.process-btn:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}

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

.download-btn {
    background: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
    border: none;
    padding: var(--spacing-sm) var(--spacing-lg);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 500;
    font-size: 0.9375rem;
    transition: all var(--transition-base);
    box-shadow: var(--shadow-sm);
}

.download-btn:hover {
    background: hsl(var(--primary) / 0.9);
    box-shadow: var(--shadow-md);
}

/* ==========================================
   PROGRESS
   ========================================== */

.progress-container {
    display: none;
    margin-bottom: var(--spacing-lg);
}

.progress-bar {
    background: hsl(var(--muted));
    height: 2.5rem;
    border-radius: var(--radius-md);
    overflow: hidden;
    position: relative;
    border: 1px solid hsl(var(--border));
}

.progress-fill {
    background: linear-gradient(90deg, hsl(var(--primary)) 0%, hsl(var(--secondary)) 100%);
    height: 100%;
    width: 0%;
    transition: width var(--transition-slow) ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: hsl(var(--primary-foreground));
    font-weight: 600;
    font-size: 0.875rem;
}

.status-message {
    margin-top: var(--spacing-sm);
    color: hsl(var(--primary));
    font-weight: 500;
    text-align: center;
    font-size: 0.9375rem;
}

/* ==========================================
   RESULTS
   ========================================== */

.results {
    display: none;
    background: hsl(var(--muted));
    padding: var(--spacing-lg);
    border-radius: var(--radius-md);
    margin-top: var(--spacing-lg);
    border: 1px solid hsl(var(--border));
}

.result-item {
    background: hsl(var(--card-background));
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    margin-bottom: var(--spacing-sm);
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-sm);
    border: 1px solid hsl(var(--border));
}

.result-item:last-child {
    margin-bottom: 0;
}

.result-info {
    flex: 1;
}

.result-title {
    font-weight: 600;
    color: hsl(var(--foreground));
    margin-bottom: var(--spacing-xs);
    font-size: 0.9375rem;
}

.result-meta {
    color: hsl(var(--muted-foreground));
    font-size: 0.875rem;
}

/* ==========================================
   IMAGE PREVIEW
   ========================================== */

.image-preview {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-sm);
}

.image-preview img {
    max-width: 150px;
    max-height: 150px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    border: 1px solid hsl(var(--border));
    transition: all var(--transition-base);
}

.image-preview img:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-lg);
}

/* ==========================================
   ERROR MESSAGE
   ========================================== */

.error-message {
    background: hsl(var(--destructive) / 0.1);
    color: hsl(var(--destructive));
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    margin-top: var(--spacing-lg);
    display: none;
    border: 1px solid hsl(var(--destructive) / 0.3);
    font-size: 0.9375rem;
}

/* ==========================================
   RESPONSIVE DESIGN
   ========================================== */

@media (max-width: 600px) {
    body {
        padding: var(--spacing-sm);
    }

    .container {
        padding: var(--spacing-lg);
    }

    h1 {
        font-size: 1.5rem;
    }

    .drop-zone {
        padding: var(--spacing-xl) var(--spacing-md);
    }

    .result-item {
        flex-direction: column;
        align-items: stretch;
        gap: var(--spacing-sm);
    }

    .download-btn {
        width: 100%;
    }
}
