/* CSS Variables */
:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --primary-light: #e0e7ff;
    --secondary-color: #64748b;
    --background: #f8fafc;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --success-color: #22c55e;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: all 0.2s ease;
}

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

html {
    scroll-behavior: smooth;
}

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

/* App Container */
.app-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem 1rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 2rem;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

header .subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Main Content */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
}

.card h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: var(--text-primary);
}

.card-description {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1.25rem;
}

/* Input Groups */
.input-group {
    display: flex;
    align-items: flex-end;
    gap: 1rem;
    flex-wrap: wrap;
}

.input-field {
    flex: 1;
    min-width: 100px;
}

.input-field label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.input-field input,
.input-field select {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    transition: var(--transition);
    background: var(--card-bg);
}

.input-field input:focus,
.input-field select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.input-field input::placeholder {
    color: var(--text-secondary);
    opacity: 0.6;
}

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

/* Input with Suffix */
.input-with-suffix {
    position: relative;
    display: flex;
    align-items: center;
}

.input-with-suffix input {
    padding-right: 2.5rem;
}

.input-with-suffix .suffix {
    position: absolute;
    right: 1rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

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

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

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

/* Results */
.result {
    margin-top: 1.25rem;
    padding: 1rem;
    background: var(--background);
    border-radius: var(--radius-sm);
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
}

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

.result-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
}

.result-value {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--primary-color);
}

/* Presets Grid */
.presets-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
}

.preset-btn {
    padding: 0.75rem 1rem;
    background: var(--background);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
}

.preset-btn:hover {
    border-color: var(--primary-color);
    background: var(--primary-light);
}

.preset-btn.active {
    border-color: var(--primary-color);
    background: var(--primary-light);
}

.preset-name {
    font-weight: 600;
    color: var(--text-primary);
    display: block;
}

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

/* Custom Ratio Inputs */
.custom-ratio-inputs {
    min-width: 150px;
}

.custom-ratio-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.custom-ratio-row input {
    width: 60px;
    padding: 0.75rem 0.5rem;
    text-align: center;
}

.custom-ratio-row span {
    color: var(--text-secondary);
    font-weight: 500;
}

/* Equivalent Results */
.equivalent-results {
    margin-top: 1.25rem;
}

.equivalent-results h3 {
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

.resolutions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.75rem;
}

.resolution-item {
    padding: 0.75rem;
    background: var(--background);
    border-radius: var(--radius-sm);
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    border: 2px solid transparent;
}

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

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

.resolution-value {
    font-weight: 600;
    color: var(--text-primary);
}

/* Scale Section */
.scale-inputs {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.scale-method {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.scale-method > label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.radio-group {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
}

.radio-label input[type="radio"] {
    accent-color: var(--primary-color);
    width: 1rem;
    height: 1rem;
}

.scale-value-group {
    margin-top: 0.5rem;
}

/* Preview Section */
.preview-controls {
    margin-bottom: 1.5rem;
}

.preview-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 2rem;
    background: var(--background);
    border-radius: var(--radius-sm);
}

.preview-box {
    width: 100%;
    max-width: 320px;
    aspect-ratio: 16 / 9;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: aspect-ratio 0.3s ease;
    box-shadow: var(--shadow-lg);
}

.preview-label {
    color: white;
    font-size: 1.5rem;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.preview-info {
    text-align: center;
}

.preview-info p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Comparison Grid */
.comparison-presets {
    margin-top: 1.5rem;
}

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

.comparison-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 0.75rem;
}

.comparison-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

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

.comparison-box {
    width: 80px;
    height: 50px;
    background: linear-gradient(135deg, var(--secondary-color), var(--text-secondary));
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.comparison-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: white;
}

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

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

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

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

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

/* Responsive Design */
@media (max-width: 768px) {
    .app-container {
        padding: 1rem 0.75rem;
    }

    header h1 {
        font-size: 1.75rem;
    }

    header .subtitle {
        font-size: 0.95rem;
    }

    .card {
        padding: 1.25rem;
    }

    .input-group {
        flex-direction: column;
        align-items: stretch;
    }

    .input-field {
        width: 100%;
    }

    .separator {
        text-align: center;
        padding: 0;
    }

    .btn {
        width: 100%;
    }

    .result {
        flex-direction: column;
        gap: 1rem;
    }

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

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

    .radio-group {
        flex-direction: column;
        gap: 0.75rem;
    }

    .preview-box {
        max-width: 280px;
    }

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

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

    .card h2 {
        font-size: 1.1rem;
    }

    .presets-grid {
        grid-template-columns: 1fr 1fr;
    }

    .comparison-grid {
        grid-template-columns: 1fr 1fr;
    }

    .preview-label {
        font-size: 1.25rem;
    }
}

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

.card {
    animation: fadeIn 0.3s ease;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.highlight {
    animation: highlight 0.5s ease;
}

@keyframes highlight {
    0%, 100% {
        background: var(--background);
    }
    50% {
        background: var(--primary-light);
    }
}
