/* --- ЦВЕТОВЫЕ СХЕМЫ --- */
:root {
    --font-family: 'Manrope', sans-serif;
    --header-font: 'Inter', sans-serif;
    --accent-blue: #007AFF;
    --status-sent: rgba(0, 122, 255, 0.2);
    --status-sent-text: #007AFF;

    /* --- ИКОНКИ ДЛЯ ТЕМНОЙ ТЕМЫ --- */
    --icon-home: url('images/icon-home-dark.svg');
    --icon-catalog: url('images/icon-catalog-dark.svg');
    --icon-cart: url('images/icon-cart-dark.svg');
    --icon-profile: url('images/icon-profile-dark.svg');
    --icon-telegram: url('images/icon-telegram-dark.svg');
    --icon-services: url('images/icon-services-dark.svg');
    
    /* По умолчанию: ТЕМНАЯ ТЕМА */
    --background-color: #121212;
    --text-color: #FFFFFF;
    --text-color-muted: rgba(228, 228, 235, 0.6);
    --glass-bg: rgba(28, 28, 30, 0.7);
    --glass-border: rgba(80, 80, 80, 0.4);
    --tab-bar-bg: rgba(30, 30, 30, 0.85);
    --profile-card-bg: #1C1C1E;
    --action-button-hover: #0056b3;
    --switch-bg: #303136;
    --switch-handle-shadow: inset -3px -2px 5px -2px #8983f7, inset -10px -4px 0 0 #a3dafb;
    --switch-handle-bg: #303136;
    --banner-image: url('images/banner-dark.jpg');
}

body.light-theme {
    /* --- ИКОНКИ ДЛЯ СВЕТЛОЙ ТЕМЫ --- */
    --icon-home: url('images/icon-home-light.svg');
    --icon-catalog: url('images/icon-catalog-light.svg');
    --icon-cart: url('images/icon-cart-light.svg');
    --icon-profile: url('images/icon-profile-light.svg');
    --icon-telegram: url('images/icon-telegram-light.svg');
    --icon-services: url('images/icon-services-light.svg');

    /* СВЕТЛАЯ ТЕМА */
    --background-color: #F2F2F7;
    --text-color: #000000;
    --text-color-muted: rgba(60, 60, 67, 0.6);
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(180, 180, 180, 0.5);
    --tab-bar-bg: rgba(249, 249, 249, 0.85);
    --profile-card-bg: #FFFFFF;
    --action-button-hover: #0062cc;
    --switch-bg: #e9e9eb;
    --switch-handle-shadow: none;
    --switch-handle-bg: linear-gradient(40deg, #ff0080, #ff8c00 70%);
    --banner-image: url('images/banner-light.jpg');
}

body {
    background-color: var(--background-color);
    color: var(--text-color);
    font-family: var(--font-family);
    margin: 0;
    padding: 0;
    overflow: hidden;
    height: 100vh;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* --- СТИЛИ ЗАГРУЗЧИКА --- */
.loader-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: "Inter", sans-serif;
    font-size: 1.2em;
    font-weight: 300;
    color: white;
    background-color: #121212;
    z-index: 100;
    user-select: none;
    transition: opacity 0.5s ease;
}

.loader {
    position: absolute;
    width: 180px;
    height: 180px;
    border-radius: 50%;
    animation: loader-rotate 2s linear infinite;
}

@keyframes loader-rotate {
    0% {
        transform: rotate(90deg);
        box-shadow: 0 10px 20px 0 #fff inset, 0 20px 30px 0 #ad5fff inset, 0 60px 60px 0 #471eec inset;
    }
    50% {
        transform: rotate(270deg);
        box-shadow: 0 10px 20px 0 #fff inset, 0 20px 10px 0 #d60a47 inset, 0 40px 60px 0 #311e80 inset;
    }
    100% {
        transform: rotate(450deg);
        box-shadow: 0 10px 20px 0 #fff inset, 0 20px 30px 0 #ad5fff inset, 0 60px 60px 0 #471eec inset;
    }
}

.loader-letter {
    display: inline-block;
    opacity: 0.4;
    animation: loader-letter-anim 2s infinite;
    z-index: 1;
}

.loader-letter:nth-child(1) { animation-delay: 0s; }
.loader-letter:nth-child(2) { animation-delay: 0.1s; }
.loader-letter:nth-child(3) { animation-delay: 0.2s; }
.loader-letter:nth-child(4) { animation-delay: 0.3s; }
.loader-letter:nth-child(5) { animation-delay: 0.4s; }
.loader-letter:nth-child(6) { animation-delay: 0.5s; }
.loader-letter:nth-child(7) { animation-delay: 0.6s; }
.loader-letter:nth-child(8) { animation-delay: 0.7s; }
.loader-letter:nth-child(9) { animation-delay: 0.8s; }
.loader-letter:nth-child(10) { animation-delay: 0.9s; }

@keyframes loader-letter-anim {
    0%,
    100% {
        opacity: 0.4;
        transform: translateY(0);
    }
    20% {
        opacity: 1;
        transform: scale(1.15);
    }
    40% {
        opacity: 0.7;
        transform: translateY(0);
    }
}

/* --- ОБЩАЯ СТРУКТУРА --- */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    box-sizing: border-box;
}

