/* ============================================
   Apple.com Inspired Design System
   iPhone Price Scraper Application
   ============================================ */

/* ============================================
   CSS Variables - Apple Color Palette
   ============================================ */
:root {
    /* Primary Colors */
    --apple-white: #ffffff;
    --apple-black: #1d1d1f;
    --apple-gray-light: #f5f5f7;
    --apple-gray: #86868b;
    --apple-gray-dark: #424245;
    
    /* Accent Colors */
    --apple-blue: #0071e3;
    --apple-blue-hover: #0077ed;
    --apple-green: #30d158;
    --apple-orange: #ff9500;
    --apple-red: #ff3b30;
    
    /* Background Colors */
    --bg-primary: #ffffff;
    --bg-secondary: #f5f5f7;
    --bg-tertiary: #fbfbfd;
    --bg-elevated: rgba(255, 255, 255, 0.8);
    
    /* Text Colors */
    --text-primary: #1d1d1f;
    --text-secondary: #86868b;
    --text-tertiary: #6e6e73;
    
    /* Border & Shadow */
    --border-light: rgba(0, 0, 0, 0.08);
    --border-medium: rgba(0, 0, 0, 0.12);
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07), 0 2px 4px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 12px 24px rgba(0, 0, 0, 0.1), 0 6px 12px rgba(0, 0, 0, 0.08);
    --shadow-xl: 0 20px 40px rgba(0, 0, 0, 0.12), 0 10px 20px rgba(0, 0, 0, 0.1);
    
    /* Spacing */
    --spacing-xs: 8px;
    --spacing-sm: 12px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
    --spacing-2xl: 48px;
    --spacing-3xl: 64px;
    
    /* Border Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --radius-xl: 24px;
    --radius-pill: 980px;
    
    /* Transitions */
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================
   Reset & Base Styles
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
    background: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.47059;
    font-weight: 400;
    letter-spacing: -0.022em;
    min-height: 100vh;
}

/* ============================================
   Typography
   ============================================ */

/* Hero Headline */
.hero-headline {
    font-size: clamp(48px, 8vw, 80px);
    font-weight: 600;
    letter-spacing: -0.015em;
    line-height: 1.05;
    color: var(--text-primary);
}

/* Large Headline */
.large-headline {
    font-size: clamp(40px, 6vw, 56px);
    font-weight: 600;
    letter-spacing: -0.01em;
    line-height: 1.07143;
    color: var(--text-primary);
}

/* Headline */
.headline {
    font-size: clamp(32px, 4vw, 40px);
    font-weight: 600;
    letter-spacing: -0.005em;
    line-height: 1.1;
    color: var(--text-primary);
}

/* Subheadline */
.subheadline {
    font-size: clamp(24px, 3vw, 28px);
    font-weight: 600;
    letter-spacing: 0.007em;
    line-height: 1.14286;
    color: var(--text-primary);
}

/* Body Large */
.body-large {
    font-size: 21px;
    font-weight: 400;
    letter-spacing: 0.011em;
    line-height: 1.381;
    color: var(--text-secondary);
}

/* Body */
.body {
    font-size: 17px;
    font-weight: 400;
    letter-spacing: -0.022em;
    line-height: 1.47059;
    color: var(--text-secondary);
}

/* Caption */
.caption {
    font-size: 14px;
    font-weight: 400;
    letter-spacing: -0.016em;
    line-height: 1.42859;
    color: var(--text-tertiary);
}

/* ============================================
   Layout
   ============================================ */
.container {
    max-width: 980px;
    margin: 0 auto;
    padding: 0 22px;
}

@media (min-width: 1440px) {
    .container {
        max-width: 1280px;
    }
}

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

.section-sm {
    padding: var(--spacing-md) 0;
}

/* ============================================
   Buttons
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-xs);
    padding: 12px 24px;
    font-size: 17px;
    font-weight: 400;
    line-height: 1.17648;
    letter-spacing: -0.022em;
    border-radius: var(--radius-pill);
    border: none;
    cursor: pointer;
    transition: all var(--transition-base);
    text-decoration: none;
    white-space: nowrap;
}

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

/* Primary Button */
.btn-primary {
    background: var(--apple-blue);
    color: var(--apple-white);
}

.btn-primary:hover:not(:disabled) {
    background: var(--apple-blue-hover);
    transform: scale(1.02);
}

.btn-primary:active:not(:disabled) {
    transform: scale(0.98);
}

/* Secondary Button */
.btn-secondary {
    background: transparent;
    color: var(--apple-blue);
    border: 1px solid var(--apple-blue);
}

.btn-secondary:hover:not(:disabled) {
    background: rgba(0, 113, 227, 0.08);
}

/* Small Button */
.btn-small {
    padding: 8px 16px;
    font-size: 14px;
}

