/* ─── Base & Telegram Theme ─── */
:root {
    --bg: var(--tg-theme-bg-color, #ffffff);
    --text: var(--tg-theme-text-color, #1a1a2e);
    --hint: var(--tg-theme-hint-color, #999999);
    --link: var(--tg-theme-link-color, #2481cc);
    --btn: var(--tg-theme-button-color, #5b2c8e);
    --btn-text: var(--tg-theme-button-text-color, #ffffff);
    --secondary-bg: var(--tg-theme-secondary-bg-color, #f0f0f5);
    --card-shadow: 0 2px 16px rgba(0, 0, 0, 0.08);
    --card-radius: 16px;
    --accent-gradient: linear-gradient(135deg, #7c3aed, #a855f7);
    --accent-gradient-hover: linear-gradient(135deg, #6d28d9, #9333ea);
    --cancel-gradient: linear-gradient(135deg, #ef4444, #f97316);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ─── Pages ─── */
.page {
    display: none;
    animation: fadeIn 0.3s ease;
}

.page.active {
    display: block;
}

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

@keyframes slideIn {
    from { opacity: 0; transform: translateX(30px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ─── Header ─── */
.header {
    padding: 24px 20px 16px;
    text-align: center;
}

.header h1 {
    font-size: 24px;
    font-weight: 800;
    line-height: 1.2;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    margin-top: 8px;
    color: var(--hint);
    font-size: 14px;
}

/* ─── Studios Grid ─── */
.studios-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 8px 16px 24px;
}

/* ─── Studio Card ─── */
.studio-card {
    background: var(--secondary-bg);
    border-radius: var(--card-radius);
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: var(--card-shadow);
    position: relative;
}

.studio-card:active {
    transform: scale(0.97);
}

.studio-card .card-image {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    display: block;
}

.studio-card .card-body {
    padding: 10px 12px 12px;
}

.studio-card .card-name {
    font-size: 13px;
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.studio-card .card-address {
    font-size: 11px;
    color: var(--hint);
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.studio-card .card-rating {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 3px;
    backdrop-filter: blur(4px);
}

.studio-card .card-rating::before {
    content: "★";
    color: #fbbf24;
}

.studio-card .card-votes {
    font-size: 11px;
    color: var(--link);
    margin-top: 4px;
    font-weight: 600;
}

.voted-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background: var(--accent-gradient);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 20px;
    backdrop-filter: blur(4px);
}

/* ─── Studio Detail ─── */
.studio-detail {
    animation: slideIn 0.3s ease;
}

.studio-hero {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    overflow: hidden;
}

.studio-hero img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.back-btn {
    position: absolute;
    top: 12px;
    left: 12px;
    width: 40px;
    height: 40px;
    background: rgba(0, 0, 0, 0.5);
    border: none;
    border-radius: 50%;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    backdrop-filter: blur(4px);
    transition: background 0.2s;
}

.back-btn:active {
    background: rgba(0, 0, 0, 0.7);
}

.studio-content {
    padding: 20px 16px 32px;
}

.studio-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.studio-header-row h2 {
    font-size: 22px;
    font-weight: 800;
}

.rating-badge {
    background: var(--accent-gradient);
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 20px;
    white-space: nowrap;
    flex-shrink: 0;
}

.studio-desc {
    font-size: 14px;
    line-height: 1.6;
    color: var(--hint);
    margin-bottom: 20px;
}

/* ─── Info Cards ─── */
.info-cards {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 24px;
}

.info-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: var(--secondary-bg);
    border-radius: 12px;
}

.info-icon {
    width: 40px;
    height: 40px;
    background: var(--accent-gradient);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #fff;
}

.info-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.info-label {
    font-size: 11px;
    color: var(--hint);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.info-value {
    font-size: 14px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.phone-link {
    color: var(--link);
    text-decoration: none;
}

/* ─── QR Section ─── */
.qr-section {
    text-align: center;
    margin-bottom: 24px;
    padding: 20px;
    background: var(--secondary-bg);
    border-radius: 16px;
}

.qr-title {
    font-size: 13px;
    color: var(--hint);
    margin-bottom: 16px;
    font-weight: 600;
}

.qr-container {
    display: inline-block;
    padding: 12px;
    background: #fff;
    border-radius: 12px;
}

.qr-container img,
.qr-container canvas {
    display: block;
    width: 200px;
    height: 200px;
}

.qr-buttons {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-top: 14px;
}

.qr-download-btn,
.qr-share-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s ease, opacity 0.15s ease;
}

.qr-download-btn {
    background: var(--accent-gradient);
}

.qr-share-btn {
    background: linear-gradient(135deg, #2481cc, #3b9be0);
}

.qr-download-btn:active,
.qr-share-btn:active {
    transform: scale(0.97);
}

/* ─── Vote Section ─── */
.vote-section {
    text-align: center;
    margin-top: 24px;
    margin-bottom: 24px;
}

.vote-count {
    font-size: 14px;
    color: var(--hint);
    margin-bottom: 12px;
    font-weight: 600;
}

.vote-btn {
    width: 100%;
    padding: 16px 24px;
    border: none;
    border-radius: 14px;
    font-size: 16px;
    font-weight: 700;
    color: var(--btn-text);
    background: var(--accent-gradient);
    cursor: pointer;
    transition: transform 0.15s ease, opacity 0.15s ease;
    position: relative;
    overflow: hidden;
}

.vote-btn:active {
    transform: scale(0.97);
}

.vote-btn.voted {
    background: var(--cancel-gradient);
}

.vote-btn.loading {
    opacity: 0.7;
    pointer-events: none;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.vote-btn.just-voted {
    animation: pulse 0.4s ease;
}

/* ─── Loader ─── */
.loader {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 60px 20px;
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--secondary-bg);
    border-top-color: var(--btn);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ─── Not Found Section ─── */
.not-found-section {
    text-align: center;
    padding: 20px 16px 32px;
    margin-top: 8px;
}

.not-found-text {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 4px;
}

.not-found-hint {
    font-size: 13px;
    color: var(--hint);
    margin-bottom: 14px;
}

.not-found-btn {
    display: inline-block;
    padding: 12px 28px;
    background: var(--accent-gradient);
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.15s ease;
}

.not-found-btn:active {
    transform: scale(0.97);
}

/* ─── Application Form ─── */
.app-form-wrapper {
    padding: 16px;
    animation: slideIn 0.3s ease;
}

.app-form-header {
    margin-bottom: 20px;
}

.app-form-header h2 {
    font-size: 22px;
    font-weight: 800;
    margin-top: 12px;
    margin-bottom: 4px;
}

.back-btn-inline {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    color: var(--link);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 0;
}

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

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text);
}

.form-label .req {
    color: #ef4444;
}

.form-input {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid var(--secondary-bg);
    border-radius: 12px;
    font-size: 14px;
    font-family: inherit;
    background: var(--secondary-bg);
    color: var(--text);
    outline: none;
    transition: border-color 0.2s;
}

.form-input:focus {
    border-color: var(--btn);
}

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

.phone-input-wrapper {
    display: flex;
    align-items: center;
    background: var(--secondary-bg);
    border: 2px solid var(--secondary-bg);
    border-radius: 12px;
    transition: border-color 0.2s;
}

.phone-input-wrapper:focus-within {
    border-color: var(--btn);
}

.phone-prefix {
    padding: 12px 0 12px 14px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    user-select: none;
}

.phone-input-wrapper .phone-input {
    border: none;
    background: transparent;
    padding-left: 6px;
}

.phone-input-wrapper .phone-input:focus {
    border-color: transparent;
}

.form-divider {
    height: 1px;
    background: var(--secondary-bg);
    margin: 20px 0;
}

/* ─── Admin FAB Button ─── */
.admin-fab {
    position: fixed;
    top: 12px;
    left: 12px;
    width: 40px;
    height: 40px;
    background: var(--accent-gradient);
    border: none;
    border-radius: 50%;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 100;
    box-shadow: 0 2px 12px rgba(124, 58, 237, 0.4);
    transition: transform 0.2s, box-shadow 0.2s;
}

.admin-fab:active {
    transform: scale(0.92);
}

/* ─── Responsive ─── */
@media (min-width: 400px) {
    .header h1 {
        font-size: 28px;
    }
    .studios-grid {
        gap: 14px;
        padding: 8px 20px 28px;
    }
    .studio-card .card-name {
        font-size: 14px;
    }
}