/* CSS Reset and Variables */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #64748b;
    --bg-color: #f8fafc;
    --panel-bg: #ffffff;
    --text-color: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --shadow: 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);
    --radius: 12px;
    --radius-sm: 8px;
}

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

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

/* Header */
.app-header {
    background: var(--panel-bg);
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border-color);
    text-align: center;
}

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

.logo {
    width: 40px;
    height: 40px;
    object-fit: contain;
}

.app-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-color), #a855f7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tagline {
    color: var(--text-muted);
    margin-top: 0.25rem;
    font-size: 0.95rem;
}

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

/* Control Panel */
.control-panel {
    width: 340px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-height: calc(100vh - 180px);
    overflow-y: auto;
    padding-right: 0.5rem;
}

.control-panel::-webkit-scrollbar {
    width: 6px;
}

.control-panel::-webkit-scrollbar-track {
    background: transparent;
}

.control-panel::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.panel-section {
    background: var(--panel-bg);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
}

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

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

.device-btn {
    padding: 0.625rem 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--panel-bg);
    color: var(--text-color);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.device-btn:hover {
    border-color: var(--primary-color);
    background: #f0f0ff;
}

.device-btn.active {
    border-color: var(--primary-color);
    background: var(--primary-color);
    color: white;
}

/* Control Groups */
.control-group {
    margin-bottom: 0.875rem;
}

.control-group:last-child {
    margin-bottom: 0;
}

.control-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 0.375rem;
}

.control-group input[type="text"],
.control-group input[type="url"],
.control-group select {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    background: var(--panel-bg);
    color: var(--text-color);
    transition: border-color 0.2s ease;
}

.control-group input[type="text"]:focus,
.control-group input[type="url"]:focus,
.control-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

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

.control-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.control-group input[type="color"] {
    width: 100%;
    height: 40px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 4px;
    cursor: pointer;
}

.control-group span {
    display: inline-block;
    margin-top: 0.25rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.checkbox-group label {
    margin-bottom: 0;
    cursor: pointer;
}

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

/* Content Sections */
.content-section {
    margin-top: 0.75rem;
}

.content-section.hidden {
    display: none;
}

.upload-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem;
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.875rem;
    font-weight: 500;
}

.upload-btn:hover {
    border-color: var(--primary-color);
    background: #f8f8ff;
}

.upload-btn input[type="file"] {
    display: none;
}

.upload-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
    margin-top: 0.5rem;
}

/* Buttons */
.primary-btn {
    width: 100%;
    padding: 0.875rem 1.25rem;
    background: linear-gradient(135deg, var(--primary-color), #a855f7);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

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

.primary-btn:active {
    transform: translateY(0);
}

.secondary-btn {
    padding: 0.625rem 1rem;
    background: var(--panel-bg);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

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

#load-url-btn {
    margin-top: 0.5rem;
    width: 100%;
}

/* Preview Area */
.preview-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #e0e7ff 0%, #fce7f3 100%);
    border-radius: var(--radius);
    padding: 2rem;
    min-height: 600px;
}

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

.preview-actions {
    margin-top: 1.5rem;
}

/* Device Frame Styles */
.device-frame {
    position: relative;
    background: #1a1a1a;
    border-radius: 45px;
    padding: 12px;
    box-shadow:
        0 25px 50px -12px rgba(0, 0, 0, 0.35),
        inset 0 0 0 1px rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
}

.device-frame.light-mode .status-bar {
    background: #f5f5f7;
    color: #1d1d1f;
}

.device-frame.dark-mode .status-bar {
    background: #1c1c1e;
    color: #ffffff;
}

/* Device Sizes */
.device-frame.iphone-14,
.device-frame.iphone-14-pro {
    width: 290px;
    height: 590px;
    border-radius: 45px;
}

.device-frame.samsung-s23 {
    width: 280px;
    height: 600px;
    border-radius: 35px;
}

.device-frame.pixel-7 {
    width: 275px;
    height: 585px;
    border-radius: 38px;
}

.device-frame.ipad {
    width: 450px;
    height: 620px;
    border-radius: 25px;
    padding: 18px;
}

.device-frame.macbook {
    width: 600px;
    height: 380px;
    border-radius: 15px;
    padding: 8px 8px 30px 8px;
}

.device-frame.macbook::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 120px;
    height: 20px;
    background: linear-gradient(to bottom, #2a2a2a, #1a1a1a);
    border-radius: 0 0 8px 8px;
}

/* Status Bar */
.status-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 20px;
    font-size: 14px;
    font-weight: 600;
    background: #f5f5f7;
    color: #1d1d1f;
    border-radius: 35px 35px 0 0;
    position: relative;
    z-index: 10;
}

.device-frame.macbook .status-bar {
    padding: 6px 16px;
    font-size: 12px;
    border-radius: 8px 8px 0 0;
}

.device-frame.ipad .status-bar {
    border-radius: 8px 8px 0 0;
}