.app-header {
    padding: 15px 15px 0 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-shrink: 0;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
}

.avatar-placeholder {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--glass-bg);
    flex-shrink: 0;
}

#user-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
}

#user-name {
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pages-container {
    flex-grow: 1;
    overflow-y: auto;
    position: relative;
    -webkit-overflow-scrolling: touch;
    padding: 0 15px;
}

.pages-container::-webkit-scrollbar {
    display: none;
}

.page {
    display: none;
    flex-direction: column;
    gap: 16px;
    padding-bottom: 95px;
}

.page.active {
    display: flex;
}

.page-title {
    font-family: var(--header-font);
    font-size: 28px;
    font-weight: 600;
    margin: 0 0 10px 0;
}

.page-description {
    font-size: 15px;
    color: var(--text-color-muted);
    line-height: 1.6;
    margin-top: -15px;
}

.section-title {
    font-family: var(--header-font);
    font-size: 18px;
    font-weight: 500;
    color: var(--text-color);
    text-align: left;
    margin-top: 10px;
    margin-bottom: 0px;
}

/* --- СТИЛИ БАННЕРА --- */
.banner-placeholder {
    width: 100%;
    height: 150px;
    border-radius: 16px;
    background-image: var(--banner-image);
    background-size: cover;
    background-position: center;
    flex-shrink: 0;
    cursor: default;
    border: 1px solid var(--glass-border);
    box-sizing: border-box;
    transition: background-image 0.3s ease-in-out;
}

/* --- СТИЛИ КНОПОК И СПИСКОВ --- */
.home-actions-grid-top {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.list-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.glass-button {
    background-color: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 1rem 1.2rem;
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--text-color);
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.glass-button:active {
    background-color: rgba(128, 128, 128, 0.2);
}

.glass-button h3 {
    font-family: var(--header-font);
    font-size: 16px;
    font-weight: 600;
    margin: 0;
    flex-grow: 1;
    text-align: left;
    color: var(--text-color);
}

.glass-button span {
    font-size: 16px;
    font-weight: 500;
    text-align: left;
}

.glass-button .arrow {
    font-size: 20px;
    color: var(--text-color-muted);
}

.glass-button.list-item {
    padding: 1.1rem 1.5rem;
}

.glass-button.soon {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
}

/* --- СТРАНИЦА ДЕТАЛЕЙ УСЛУГИ --- */
#page-service-detail {
    padding-bottom: 175px;
}

#service-description {
    color: var(--text-color-muted);
    line-height: 1.6;
    margin: 0;
}

