/* CSS Variables */
:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #64748b;
    --background: #f8fafc;
    --surface: #ffffff;
    --surface-hover: #f1f5f9;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 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-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --transition: 150ms ease;
}

/* Dark mode */
[data-theme="dark"] {
    --primary-color: #818cf8;
    --primary-hover: #6366f1;
    --secondary-color: #94a3b8;
    --background: #0f172a;
    --surface: #1e293b;
    --surface-hover: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --border-color: #334155;
}

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

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

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--background);
    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: var(--surface);
    border-bottom: 1px solid var(--border-color);
    padding: 1.5rem;
    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;
}

.header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
}

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

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

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

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

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

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

.control-section {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
}

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

.control-group {
    margin-bottom: 1rem;
}

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

.control-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.control-group label span {
    font-weight: 600;
    color: var(--primary-color);
}

/* Form Elements */
select, input[type="text"], textarea {
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-size: 0.875rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--text-primary);
    transition: border-color var(--transition), box-shadow var(--transition);
}

select:hover, input[type="text"]:hover, textarea:hover {
    border-color: var(--secondary-color);
}

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

textarea {
    resize: vertical;
    min-height: 80px;
}

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

input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 2px;
}

input[type="color"]::-webkit-color-swatch {
    border-radius: 4px;
    border: none;
}

/* Range Slider */
input[type="range"] {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    background: var(--border-color);
    border-radius: 3px;
    outline: none;
}

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

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.2);
}

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

.weight-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.hint {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

/* Google Font & Custom Font Input */
.google-font-input, .custom-font-input {
    display: flex;
    gap: 0.5rem;
}

.google-font-input input, .custom-font-input input {
    flex: 1;
}

/* Preset Texts */
.preset-texts {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition);
}

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

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

.btn-secondary {
    background: var(--surface-hover);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

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

.btn-small {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
    background: var(--surface-hover);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn-small:hover {
    background: var(--border-color);
    color: var(--text-primary);
}

.btn-icon {
    padding: 0.5rem;
    background: var(--surface-hover);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

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

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

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

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

.preview-actions {
    display: flex;
    gap: 0.5rem;
}

.preview-container {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 2rem;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
    overflow: hidden;
    word-break: break-word;
}

#preview-output {
    text-align: center;
    transition: all var(--transition);
}

/* Weight Comparison */
.weight-comparison {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
}

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

.weight-samples {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
}

.weight-sample {
    padding: 1rem;
    background: var(--surface-hover);
    border-radius: var(--radius-md);
    text-align: center;
}

.weight-sample .weight-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.weight-sample .weight-text {
    font-size: 1.25rem;
    transition: font-family var(--transition);
}

/* CSS Export */
.css-export {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
}

.export-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.export-header h3 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

#css-output {
    background: var(--background);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem;
    overflow-x: auto;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.8125rem;
    line-height: 1.6;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-break: break-all;
}

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

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

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

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

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--text-primary);
    color: var(--surface);
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 1000;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    visibility: visible;
}

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

    .controls-panel {
        max-height: none;
        overflow-y: visible;
        padding-right: 0;
    }

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

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

    .header h1 {
        font-size: 1.5rem;
    }

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

    .control-section {
        padding: 1rem;
    }

    .preview-container {
        padding: 1.5rem;
        min-height: 150px;
    }

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

    .preview-header {
        flex-direction: column;
        gap: 0.75rem;
        align-items: flex-start;
    }

    .export-header {
        flex-direction: column;
        gap: 0.75rem;
        align-items: flex-start;
    }
}

@media (max-width: 480px) {
    .logo {
        flex-direction: column;
        gap: 0.5rem;
    }

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

    .tagline {
        font-size: 0.85rem;
    }

    .weight-samples {
        grid-template-columns: 1fr 1fr;
    }

    .preset-texts {
        flex-direction: column;
    }

    .preset-texts .btn-small {
        width: 100%;
    }

    .google-font-input, .custom-font-input {
        flex-direction: column;
    }
}

/* Print styles */
@media print {
    .controls-panel,
    .preview-actions,
    .css-export,
    .footer {
        display: none;
    }

    .main-content {
        grid-template-columns: 1fr;
    }

    .preview-container {
        border: 1px solid #000;
        box-shadow: none;
    }
}
