/* ============================================
   Lost & Found Poster Generator - Styles (AI版)
   ============================================ */

:root {
    --bg: #F2F2F7;
    --card: #FFFFFF;
    --text-primary: #1C1C1E;
    --text-secondary: #8E8E93;
    --text-tertiary: #AEAEB2;
    --accent: #FF9500;
    --accent-hover: #E68600;
    --accent-light: #FFF5EB;
    --accent-bg: rgba(255,149,0,0.08);
    --border: #E5E5EA;
    --border-light: #F2F2F7;
    --danger: #FF3B30;
    --danger-bg: rgba(255,59,48,0.08);
    --success: #34C759;
    --radius-lg: 20px;
    --radius: 14px;
    --radius-sm: 10px;
    --radius-xs: 8px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.06);
    --shadow: 0 2px 8px rgba(0,0,0,0.06), 0 4px 16px rgba(0,0,0,0.04);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.08), 0 2px 8px rgba(0,0,0,0.04);
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --header-height: 56px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

#app {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100vh;
    min-height: 100dvh;
    position: relative;
}

/* ---- Header ---- */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    height: calc(var(--header-height) + var(--safe-top));
    padding-top: var(--safe-top);
    background: var(--card);
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 0.5px solid var(--border-light);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    display: flex;
    align-items: center;
}

.header h1 {
    font-size: 19px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.ai-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    color: white;
    background: linear-gradient(135deg, #FF9500, #FF6B00);
    padding: 2px 8px;
    border-radius: 100px;
    letter-spacing: 0.5px;
    vertical-align: middle;
}

.store-selector {
    display: flex;
    align-items: center;
    gap: 2px;
}

.store-selector select {
    appearance: none;
    -webkit-appearance: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px 30px 6px 12px;
    font-size: 13px;
    font-weight: 500;
    background-color: var(--bg);
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 12 12' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3 5l3 3 3-3' stroke='%238E8E93' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    color: var(--text-primary);
    max-width: 130px;
    cursor: pointer;
    transition: border-color 0.2s;
}

.store-selector select:focus {
    outline: none;
    border-color: var(--accent);
}

.icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
}

.icon-btn:active {
    background: var(--bg);
    transform: scale(0.92);
}

/* ---- Main ---- */
.main {
    padding: 16px 20px;
    padding-bottom: calc(24px + var(--safe-bottom));
}

/* ---- Steps ---- */
.step {
    display: none;
    animation: fadeIn 0.3s ease;
}

.step.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.step-hint {
    font-size: 14px;
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 16px;
    padding-left: 2px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 6px;
    background: var(--accent);
    color: white;
    font-size: 11px;
    font-weight: 800;
    flex-shrink: 0;
}

.ai-source {
    font-size: 12px;
    font-weight: 400;
    color: var(--text-tertiary);
    margin-left: auto;
}

/* ---- Upload Zone ---- */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    background: var(--card);
    padding: 48px 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 0;
}

.upload-zone:active,
.upload-zone.dragover {
    border-color: var(--accent);
    background: var(--accent-bg);
    transform: scale(0.98);
}

.upload-zone-inner {
    pointer-events: none;
}

.upload-icon-wrap {
    margin-bottom: 16px;
}

.upload-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.upload-hint {
    font-size: 13px;
    color: var(--text-secondary);
}

/* ---- Recognizing State ---- */
.recognizing-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
    background: var(--card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    margin-bottom: 0;
}

.recognizing-card img {
    width: 100%;
    max-height: 280px;
    object-fit: contain;
    border-radius: var(--radius);
    margin-bottom: 24px;
    background: #f8f8f8;
}

.ai-spinner {
    position: relative;
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}

.spinner-ring {
    position: absolute;
    inset: 0;
    border: 3px solid var(--border-light);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.ai-eye-icon {
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.8; }
}

.recognizing-text {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.recognizing-hint {
    font-size: 13px;
    color: var(--text-secondary);
}

/* ---- AI Result Banner ---- */
.ai-result-banner {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: var(--accent-bg);
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--accent-hover);
}

.ai-result-banner svg {
    flex-shrink: 0;
}

.ai-result-banner span {
    flex: 1;
}

.btn-clear-ai {
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    background: var(--card);
    color: var(--text-secondary);
    font-size: 12px;
    padding: 4px 10px;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
    transition: all 0.2s;
}

.btn-clear-ai:active {
    background: var(--bg);
}

.ai-tag {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    color: var(--accent);
    background: var(--accent-bg);
    padding: 1px 6px;
    border-radius: 4px;
    margin-left: 6px;
    vertical-align: middle;
}

/* ---- Image Card ---- */
.image-card {
    position: relative;
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--card);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

.image-card img {
    display: block;
    width: 100%;
    max-height: 360px;
    object-fit: contain;
    background: #f8f8f8;
}

