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

:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #8b5cf6;
    --background: #0f172a;
    --surface: #1e293b;
    --surface-light: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --border-color: #475569;
    --success: #22c55e;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -2px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -4px rgba(0, 0, 0, 0.2);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    text-align: center;
    padding: 2rem 1rem;
    background: linear-gradient(135deg, var(--surface) 0%, var(--background) 100%);
    border-bottom: 1px solid var(--border-color);
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.logo-img {
    width: 48px;
    height: 48px;
    border-radius: 12px;
}

.header h1 {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tagline {
    color: var(--text-secondary);
    font-size: 1rem;
}

/* Main Content */
.main-content {
    flex: 1;
    display: grid;
    grid-template-columns: 360px 1fr;
    gap: 2rem;
    padding: 2rem;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
}

/* Controls Panel */
.controls-panel {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.control-section {
    background: var(--surface);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.control-section h2 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
}

/* Device Grid */
.device-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

.device-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.75rem 0.5rem;
    background: var(--surface-light);
    border: 2px solid transparent;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-primary);
}

.device-btn:hover {
    background: var(--border-color);
    transform: translateY(-2px);
}

.device-btn.active {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.15);
}

.device-icon {
    font-size: 1.5rem;
}

.device-name {
    font-size: 0.75rem;
    font-weight: 500;
}

/* Upload Area */
.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    padding: 2rem 1rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.1);
}

.upload-content {
    pointer-events: none;
}

.upload-icon {
    font-size: 2.5rem;
    display: block;
    margin-bottom: 0.5rem;
}

.upload-area p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.upload-hint {
    font-size: 0.75rem !important;
    margin-top: 0.25rem;
}

.file-name {
    margin-top: 0.75rem;
    font-size: 0.75rem;
    color: var(--success);
    word-break: break-all;
}

/* Sliders */
.slider-group {
    margin-bottom: 1.25rem;
}

.slider-group:last-of-type {
    margin-bottom: 1rem;
}

.slider-group label {
    display: block;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.slider-group input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--surface-light);
    appearance: none;
    cursor: pointer;
}

.slider-group input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    transition: transform 0.2s ease;
}

.slider-group input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.slider-group input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-color);
    border: none;
    cursor: pointer;
}

.slider-value {
    display: block;
    text-align: right;
    font-size: 0.75rem;
    color: var(--primary-color);
    margin-top: 0.25rem;
    font-weight: 600;
}

