/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary: #3D9BD1;
    --primary-dark: #1A6FA8;
    --bg: #F4F6FA;
    --card-bg: #FFFFFF;
    --text: #1A1A2E;
    --text-muted: #6B7280;
    --border: #E5E7EB;
    --radius: 16px;
    --shadow: 0 2px 12px rgba(0,0,0,0.08);
    --nav-height: 64px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    padding-bottom: var(--nav-height);
    -webkit-font-smoothing: antialiased;
}

#app { min-height: calc(100vh - var(--nav-height)); }

/* ===== SCREENS ===== */
.screen { display: none; }
.screen.active { display: block; }

/* ===== LOADING ===== */
.loading-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 60vh;
    gap: 16px;
    color: var(--text-muted);
}

.spinner {
    width: 40px; height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== HEADER ===== */
.app-header {
    background: var(--card-bg);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 1px 0 var(--border);
    position: sticky; top: 0; z-index: 10;
}
.app-header h1 { font-size: 18px; font-weight: 700; }
.app-header .user-name { font-size: 13px; color: var(--text-muted); }

/* ===== BOTTOM NAV ===== */
.bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0;
    height: var(--nav-height);
    background: var(--card-bg);
    border-top: 1px solid var(--border);
    display: flex;
    z-index: 100;
}
.nav-btn {
    flex: 1;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 4px;
    background: none; border: none; cursor: pointer;
    color: var(--text-muted);
    transition: color 0.2s;
    -webkit-tap-highlight-color: transparent;
}
.nav-btn.active { color: var(--primary); }
.nav-icon { font-size: 20px; }
.nav-label { font-size: 11px; font-weight: 600; }

/* ===== DASHBOARD ===== */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding: 16px;
}
.tool-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px 16px;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    border: 2px solid transparent;
    text-align: center;
    -webkit-tap-highlight-color: transparent;
}
.tool-card:active { transform: scale(0.97); }
.tool-card.disabled { opacity: 0.5; cursor: not-allowed; }
.tool-card .tool-icon { font-size: 36px; margin-bottom: 10px; }
.tool-card .tool-name { font-size: 14px; font-weight: 700; margin-bottom: 4px; }
.tool-card .tool-desc { font-size: 12px; color: var(--text-muted); line-height: 1.4; }
.tool-card .tool-badge {
    display: inline-block;
    margin-top: 8px;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 10px;
    font-weight: 700;
    background: #E8F4FD;
    color: var(--primary);
}
.tool-card.disabled .tool-badge {
    background: #F3F4F6;
    color: var(--text-muted);
}

/* ===== ФОРМА ГЕНЕРАТОРА ===== */
.screen-inner {
    padding: 16px;
    max-width: 600px;
    margin: 0 auto;
}
.back-btn {
    display: flex; align-items: center; gap: 8px;
    background: none; border: none; cursor: pointer;
    color: var(--primary); font-size: 15px; font-weight: 600;
    padding: 8px 0; margin-bottom: 8px;
    -webkit-tap-highlight-color: transparent;
}

.form-section {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
}
.form-section-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.form-group { margin-bottom: 12px; }
.form-group:last-child { margin-bottom: 0; }
.form-label {
    display: block;
    font-size: 13px; font-weight: 600;
    margin-bottom: 6px;
    color: var(--text);
}
.form-label .required { color: #EF4444; margin-left: 2px; }

.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-size: 15px;
    font-family: inherit;
    color: var(--text);
    background: var(--bg);
    transition: border-color 0.2s;
    -webkit-appearance: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    background: #fff;
}
.form-textarea { resize: vertical; min-height: 80px; }

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

/* ===== ЗАГРУЗКА ФАЙЛА ===== */
.upload-area {
    border: 2px dashed var(--border);
    border-radius: 10px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}
.upload-area:hover, .upload-area.dragover {
    border-color: var(--primary);
    background: #EBF5FB;
}
.upload-area .upload-icon { font-size: 32px; margin-bottom: 8px; }
.upload-area .upload-text { font-size: 14px; color: var(--text-muted); }
.upload-area .upload-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.upload-preview {
    display: flex; align-items: center; gap: 12px;
    margin-top: 10px;
}
.upload-preview img {
    width: 60px; height: 60px;
    object-fit: cover; border-radius: 8px;
    border: 1px solid var(--border);
}
.upload-preview .preview-info { font-size: 13px; color: var(--text-muted); }
.upload-preview .remove-btn {
    margin-left: auto;
    background: none; border: none; cursor: pointer;
    color: #EF4444; font-size: 20px;
}

/* ===== ЦВЕТОВЫЕ СХЕМЫ ===== */
.color-schemes {
    display: flex; gap: 12px; flex-wrap: wrap;
}
.color-dot {
    width: 40px; height: 40px;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid transparent;
    transition: transform 0.15s, border-color 0.15s;
    position: relative;
}
.color-dot.active {
    border-color: var(--text);
    transform: scale(1.15);
}
.color-dot.active::after {
    content: '✓';
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    color: white; font-size: 16px; font-weight: 700;
}

/* ===== КНОПКИ ===== */
.btn {
    display: block; width: 100%;
    padding: 16px;
    border: none; border-radius: var(--radius);
    font-size: 16px; font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
    -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: white; }
.btn-secondary {
    background: var(--bg); color: var(--text);
    border: 1.5px solid var(--border);
}
.btn-danger { background: #FEF2F2; color: #EF4444; }

.btn-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 10px;
}

/* ===== ЭКРАН РЕЗУЛЬТАТА ===== */
.result-image-wrap {
    width: 100%;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    margin-bottom: 16px;
}
.result-image-wrap img { width: 100%; display: block; }

/* ===== ИСТОРИЯ ===== */
.history-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding: 16px;
}
.history-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    position: relative;
}
.history-card img {
    width: 100%; aspect-ratio: 4/5;
    object-fit: cover; display: block;
}
.history-card .card-info {
    padding: 8px 10px;
}
.history-card .card-jk { font-size: 12px; font-weight: 700; }
.history-card .card-date { font-size: 11px; color: var(--text-muted); }
.history-card .card-expires {
    font-size: 10px; color: #F59E0B;
    margin-top: 2px;
}
.history-card .delete-btn {
    position: absolute; top: 6px; right: 6px;
    background: rgba(0,0,0,0.5);
    border: none; border-radius: 50%;
    width: 28px; height: 28px;
    color: white; font-size: 14px;
    cursor: pointer; display: flex;
    align-items: center; justify-content: center;
}

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 56px; margin-bottom: 16px; }
.empty-state .empty-title { font-size: 18px; font-weight: 700; margin-bottom: 8px; color: var(--text); }
.empty-state .empty-desc { font-size: 14px; line-height: 1.5; }

/* ===== TOAST ===== */
.toast {
    position: fixed; bottom: calc(var(--nav-height) + 16px); left: 16px; right: 16px;
    background: #1A1A2E; color: white;
    padding: 14px 18px; border-radius: 12px;
    font-size: 14px; font-weight: 500;
    z-index: 999;
    transform: translateY(20px); opacity: 0;
    transition: transform 0.3s, opacity 0.3s;
    text-align: center;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.error { background: #EF4444; }
.toast.success { background: #10B981; }

/* ===== АДАПТИВ ===== */
@media (max-width: 360px) {
    .dashboard-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
    .form-row { grid-template-columns: 1fr; }
    .history-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
}