.status-left {
    display: flex;
    align-items: center;
    gap: 5px;
    flex: 1;
}

.status-notch {
    display: flex;
    justify-content: center;
    flex: 1;
}

.notch {
    width: 90px;
    height: 25px;
    background: #1a1a1a;
    border-radius: 0 0 20px 20px;
}

.device-frame.iphone-14-pro .notch {
    width: 85px;
    height: 28px;
    border-radius: 20px;
    margin-top: -5px;
}

.device-frame.samsung-s23 .notch,
.device-frame.pixel-7 .notch {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.device-frame.ipad .notch,
.device-frame.macbook .notch {
    display: none;
}

.notch.hidden {
    visibility: hidden;
}

.status-right {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    justify-content: flex-end;
}

.signal-bars {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 12px;
}

.signal-bars .bar {
    width: 3px;
    background: currentColor;
    border-radius: 1px;
}

.signal-bars .bar:nth-child(1) { height: 4px; }
.signal-bars .bar:nth-child(2) { height: 6px; }
.signal-bars .bar:nth-child(3) { height: 8px; }
.signal-bars .bar:nth-child(4) { height: 10px; }

.signal-bars .bar.inactive {
    opacity: 0.3;
}

.carrier {
    font-size: 12px;
    font-weight: 500;
}

.wifi-icon,
.bluetooth-icon {
    font-size: 12px;
}

.wifi-icon.hidden,
.bluetooth-icon.hidden {
    display: none;
}

.battery {
    display: flex;
    align-items: center;
    gap: 4px;
}

.battery-icon {
    width: 22px;
    height: 10px;
    border: 1.5px solid currentColor;
    border-radius: 2px;
    position: relative;
    display: flex;
    align-items: center;
    padding: 1px;
}

.battery-icon::after {
    content: '';
    position: absolute;
    right: -4px;
    width: 2px;
    height: 5px;
    background: currentColor;
    border-radius: 0 1px 1px 0;
}

.battery-level {
    height: 100%;
    background: currentColor;
    border-radius: 1px;
    transition: width 0.3s ease;
}

.battery-percent {
    font-size: 11px;
    font-weight: 500;
}

/* Screen Content */
.screen-content {
    background: #ffffff;
    height: calc(100% - 60px);
    border-radius: 0 0 35px 35px;
    overflow: hidden;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.device-frame.macbook .screen-content {
    border-radius: 0 0 8px 8px;
    height: calc(100% - 40px);
}

.device-frame.ipad .screen-content {
    border-radius: 0 0 8px 8px;
}

.screen-content img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.placeholder-content {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem;
}

.placeholder-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

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

/* Home Indicator */
.home-indicator {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 120px;
    height: 5px;
    background: #333;
    border-radius: 3px;
}

.device-frame.ipad .home-indicator,
.device-frame.macbook .home-indicator {
    display: none;
}

/* Drag and Drop Highlight */
.screen-content.drag-over {
    background: #e0e7ff;
    border: 3px dashed var(--primary-color);
}

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

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

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

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

/* Responsive Design */
@media (max-width: 1200px) {
    .main-content {
        flex-direction: column;
    }

    .control-panel {
        width: 100%;
        max-height: none;
        overflow-y: visible;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 1rem;
    }

    .panel-section {
        flex: 1;
        min-width: 280px;
    }

    .preview-area {
        min-height: 500px;
    }
}

@media (max-width: 768px) {
    .app-header {
        padding: 1rem;
    }

    .app-header h1 {
        font-size: 1.25rem;
    }

    .main-content {
        padding: 1rem;
        gap: 1rem;
    }

    .control-panel {
        flex-direction: column;
    }

    .panel-section {
        min-width: 100%;
    }

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

    .preview-area {
        padding: 1rem;
        min-height: 400px;
    }

    .device-frame.iphone-14,
    .device-frame.iphone-14-pro,
    .device-frame.samsung-s23,
    .device-frame.pixel-7 {
        transform: scale(0.8);
        transform-origin: center;
    }

    .device-frame.ipad {
        transform: scale(0.6);
        transform-origin: center;
    }

    .device-frame.macbook {
        transform: scale(0.5);
        transform-origin: center;
    }
}

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

    .device-frame.iphone-14,
    .device-frame.iphone-14-pro,
    .device-frame.samsung-s23,
    .device-frame.pixel-7 {
        transform: scale(0.65);
    }

    .device-frame.ipad {
        transform: scale(0.45);
    }

    .device-frame.macbook {
        transform: scale(0.35);
    }
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.panel-section {
    animation: fadeIn 0.3s ease-out;
}

.panel-section:nth-child(2) { animation-delay: 0.05s; }
.panel-section:nth-child(3) { animation-delay: 0.1s; }
.panel-section:nth-child(4) { animation-delay: 0.15s; }
.panel-section:nth-child(5) { animation-delay: 0.2s; }