/* Link Button */
.btn-link {
    background: transparent;
    color: var(--apple-blue);
    padding: 0;
    border-radius: 0;
}

.btn-link:hover {
    text-decoration: underline;
    transform: none;
}

/* ============================================
   Cards
   ============================================ */
.card {
    background: var(--apple-white);
    border-radius: var(--radius-lg);
    padding: var(--spacing-md) var(--spacing-lg);
    box-shadow: var(--shadow-md);
    transition: all var(--transition-base);
    border: 1px solid var(--border-light);
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.card-header {
    margin-bottom: var(--spacing-md);
}

.card-title {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.009em;
    color: var(--text-primary);
    margin-bottom: 0;
}

.card-subtitle {
    font-size: 17px;
    color: var(--text-secondary);
}

.card-body {
    margin-bottom: var(--spacing-md);
}

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

/* ============================================
   Inputs & Forms
   ============================================ */
.input,
.select,
.textarea {
    width: 100%;
    padding: 12px 16px;
    font-size: 17px;
    font-family: inherit;
    background: var(--apple-gray-light);
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    color: var(--text-primary);
    transition: all var(--transition-fast);
}

.input:focus,
.select:focus,
.textarea:focus {
    outline: none;
    background: var(--apple-white);
    border-color: var(--apple-blue);
    box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.1);
}

.input::placeholder {
    color: var(--text-tertiary);
}

/* Date Inputs */
input[type="date"],
input[type="week"],
input[type="month"] {
    cursor: pointer;
}

input[type="date"]::-webkit-calendar-picker-indicator,
input[type="week"]::-webkit-calendar-picker-indicator,
input[type="month"]::-webkit-calendar-picker-indicator {
    cursor: pointer;
    opacity: 0.6;
    transition: opacity var(--transition-fast);
}

input[type="date"]:hover::-webkit-calendar-picker-indicator,
input[type="week"]:hover::-webkit-calendar-picker-indicator,
input[type="month"]:hover::-webkit-calendar-picker-indicator {
    opacity: 1;
}

/* ============================================
   Checkboxes & Radio Buttons
   ============================================ */
.checkbox-wrapper,
.radio-wrapper {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--apple-gray-light);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    user-select: none;
}

.checkbox-wrapper:hover,
.radio-wrapper:hover {
    background: rgba(0, 113, 227, 0.08);
    border-color: var(--apple-blue);
}

.checkbox-wrapper input[type="checkbox"],
.radio-wrapper input[type="radio"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--apple-blue);
}

/* ============================================
   Header
   ============================================ */
header {
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-light);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: saturate(180%) blur(20px);
    background: rgba(255, 255, 255, 0.8);
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-md) 0;
}

/* ============================================
   Hero Section
   ============================================ */