.advantages-list {
    list-style: none;
    padding: 0;
    margin: 20px 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.advantages-list li {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 15px;
}

.advantages-list li::before {
    content: '✓';
    color: var(--accent-blue);
    font-weight: bold;
}

#service-options-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 10px;
}

.service-option {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
}

.service-option.selected {
    border-color: var(--accent-blue);
    background-color: rgba(0, 122, 255, 0.2);
}

.option-name {
    font-weight: 500;
}

.option-price {
    color: var(--text-color-muted);
}

.spacer {
    flex-grow: 1;
}

.add-to-cart-bar {
    position: fixed;
    bottom: calc(75px + env(safe-area-inset-bottom));
    left: 15px;
    right: 15px;
    display: flex;
    gap: 15px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 10px;
    border-radius: 16px;
    align-items: center;
    z-index: 5;
}

.price-display {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 0 10px;
}

#total-price-label {
    font-size: 12px;
    color: var(--text-color-muted);
}

#total-price-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-color);
}

/* --- ОБЩИЕ КНОПКИ ДЕЙСТВИЙ --- */
.action-button {
    display: block;
    width: 100%;
    padding: 15px;
    background-color: var(--accent-blue);
    color: white;
    text-decoration: none;
    border-radius: 12px;
    font-weight: 700;
    font-family: var(--header-font);
    border: none;
    cursor: pointer;
    transition: background-color 0.3s ease;
    box-sizing: border-box;
}

.action-button:hover {
    background-color: var(--action-button-hover);
}

/* --- СТРАНИЦА КОРЗИНЫ --- */
#cart-items-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.cart-item {
    padding: 16px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.cart-item-main {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.cart-item-name {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 4px;
}

.cart-item-price {
    font-size: 14px;
    color: var(--text-color-muted);
}

.cart-item-options {
    list-style: none;
    padding: 0;
    margin: 8px 0 0 0;
    font-size: 13px;
    color: var(--text-color-muted);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.cart-item-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.quantity-controls {
    display: flex;
    align-items: center;
    background-color: rgba(128, 128, 128, 0.2);
    border-radius: 8px;
}

.quantity-btn-cart {
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 18px;
    width: 30px;
    height: 30px;
    cursor: pointer;
}

.quantity-cart {
    font-weight: 700;
    padding: 0 5px;
}

.remove-item-btn {
    background-color: rgba(128, 128, 128, 0.2);
    border: none;
    border-radius: 8px;
    color: var(--text-color);
    width: 30px;
    height: 30px;
    font-size: 16px;
    cursor: pointer;
}

#cart-empty-placeholder {
    text-align: center;
    margin-top: 50px;
    color: var(--text-color-muted);
}

#cart-empty-placeholder p {
    font-size: 18px;
    margin-bottom: 20px;
}

#cart-summary-container {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.cart-summary-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 18px;
}

.cart-summary-item.total {
    font-weight: 700;
}

.form-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.payment-options {
    display: flex;
    gap: 10px;
}

.payment-option-btn {
    flex: 1;
    padding: 12px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-color-muted);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.payment-option-btn.active {
    color: var(--text-color);
    border-color: var(--accent-blue);
    background-color: rgba(0, 122, 255, 0.2);
}

.form-input {
    width: 100%;
    padding: 15px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: var(--text-color);
    font-family: var(--font-family);
    font-size: 16px;
    box-sizing: border-box;
}

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

/* --- СТРАНИЦА ПРОФИЛЯ --- */
.profile-card {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 20px;
    background: var(--profile-card-bg);
    border-radius: 16px;
}

.profile-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
}

.profile-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
}

.profile-info {
    display: flex;
    flex-direction: column;
}

.profile-name {
    font-family: var(--header-font);
    font-size: 20px;
    font-weight: 700;
    color: var(--text-color);
}

.profile-desc {
    font-size: 14px;
    color: var(--text-color-muted);
}

