/* FlipAlert Photo Studio — Minimal CSS */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #f5f5f7;
    color: #1d1d1f;
    min-height: 100vh;
}

.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 40px 20px;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 40px;
}

header h1 {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.subtitle {
    color: #86868b;
    margin-top: 6px;
    font-size: 15px;
}

/* Flash messages */
.flash-messages {
    margin-bottom: 24px;
}

.flash {
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 14px;
    margin-bottom: 8px;
}

.flash.error {
    background: #fff0f0;
    color: #c00;
    border: 1px solid #fcc;
}

/* Upload area */
.upload-area {
    border: 2px dashed #d2d2d7;
    border-radius: 16px;
    padding: 48px 24px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    position: relative;
    background: #fff;
}

.upload-area:hover,
.upload-area.drag-over {
    border-color: #0071e3;
    background: #f0f7ff;
}

.upload-area input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.upload-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    pointer-events: none;
}

.upload-icon {
    font-size: 36px;
    color: #86868b;
    font-weight: 300;
    width: 64px;
    height: 64px;
    border: 2px solid #d2d2d7;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
}

.upload-text {
    font-size: 16px;
    font-weight: 500;
}

.upload-hint {
    font-size: 13px;
    color: #86868b;
}

/* File preview */
.file-preview {
    display: flex;
    align-items: center;
    gap: 16px;
    justify-content: center;
}

.file-preview img {
    max-width: 120px;
    max-height: 120px;
    border-radius: 8px;
    object-fit: cover;
}

#preview-name {
    font-size: 14px;
    font-weight: 500;
    color: #1d1d1f;
}

/* Engine selection */
.engine-select {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 24px;
}

.engine-option {
    cursor: pointer;
}

.engine-option input[type="radio"] {
    display: none;
}

.engine-card {
    border: 2px solid #d2d2d7;
    border-radius: 12px;
    padding: 16px;
    text-align: center;
    transition: border-color 0.2s, background 0.2s;
    background: #fff;
}

.engine-card strong {
    display: block;
    font-size: 15px;
    margin-bottom: 4px;
}

.engine-card span {
    font-size: 13px;
    color: #86868b;
}

.engine-option input:checked + .engine-card {
    border-color: #0071e3;
    background: #f0f7ff;
}

/* API key input */
.api-key-section {
    margin-top: 16px;
    background: #fff;
    border: 1px solid #d2d2d7;
    border-radius: 12px;
    padding: 16px;
}

.api-key-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
}

.api-key-section input[type="password"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d2d2d7;
    border-radius: 8px;
    font-size: 14px;
    font-family: ui-monospace, monospace;
    background: #f5f5f7;
    outline: none;
    transition: border-color 0.2s;
}

.api-key-section input[type="password"]:focus {
    border-color: #0071e3;
    background: #fff;
}

.api-key-hint {
    margin-top: 8px;
    font-size: 12px;
    color: #86868b;
}

.api-key-hint a {
    color: #0071e3;
    text-decoration: none;
}

.api-key-hint a:hover {
    text-decoration: underline;
}

/* Process button */
.btn-process {
    display: block;
    width: 100%;
    margin-top: 24px;
    padding: 14px;
    background: #0071e3;
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-process:hover {
    background: #0077ed;
}

.btn-process:disabled {
    background: #86868b;
    cursor: not-allowed;
}

/* Loading overlay */
.overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(245, 245, 247, 0.92);
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 20px;
    z-index: 100;
    backdrop-filter: blur(8px);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #d2d2d7;
    border-top-color: #0071e3;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loading-text {
    font-size: 16px;
    color: #86868b;
    font-weight: 500;
}

/* Results */
.results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid #d2d2d7;
}

.results-header p {
    font-size: 15px;
}

.results-actions {
    display: flex;
    gap: 10px;
}

.btn-download-all,
.btn-new {
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: background 0.2s;
}

.btn-download-all {
    background: #0071e3;
    color: #fff;
}

.btn-download-all:hover {
    background: #0077ed;
}

.btn-new {
    background: #e8e8ed;
    color: #1d1d1f;
}

.btn-new:hover {
    background: #d2d2d7;
}

/* Results grid */
.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.result-card {
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #e8e8ed;
    transition: box-shadow 0.2s;
}

.result-card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.result-card img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    display: block;
}

.result-info {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.result-name {
    font-size: 14px;
    font-weight: 500;
}

.btn-download {
    font-size: 13px;
    color: #0071e3;
    text-decoration: none;
    font-weight: 500;
}

.btn-download:hover {
    text-decoration: underline;
}

.result-error {
    width: 100%;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f5f5f7;
    color: #86868b;
    font-size: 14px;
}

/* Hanger mode toggle */
.hanger-mode-section {
    margin-top: 16px;
    background: #fff;
    border: 1px solid #d2d2d7;
    border-radius: 12px;
    padding: 16px;
}

.hanger-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

.hanger-toggle input[type="checkbox"] {
    display: none;
}

.toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
    background: #d2d2d7;
    border-radius: 12px;
    transition: background 0.2s;
    flex-shrink: 0;
}

.toggle-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.hanger-toggle input:checked + .toggle-switch {
    background: #0071e3;
}

.hanger-toggle input:checked + .toggle-switch::after {
    transform: translateX(20px);
}

.toggle-label strong {
    display: block;
    font-size: 14px;
    font-weight: 600;
}

.toggle-label span {
    font-size: 12px;
    color: #86868b;
}

/* Responsive */
@media (max-width: 600px) {
    .container {
        padding: 24px 16px;
    }

    .engine-select {
        grid-template-columns: 1fr;
    }

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

    .results-header {
        flex-direction: column;
        align-items: flex-start;
    }
}