.hero {
    text-align: center;
    padding: var(--spacing-lg) 0 var(--spacing-md) 0;
    background: linear-gradient(180deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
}

.hero-title {
    margin-bottom: var(--spacing-md);
}

.hero-subtitle {
    margin-bottom: var(--spacing-xl);
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.hero-cta {
    display: flex;
    gap: var(--spacing-md);
    justify-content: center;
    flex-wrap: wrap;
}

/* ============================================
   Grid Layouts
   ============================================ */
.grid {
    display: grid;
    gap: var(--spacing-md);
}

.grid-2 {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.grid-3 {
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

.grid-4 {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.grid-5 {
    grid-template-columns: repeat(5, 1fr);
    gap: var(--spacing-md);
}

/* Responsive adjustments for 5-column grid */
@media (max-width: 1200px) {
    .grid-5 {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .grid-5 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .grid-5 {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   Stats Display
   ============================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--spacing-lg);
    margin: var(--spacing-xl) 0;
}

.stat-card {
    text-align: center;
    padding: var(--spacing-sm);
    background: var(--apple-white);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-light);
}

.stat-value {
    font-size: 48px;
    font-weight: 600;
    letter-spacing: -0.015em;
    color: var(--apple-blue);
    line-height: 1;
    margin-bottom: var(--spacing-xs);
}

.stat-label {
    font-size: 14px;
    color: var(--text-secondary);
    letter-spacing: -0.016em;
}

/* ============================================
   Table Styles
   ============================================ */
.table-container {
    background: var(--apple-white);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-light);
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table thead {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-medium);
}

.table th {
    padding: var(--spacing-md) var(--spacing-lg);
    text-align: left;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: -0.016em;
    text-transform: uppercase;
}

.table td {
    padding: var(--spacing-md) var(--spacing-lg);
    border-bottom: 1px solid var(--border-light);
    font-size: 17px;
    color: var(--text-primary);
}

.table tbody tr {
    transition: background var(--transition-fast);
}

.table tbody tr:hover {
    background: var(--bg-tertiary);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

/* Checkbox column */
.checkbox-col {
    width: 40px;
    text-align: center;
}

.table input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--apple-blue);
}

/* ============================================
   Badges & Tags
   ============================================ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 500;
    border-radius: var(--radius-pill);
    letter-spacing: 0.01em;
}

.badge-blue {
    background: rgba(0, 113, 227, 0.1);
    color: var(--apple-blue);
}

.badge-green {
    background: rgba(48, 209, 88, 0.1);
    color: var(--apple-green);
}

.badge-orange {
    background: rgba(255, 149, 0, 0.1);
    color: var(--apple-orange);
}

.badge-red {
    background: rgba(255, 59, 48, 0.1);
    color: var(--apple-red);
}

/* ============================================
   Progress & Loading
   ============================================ */
.progress-bar {
    width: 100%;
    height: 4px;
    background: var(--apple-gray-light);
    border-radius: var(--radius-pill);
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--apple-blue);
    border-radius: var(--radius-pill);
    transition: width var(--transition-base);
}

.loading {
    display: inline-block;
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* ============================================
   Animations
   ============================================ */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* ============================================
   Database Header
   ============================================ */
.db-header {
    background: var(--apple-white);
    border-bottom: 1px solid var(--border-light);
    padding: var(--spacing-lg) 0;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(20px);
    background: rgba(255, 255, 255, 0.8);
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.fade-in-up {
    animation: fadeInUp 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.fade-in {
    animation: fadeIn 0.4s ease-in;
}

/* ============================================
   Utility Classes
   ============================================ */
.text-center {
    text-align: center;
}

.text-left {
    text-align: left;
}

.text-right {
    text-align: right;
}

.mt-sm { margin-top: var(--spacing-sm); }
.mt-md { margin-top: var(--spacing-md); }
.mt-lg { margin-top: var(--spacing-lg); }
.mt-xl { margin-top: var(--spacing-xl); }

.mb-sm { margin-bottom: var(--spacing-sm); }
.mb-md { margin-bottom: var(--spacing-md); }
.mb-lg { margin-bottom: var(--spacing-lg); }
.mb-xl { margin-bottom: var(--spacing-xl); }

.flex {
    display: flex;
}

.flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

.flex-between {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.gap-sm { gap: var(--spacing-sm); }
.gap-md { gap: var(--spacing-md); }
.gap-lg { gap: var(--spacing-lg); }

/* ============================================
   Responsive Design
   ============================================ */
@media (max-width: 768px) {
    .container {
        padding: 0 16px;
    }
    
    .section {
        padding: var(--spacing-lg) 0;
    }
    
    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .table-container {
        overflow-x: auto;
    }
    
    .table {
        font-size: 14px;
    }
    
    .table th,
    .table td {
        padding: var(--spacing-sm);
    }
}

@media (max-width: 480px) {
    .hero-cta {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   Visualization Page - Compact Filter Buttons
   ============================================ */

/* Model selector - 5 columns */
#model-selector {
    grid-template-columns: repeat(5, 1fr);
    gap: var(--spacing-xs);
}

/* Capacity selector - 6 columns */
#capacity-selector {
    grid-template-columns: repeat(6, 1fr);
    gap: var(--spacing-xs);
}

/* Source selector - keep at 4 columns (fewer items) */
#source-selector {
    grid-template-columns: repeat(4, 1fr);
    gap: var(--spacing-xs);
}

/* Make filter buttons more compact */
#model-selector .checkbox-wrapper,
#capacity-selector .checkbox-wrapper,
#source-selector .checkbox-wrapper {
    padding: 6px 10px;
    font-size: 14px;
    min-height: auto;
}

#model-selector .checkbox-wrapper input[type="checkbox"],
#capacity-selector .checkbox-wrapper input[type="checkbox"],
#source-selector .checkbox-wrapper input[type="checkbox"] {
    width: 16px;
    height: 16px;
}

#model-selector .checkbox-wrapper label,
#capacity-selector .checkbox-wrapper label,
#source-selector .checkbox-wrapper label {
    font-size: 13px;
    line-height: 1.2;
}

/* Responsive adjustments for visualization filters */
@media (max-width: 1024px) {
    #model-selector {
        grid-template-columns: repeat(4, 1fr);
    }
    
    #capacity-selector {
        grid-template-columns: repeat(5, 1fr);
    }
    
    #source-selector {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    #model-selector {
        grid-template-columns: repeat(3, 1fr);
    }
    
    #capacity-selector {
        grid-template-columns: repeat(4, 1fr);
    }
    
    #source-selector {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    #model-selector,
    #capacity-selector,
    #source-selector {
        grid-template-columns: repeat(2, 1fr);
    }
}