/* --- ПЕРЕКЛЮЧАТЕЛЬ ТЕМЫ --- */
.theme-switch {
    display: block;
    --width-of-switch: 3.5em;
    --height-of-switch: 2em;
    --size-of-icon: 1.4em;
    --slider-offset: 0.3em;
    position: relative;
    width: var(--width-of-switch);
    height: var(--height-of-switch);
}

.theme-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.theme-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--switch-bg);
    transition: .4s;
    border-radius: 30px;
}

.theme-slider:before {
    position: absolute;
    content: "";
    height: var(--size-of-icon, 1.4em);
    width: var(--size-of-icon, 1.4em);
    border-radius: 20px;
    left: var(--slider-offset, 0.3em);
    top: 50%;
    transform: translateY(-50%);
    background: var(--switch-handle-bg);
    transition: .4s;
    box-shadow: var(--switch-handle-shadow);
}

input:checked+.theme-slider:before {
    left: calc(100% - (var(--size-of-icon, 1.4em) + var(--slider-offset, 0.3em)));
}

/* --- СТРАНИЦА "МОИ ЗАКАЗЫ" --- */
.order-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
}

.order-details {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.order-name {
    font-weight: 700;
}

.order-date {
    font-size: 13px;
    color: var(--text-color-muted);
}

.order-status {
    font-size: 12px;
    font-weight: bold;
    padding: 4px 8px;
    border-radius: 8px;
}

.order-status.sent {
    background-color: var(--status-sent);
    color: var(--status-sent-text);
}

/* --- TAB BAR --- */
.tab-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: auto;
    min-height: 55px;
    box-sizing: border-box;
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 10px 0;
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
    background: var(--tab-bar-bg);
    border-top: 1px solid var(--glass-border);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 10;
}

.tab-item,
.tab-item-main {
    background: none;
    border: none;
    color: var(--text-color-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    font-size: 10px;
    font-family: var(--font-family);
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
}

.tab-item.active {
    color: var(--accent-blue);
}

.counter {
    position: absolute;
    top: -2px;
    right: -5px;
    background-color: #FF3B30;
    color: white;
    font-size: 9px;
    font-weight: 700;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tab-item-main {
    width: 60px;
    height: 60px;
    background-color: var(--accent-blue);
    border-radius: 50%;
    transform: translateY(-22px);
    color: white;
    justify-content: center;
    box-shadow: 0 5px 15px rgba(0, 122, 255, 0.4);
}

/* --- ИКОНКИ --- */
.icon {
    display: block;
    width: 28px;
    height: 28px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    transition: background-image 0.3s ease-in-out;
}

.glass-button .icon {
    width: 24px;
    height: 24px;
}

.icon-home {
    background-image: var(--icon-home);
}

.icon-catalog {
    background-image: var(--icon-catalog);
}

.icon-cart {
    background-image: var(--icon-cart);
}

.icon-profile {
    background-image: var(--icon-profile);
}

.icon-telegram {
    background-image: var(--icon-telegram);
}

.icon-services {
    background-image: var(--icon-services);
}


/* --- МОДАЛЬНЫЕ ОКНА --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal-content {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 24px;
    text-align: center;
    max-width: 300px;
    margin: 20px;
}

.modal-content h2 {
    margin-top: 0;
    font-family: var(--header-font);
}

.modal-content p {
    color: var(--text-color-muted);
}

.modal-button {
    display: block;
    width: 100%;
    padding: 15px;
    background-color: var(--accent-blue);
    color: white;
    text-decoration: none;
    border-radius: 12px;
    font-weight: 700;
    margin: 20px 0 0 0;
    font-family: var(--header-font);
    box-sizing: border-box;
    border: none;
    cursor: pointer;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-color-muted);
    font-size: 16px;
    cursor: pointer;
    font-family: var(--font-family);
    margin-top: 15px;
}

#modal-success .success-icon {
    font-size: 48px;
    margin-bottom: 15px;
}