/* CSS Variables for theming */
:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #64748b;
    --secondary-hover: #475569;
    --background-color: #0f172a;
    --surface-color: #1e293b;
    --surface-light: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --border-color: #334155;
    --accent-color: #22d3ee;
    --success-color: #22c55e;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --transition: all 0.2s ease;
}

/* Reset */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
}

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

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

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

.header-content {
    max-width: 1800px;
    margin: 0 auto;
    text-align: center;
}

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

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

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

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

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

/* Controls Panel */
.controls-panel {
    width: 380px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.control-group {
    background: var(--surface-color);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    border: 1px solid var(--border-color);
}

.control-group > label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* URL Input */
.url-input-wrapper {
    display: flex;
    gap: 0.5rem;
}

.url-input-wrapper input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--background-color);
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: var(--transition);
}

.url-input-wrapper input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

/* Buttons */
.btn {
    padding: 0.75rem 1.25rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

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

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

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

.btn-action {
    background: var(--surface-light);
    color: var(--text-primary);
    flex: 1;
}

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

.btn-icon {
    font-size: 1.1rem;
}

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

.preset-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.75rem 0.5rem;
    background: var(--background-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-primary);
}

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

.preset-btn.active {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.2);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.3);
}

.preset-icon {
    font-size: 1.25rem;
    margin-bottom: 0.25rem;
}

.preset-name {
    font-size: 0.75rem;
    font-weight: 600;
    text-align: center;
    line-height: 1.2;
}

.preset-size {
    font-size: 0.65rem;
    color: var(--text-secondary);
    margin-top: 0.15rem;
}

/* Custom Dimensions */
.custom-dimensions {
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.dimension-input {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.dimension-input label {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.dimension-input input {
    width: 80px;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--background-color);
    color: var(--text-primary);
    font-size: 0.9rem;
    text-align: center;
}

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

.dimension-separator {
    color: var(--text-secondary);
    font-size: 1.25rem;
    padding-bottom: 0.5rem;
}

.unit {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Actions Group */
.actions-group {
    display: flex;
    gap: 0.75rem;
}

/* Current Info */
.current-info {
    background: var(--surface-color);
    border-radius: var(--radius-md);
    padding: 1rem 1.25rem;
    border: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    gap: 1rem;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.info-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.info-value {
    font-size: 1rem;
    font-weight: 600;
    color: var(--accent-color);
}

/* Preview Panel */
.preview-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-width: 0;
}

.preview-container {
    flex: 1;
    background: var(--surface-color);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    padding: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
    position: relative;
}

.preview-frame {
    position: relative;
    background: #ffffff;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    transition: width 0.3s ease, height 0.3s ease;
    overflow: hidden;
}

.iframe-wrapper {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.iframe-wrapper iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
    transform-origin: top left;
}

.frame-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, var(--surface-color), var(--background-color));
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 1rem;
    text-align: center;
    padding: 2rem;
}

.frame-overlay.hidden {
    display: none;
}

/* Zoom Controls */
.zoom-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: var(--surface-color);
    border-radius: var(--radius-md);
    padding: 0.75rem 1.25rem;
    border: 1px solid var(--border-color);
}

.zoom-controls label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

#zoom-slider {
    flex: 1;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--border-color);
    border-radius: 3px;
    cursor: pointer;
}

#zoom-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition);
}

#zoom-slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    background: var(--primary-hover);
}

#zoom-value {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--accent-color);
    min-width: 45px;
    text-align: right;
}

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

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

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

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

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--surface-color);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 800px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-color);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.75rem;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    transition: var(--transition);
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.screenshot-preview {
    background: var(--background-color);
    border-radius: var(--radius-md);
    padding: 1rem;
    text-align: center;
    margin-bottom: 1rem;
}

.screenshot-preview img {
    max-width: 100%;
    max-height: 50vh;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
}

.screenshot-info {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
}

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

    .controls-panel {
        width: 100%;
    }

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

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

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

    .logo h1 {
        font-size: 1.4rem;
    }

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

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

    .control-group {
        padding: 1rem;
    }

    .custom-dimensions {
        flex-direction: column;
        align-items: stretch;
    }

    .custom-dimensions .dimension-input {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }

    .dimension-separator {
        display: none;
    }

    .actions-group {
        flex-direction: column;
    }

    .current-info {
        flex-direction: column;
        gap: 0.75rem;
    }

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

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

    .url-input-wrapper {
        flex-direction: column;
    }

    .url-input-wrapper .btn {
        width: 100%;
    }

    .logo-img {
        width: 32px;
        height: 32px;
    }

    .logo h1 {
        font-size: 1.2rem;
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--background-color);
}

::-webkit-scrollbar-thumb {
    background: var(--surface-light);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-color);
}

/* Animation for preset selection */
@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(99, 102, 241, 0); }
    100% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0); }
}

.preset-btn.active {
    animation: pulse 0.5s ease-out;
}