/* ---- Form ---- */
.form-section {
    margin-bottom: 20px;
}

.form-item {
    margin-bottom: 16px;
}

.form-item.compact {
    margin-bottom: 12px;
}

.form-label {
    display: flex;
    align-items: center;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.optional {
    font-weight: 400;
    color: var(--text-tertiary);
    font-size: 12px;
}

.form-input {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 15px;
    color: var(--text-primary);
    background: var(--card);
    transition: all 0.2s;
    font-family: inherit;
}

.form-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-bg);
}

.form-input::placeholder {
    color: var(--text-tertiary);
}

.form-textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 15px;
    color: var(--text-primary);
    background: var(--card);
    resize: none;
    transition: all 0.2s;
    font-family: inherit;
    line-height: 1.5;
}

.form-textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-bg);
}

.form-textarea::placeholder {
    color: var(--text-tertiary);
}

/* ---- Category Grid ---- */
.category-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.category-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 8px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--card);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-family: inherit;
}

.category-btn .cat-icon {
    font-size: 16px;
    flex-shrink: 0;
}

.category-btn:active {
    transform: scale(0.96);
}

.category-btn.selected {
    border-color: var(--accent);
    background: var(--accent-light);
    color: var(--accent-hover);
    font-weight: 600;
}

/* ---- Buttons ---- */
.btn-primary {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 14px 24px;
    border: none;
    border-radius: var(--radius);
    background: var(--accent);
    color: white;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    letter-spacing: 0.2px;
}

.btn-primary:active {
    background: var(--accent-hover);
    transform: scale(0.98);
}

.btn-primary:disabled {
    opacity: 0.5;
    pointer-events: none;
}

.btn-secondary {
    flex: 1;
    padding: 12px 16px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    background: var(--card);
    color: var(--text-primary);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.btn-secondary:active {
    background: var(--bg);
    transform: scale(0.98);
}

.btn-block {
    width: 100%;
}

.btn-row {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

/* ---- Result ---- */
.poster-container {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

.poster-container img {
    width: 100%;
    max-width: 360px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
}

.result-actions {
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* ---- Modal ---- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 200;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    animation: overlayIn 0.25s ease;
}

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

@keyframes overlayIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal {
    background: var(--card);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    width: 100%;
    max-width: 480px;
    max-height: 80vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
    padding-bottom: var(--safe-bottom);
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 20px 0;
}

.modal-header h2 {
    font-size: 18px;
    font-weight: 700;
}

.btn-close {
    width: 30px;
    height: 30px;
    border: none;
    background: var(--bg);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 18px;
    transition: all 0.2s;
}

.btn-close:active {
    transform: scale(0.9);
    background: var(--border);
}

.modal-body {
    padding: 16px 20px 24px;
}

.divider {
    height: 1px;
    background: var(--border-light);
    margin: 16px 0;
}

.store-form h3 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-secondary);
}

/* ---- Store List ---- */
.store-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.store-item {
    display: flex;
    align-items: center;
    padding: 12px 14px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    gap: 12px;
}

.store-item.selected-store {
    background: var(--accent-bg);
    border: 1px solid var(--accent);
}

.store-info {
    flex: 1;
    min-width: 0;
}

.store-info .store-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.store-info .store-detail {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.store-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.store-actions button {
    width: 30px;
    height: 30px;
    border: none;
    border-radius: var(--radius-xs);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.store-actions .btn-edit {
    background: var(--accent-bg);
    color: var(--accent);
}

.store-actions .btn-delete {
    background: var(--danger-bg);
    color: var(--danger);
}

.store-actions button:active {
    transform: scale(0.9);
}

/* ---- Toast ---- */
.toast {
    position: fixed;
    top: calc(var(--header-height) + var(--safe-top) + 16px);
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    background: rgba(28,28,30,0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: white;
    padding: 10px 20px;
    border-radius: 100px;
    font-size: 14px;
    font-weight: 500;
    z-index: 300;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
    white-space: nowrap;
}

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

.toast.hidden {
    display: block;
}

/* ---- Empty State ---- */
.empty-state {
    text-align: center;
    padding: 20px;
    color: var(--text-secondary);
    font-size: 14px;
}

/* ---- Settings ---- */
.settings-section h3 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-primary);
}

.settings-desc {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.settings-desc a {
    color: var(--accent);
    text-decoration: none;
}

.settings-desc a:active {
    text-decoration: underline;
}

/* ---- Responsive ---- */
@media (max-width: 360px) {
    .category-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }
    .category-btn {
        padding: 8px 6px;
        font-size: 12px;
    }
    .upload-zone {
        padding: 36px 16px;
    }
}

@media (min-width: 481px) {
    #app {
        box-shadow: 0 0 60px rgba(0,0,0,0.06);
        background: var(--card);
    }
}
