/* ===== RESET & VARIABLES ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

:root {
    --primary: #4361ee;
    --primary-dark: #3a56d4;
    --secondary: #7209b7;
    --bg: #f8fafc;
    --surface: #ffffff;
    --text: #0f172a;
    --text-light: #334155;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);
    --radius: 12px;
    --header-height: 70px;
}

/* Dark mode */
body.dark-mode {
    --bg: #0f172a;
    --surface: #1e293b;
    --text: #f1f5f9;
    --text-light: #cbd5e1;
    --border: #334155;
}

body {
    background: var(--bg);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    color: var(--text);
}

/* ===== HEADER ===== */
.header {
    height: var(--header-height);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 40;
    box-shadow: var(--shadow);
}

.menu-button {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 10px;
    background: var(--bg);
    color: var(--text);
    cursor: pointer;
    font-size: 24px;
    border: 1px solid var(--border);
    flex-shrink: 0;
}

.menu-button:hover {
    background: var(--primary);
    color: white;
}

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

.nav-links a {
    color: var(--text);
    text-decoration: none;
    padding: 8px 12px;
    border-radius: 6px;
}

.nav-links a:hover {
    background: var(--bg);
    color: var(--primary);
}

.url-section {
    flex: 1;
    max-width: 600px;
    display: flex;
    gap: 8px;
    margin: 0 auto;
}

.url-input {
    width: 100%;
    height: 44px;
    padding: 0 16px;
    border: 2px solid var(--border);
    border-radius: 30px;
    font-size: 14px;
    background: var(--bg);
    color: var(--text);
}

.url-input:focus {
    outline: none;
    border-color: var(--primary);
}

.test-btn {
    height: 44px;
    padding: 0 24px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 30px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}

.test-btn:hover {
    background: var(--primary-dark);
}

.header-controls {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.icon-btn {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--text-light);
    cursor: pointer;
    font-size: 20px;
}

.icon-btn:hover {
    background: var(--bg);
    color: var(--primary);
}

/* ===== MAIN CONTAINER ===== */
.main-container {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
}

.content-area {
    flex: 1;
    display: flex;
    overflow: hidden;
    position: relative;
}

/* ===== DEVICE PANEL ===== */
.device-panel {
    position: absolute;
    left: -400px;
    top: 0;
    width: min(380px, 90%);
    height: 100%;
    background: var(--surface);
    border-right: 1px solid var(--border);
    transition: left 0.3s ease;
    z-index: 45;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
}

.device-panel.open {
    left: 0;
}

.panel-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.panel-header h3 {
    font-size: 18px;
}

.close-panel {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    cursor: pointer;
    font-size: 20px;
}

.panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.device-section {
    margin-bottom: 24px;
}

.section-title {
    font-weight: 600;
    font-size: 15px;
    color: var(--text-muted);
    margin-bottom: 12px;
    text-transform: uppercase;
}

.device-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 8px;
}