/* Buttons */
.reset-btn {
    width: 100%;
    padding: 0.625rem 1rem;
    background: var(--surface-light);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.reset-btn:hover {
    background: var(--border-color);
}

.download-btn {
    width: 100%;
    padding: 1rem;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    border: none;
    border-radius: 12px;
    color: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.download-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

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

.download-icon {
    font-size: 1.25rem;
}

/* Preview Panel */
.preview-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    border-radius: 16px;
    padding: 2rem;
    min-height: 500px;
    box-shadow: var(--shadow);
}

.preview-container {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

/* Device Frames */
.device-frame {
    position: relative;
    background: #1a1a1a;
    border-radius: 40px;
    padding: 12px;
    box-shadow:
        0 0 0 2px #333,
        0 0 0 4px #1a1a1a,
        var(--shadow-lg);
}

.device-frame::before {
    content: '';
    position: absolute;
    top: 50%;
    left: -3px;
    transform: translateY(-50%);
    width: 3px;
    height: 60px;
    background: #333;
    border-radius: 2px 0 0 2px;
}

.device-frame::after {
    content: '';
    position: absolute;
    top: 50%;
    right: -3px;
    transform: translateY(-50%);
    width: 3px;
    height: 30px;
    background: #333;
    border-radius: 0 2px 2px 0;
}

.device-screen {
    position: relative;
    background: #000;
    border-radius: 28px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* iPhone 14 */
.device-frame.iphone-14 .device-screen {
    width: 260px;
    height: 562px;
}

/* iPhone 14 Pro */
.device-frame.iphone-14-pro {
    border-radius: 50px;
}

.device-frame.iphone-14-pro .device-screen {
    width: 260px;
    height: 562px;
    border-radius: 36px;
}

.device-frame.iphone-14-pro .device-screen::before {
    content: '';
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    width: 90px;
    height: 28px;
    background: #1a1a1a;
    border-radius: 20px;
    z-index: 10;
}

/* Pixel 7 */
.device-frame.pixel-7 {
    border-radius: 36px;
}

.device-frame.pixel-7 .device-screen {
    width: 256px;
    height: 554px;
    border-radius: 24px;
}

.device-frame.pixel-7::before {
    display: none;
}

/* Samsung S23 */
.device-frame.samsung-s23 {
    border-radius: 36px;
}

.device-frame.samsung-s23 .device-screen {
    width: 256px;
    height: 554px;
    border-radius: 24px;
}

.device-frame.samsung-s23 .device-screen::before {
    content: '';
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    width: 12px;
    height: 12px;
    background: #1a1a1a;
    border-radius: 50%;
    z-index: 10;
}

/* iPad Pro */
.device-frame.ipad-pro {
    border-radius: 24px;
    padding: 16px;
}

.device-frame.ipad-pro .device-screen {
    width: 400px;
    height: 540px;
    border-radius: 8px;
}

.device-frame.ipad-pro::before,
.device-frame.ipad-pro::after {
    display: none;
}

/* MacBook Pro */
.device-frame.macbook-pro {
    border-radius: 16px 16px 0 0;
    padding: 12px 12px 0 12px;
    background: #2a2a2a;
}

.device-frame.macbook-pro .device-screen {
    width: 520px;
    height: 325px;
    border-radius: 4px 4px 0 0;
}

.device-frame.macbook-pro::before {
    content: '';
    position: absolute;
    top: 6px;
    left: 50%;
    transform: translateX(-50%);
    width: 8px;
    height: 8px;
    background: #1a1a1a;
    border-radius: 50%;
}

.device-frame.macbook-pro::after {
    content: '';
    position: absolute;
    bottom: -20px;
    left: -30px;
    right: -30px;
    height: 20px;
    background: linear-gradient(180deg, #3a3a3a 0%, #2a2a2a 100%);
    border-radius: 0 0 8px 8px;
}

/* iMac */
.device-frame.imac {
    border-radius: 16px;
    padding: 16px 16px 50px 16px;
    background: #e0e0e0;
}

.device-frame.imac .device-screen {
    width: 540px;
    height: 340px;
    border-radius: 4px;
}

.device-frame.imac::before {
    content: '';
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 20px;
    background: #c0c0c0;
    border-radius: 4px;
}

.device-frame.imac::after {
    content: '';
    position: absolute;
    bottom: -60px;
    left: 50%;
    transform: translateX(-50%);
    width: 120px;
    height: 60px;
    background: linear-gradient(180deg, #d0d0d0 0%, #b0b0b0 100%);
    border-radius: 0 0 8px 8px;
}

/* Surface Pro */
.device-frame.surface-pro {
    border-radius: 12px;
    padding: 20px;
    background: #1a1a1a;
}

.device-frame.surface-pro .device-screen {
    width: 460px;
    height: 307px;
    border-radius: 2px;
}

.device-frame.surface-pro::before,
.device-frame.surface-pro::after {
    display: none;
}

/* Preview Image */
.preview-image {
    position: absolute;
    max-width: none;
    display: none;
    pointer-events: none;
}

.preview-image.visible {
    display: block;
}

.placeholder-text {
    text-align: center;
    color: var(--text-secondary);
}

.placeholder-text span {
    font-size: 3rem;
    display: block;
    margin-bottom: 0.5rem;
    opacity: 0.5;
}

.placeholder-text p {
    font-size: 0.875rem;
}

.placeholder-text.hidden {
    display: none;
}

/* Footer */
.footer {
    text-align: center;
    padding: 1.5rem;
    background: var(--surface);
    border-top: 1px solid var(--border-color);
}

.footer p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
}

.footer a:hover {
    color: var(--secondary-color);
    text-decoration: underline;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
        gap: 1.5rem;
        padding: 1rem;
    }

    .controls-panel {
        order: 2;
    }

    .preview-panel {
        order: 1;
        min-height: 400px;
    }

    .device-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 768px) {
    .header h1 {
        font-size: 1.5rem;
    }

    .device-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Scale down devices for mobile */
    .device-frame.macbook-pro .device-screen,
    .device-frame.imac .device-screen,
    .device-frame.surface-pro .device-screen,
    .device-frame.ipad-pro .device-screen {
        width: 280px;
        height: auto;
        aspect-ratio: 16/10;
    }

    .device-frame.ipad-pro .device-screen {
        aspect-ratio: 4/3;
    }

    .preview-panel {
        padding: 1rem;
        min-height: 350px;
    }
}

@media (max-width: 480px) {
    .device-btn {
        padding: 0.5rem 0.25rem;
    }

    .device-icon {
        font-size: 1.25rem;
    }

    .device-name {
        font-size: 0.625rem;
    }

    .device-frame.iphone-14 .device-screen,
    .device-frame.iphone-14-pro .device-screen,
    .device-frame.pixel-7 .device-screen,
    .device-frame.samsung-s23 .device-screen {
        width: 180px;
        height: 390px;
    }
}