.device-item {
    padding: 10px 8px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.device-item:hover {
    border-color: var(--primary);
}

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

.device-name {
    font-weight: 600;
    font-size: 12px;
}

.device-res {
    font-size: 10px;
    opacity: 0.9;
    margin-top: 2px;
}

.size-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.size-pill {
    flex: 1 0 calc(33.333% - 6px);
    padding: 8px 4px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 11px;
    text-align: center;
    cursor: pointer;
}

.size-pill:hover {
    border-color: var(--primary);
}

.size-pill.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* ===== PREVIEW AREA ===== */
.preview-area {
    flex: 1;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.preview-default {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 20px;
}

.default-content h2 {
    font-size: 24px;
    margin-bottom: 12px;
}

.device-illustration {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 30px;
}

.device-icon {
    width: 60px;
    height: 60px;
    background: var(--surface);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.preview-active {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.preview-toolbar {
    height: 48px;
    padding: 0 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 16px;
}

.device-label {
    font-weight: 700;
    color: var(--primary);
    background: rgba(67,97,238,0.1);
    padding: 4px 12px;
    border-radius: 30px;
}

.dimension-badge {
    background: var(--bg);
    padding: 4px 12px;
    border-radius: 30px;
    border: 1px solid var(--border);
}

.preview-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow: auto;
    background: repeating-linear-gradient(45deg, var(--border) 0px, var(--border) 1px, transparent 1px, transparent 30px);
}

.device-frame {
    background: var(--surface);
    border-radius: 36px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    position: relative;
    transition: width 0.3s, height 0.3s;
    border: 6px solid var(--text);
    max-width: 100%;
    max-height: 100%;
}

.device-frame.mobile {
    border-radius: 36px;
    border-width: 6px;
}

.device-frame.tablet {
    border-radius: 24px;
    border-width: 6px;
}

.device-frame.desktop {
    border-radius: 8px;
    border-width: 2px;
}

.device-notch {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 120px;
    height: 28px;
    background: var(--text);
    border-radius: 0 0 20px 20px;
    z-index: 2;
}

.preview-iframe {
    width: 100%;
    height: 100%;
    border: none;
    background: white;
}

.resize-handle {
    position: absolute;
    width: 12px;
    height: 100%;
    top: 0;
    cursor: ew-resize;
    z-index: 10;
    background: rgba(67,97,238,0.2);
    opacity: 0;
}

.device-frame:hover .resize-handle {
    opacity: 1;
}

.resize-handle.left { left: -6px; }
.resize-handle.right { right: -6px; }

.width-tooltip {
    position: absolute;
    bottom: -40px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary);
    color: white;
    padding: 6px 16px;
    border-radius: 40px;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    pointer-events: none;
    z-index: 20;
}

/* ===== BREAKPOINT SLIDER ===== */
.breakpoint-slider {
    height: 60px;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 0 20px;
    display: flex;
    align-items: center;
}

.slider-container {
    flex: 1;
    position: relative;
    height: 40px;
    display: flex;
    align-items: center;
}

.slider-track {
    width: 100%;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
}

.slider-progress {
    position: absolute;
    height: 4px;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    border-radius: 2px;
    pointer-events: none;
}

.slider-handle {
    position: absolute;
    width: 20px;
    height: 20px;
    background: white;
    border: 3px solid var(--primary);
    border-radius: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    cursor: grab;
    box-shadow: var(--shadow-lg);
    z-index: 5;
}

.breakpoint-markers {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 100%;
    pointer-events: none;
}

.breakpoint {
    position: absolute;
    bottom: 100%;
    transform: translateX(-50%);
    font-size: 10px;
    color: var(--text-muted);
    background: var(--surface);
    padding: 2px 6px;
    border-radius: 12px;
    border: 1px solid var(--border);
}

/* ===== STATUS BAR ===== */
.status-bar {
    height: 40px;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 0 20px;
    display: flex;
    align-items: center;
    gap: 24px;
    font-size: 12px;
    color: var(--text-muted);
}

.status-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #06d6a0;
}

/* ===== MOBILE BOTTOM BAR ===== */
.mobile-bottom-bar {
    display: none;
    height: 60px;
    background: var(--surface);
    border-top: 1px solid var(--border);
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    padding: 0 12px;
    align-items: center;
    justify-content: space-around;
}

/* ===== MODAL ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: flex-end;
    z-index: 200;
}

.modal-overlay.active {
    display: flex;
}

.modal-drawer {
    background: var(--surface);
    width: 100%;
    border-radius: 30px 30px 0 0;
    padding: 24px;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-overlay.active .modal-drawer {
    transform: translateY(0);
}

/* ===== LOADING OVERLAY ===== */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.9);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 50;
}

.loading-overlay.active {
    display: flex;
}

.skeleton-loader {
    background: var(--surface);
    padding: 30px;
    border-radius: 24px;
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.skeleton-animation {
    width: 60px;
    height: 60px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== FOOTER ===== */
.site-footer {
    text-align: center;
    padding: 30px;
    border-top: 1px solid var(--border);
    background: var(--surface);
}

.footer-menu {
    margin-bottom: 15px;
}

.footer-menu a {
    color: var(--text);
    text-decoration: none;
    margin: 0 10px;
    font-size: 14px;
}

.footer-menu a:hover {
    color: var(--primary);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .nav-links {
        display: none;
    }
    
    .mobile-bottom-bar {
        display: flex;
    }
    
    .main-container {
        height: calc(100vh - var(--header-height) - 60px);
    }
    
    .breakpoint {
        display: none;
    }
}