/* assets/css/style.css - Полный iOS дизайн с Glassmorphism и Dark Mode */

/* ===== CSS Variables для светлой и темной темы ===== */
:root {
    /* Светлая тема (по умолчанию) */
    --ios-blue: #007aff;
    --ios-green: #34c759;
    --ios-red: #ff3b30;
    --ios-orange: #ff9500;
    --ios-purple: #af52de;
    --ios-pink: #ff2d55;
    --ios-gray: #8e8e93;
    --ios-light-gray: #f2f2f7;
    --ios-dark-gray: #1c1c1e;
    --ios-background: #ffffff;
    --ios-secondary-background: #f2f2f7;
    --ios-tertiary-background: #ffffff;
    --ios-separator: #c6c6c8;
    --ios-label: #000000;
    --ios-secondary-label: #3c3c43;
    --ios-tertiary-label: #8e8e93;
    
    /* Glassmorphism */
    --glass-background: rgba(255, 255, 255, 0.72);
    --glass-background-dark: rgba(0, 0, 0, 0.72);
    --glass-border: rgba(255, 255, 255, 0.3);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    
    /* Анимации */
    --spring-ease: cubic-bezier(0.34, 1.2, 0.64, 1);
    --smooth-ease: cubic-bezier(0.25, 0.1, 0.25, 1);
    --bounce-ease: cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* Темная тема */
[data-theme="dark"] {
    --ios-background: #000000;
    --ios-secondary-background: #1c1c1e;
    --ios-tertiary-background: #2c2c2e;
    --ios-separator: #38383a;
    --ios-label: #ffffff;
    --ios-secondary-label: #ebebf5;
    --ios-tertiary-label: #8e8e93;
    --glass-background: rgba(28, 28, 30, 0.72);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

/* Автоматическое определение темы */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --ios-background: #000000;
        --ios-secondary-background: #1c1c1e;
        --ios-tertiary-background: #2c2c2e;
        --ios-separator: #38383a;
        --ios-label: #ffffff;
        --ios-secondary-label: #ebebf5;
        --glass-background: rgba(28, 28, 30, 0.72);
    }
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'SF Pro Display', 'Helvetica Neue', sans-serif;
    background: var(--ios-secondary-background);
    color: var(--ios-label);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color 0.3s ease;
}

/* ===== Glassmorphism Effects ===== */
.glass {
    background: var(--glass-background);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border: 0.5px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
}

.glass-card {
    background: var(--glass-background);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 24px;
    border: 0.5px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

/* ===== iOS Navigation Bar ===== */
.ios-nav {
    background: var(--glass-background);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border-bottom: 0.5px solid var(--ios-separator);
    position: sticky;
    top: 0;
    z-index: 1000;
    transition: all 0.3s ease;
}

.ios-nav-scrolled {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

.ios-nav-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 56px;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 16px;
}

/* Glass Logo */
.ios-logo {
    font-size: 24px;
    font-weight: 700;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
    background-size: 200% 200%;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation: gradientShift 5s ease infinite;
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* ===== Glass Buttons с эффектом капли ===== */
.ios-btn {
    padding: 12px 24px;
    border-radius: 14px;
    font-size: 17px;
    font-weight: 590;
    transition: all 0.3s var(--spring-ease);
    cursor: pointer;
    border: none;
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(10px);
}

/* Эффект капли/риппла */
.ios-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255,255,255,0.4) 0%, rgba(255,255,255,0) 80%);
    transform: translate(-50%, -50%);
    transition: width 0.4s, height 0.4s;
}

.ios-btn:active::before {
    width: 200px;
    height: 200px;
}

.ios-btn-primary {
    background: linear-gradient(135deg, var(--ios-blue), #0055cc);
    color: white;
    box-shadow: 0 4px 15px rgba(0, 122, 255, 0.3);
    border: 0.5px solid rgba(255, 255, 255, 0.3);
}

.ios-btn-primary:active {
    transform: scale(0.96);
    box-shadow: 0 2px 8px rgba(0, 122, 255, 0.4);
}

.ios-btn-secondary {
    background: rgba(120, 120, 128, 0.12);
    color: var(--ios-blue);
    backdrop-filter: blur(10px);
    border: 0.5px solid rgba(0, 122, 255, 0.3);
}

.ios-btn-secondary:active {
    transform: scale(0.96);
    background: rgba(0, 122, 255, 0.15);
}

/* ===== Glass Cards ===== */
.ios-card {
    background: var(--ios-background);
    border-radius: 20px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.03);
    transition: all 0.3s var(--spring-ease);
    border: 0.5px solid var(--ios-separator);
}

.ios-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.ios-card:active {
    transform: scale(0.98);
}

/* Glass Card вариант */
.glass-card {
    background: var(--glass-background);
    backdrop-filter: blur(20px);
    border-radius: 24px;
    padding: 20px;
    border: 0.5px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

/* ===== iOS Modal с жестами ===== */
.ios-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.25s ease-out;
}

.ios-modal-content {
    background: var(--ios-background);
    border-radius: 28px;
    max-width: 400px;
    width: 90%;
    padding: 24px;
    animation: modalSlideUp 0.35s var(--spring-ease);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    max-height: 80vh;
    overflow-y: auto;
}

/* Свайп для закрытия модалки */
.ios-modal[draggable="true"] {
    cursor: grab;
}

.ios-modal[draggable="true"]:active {
    cursor: grabbing;
}

/* ===== iOS Input Fields ===== */
.ios-input, .ios-textarea, .ios-select {
    width: 100%;
    padding: 14px 16px;
    font-size: 17px;
    border: 0.5px solid var(--ios-separator);
    border-radius: 14px;
    background: var(--ios-tertiary-background);
    color: var(--ios-label);
    transition: all 0.2s var(--smooth-ease);
    margin-bottom: 16px;
}

.ios-input:focus, .ios-textarea:focus, .ios-select:focus {
    outline: none;
    border-color: var(--ios-blue);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
    transform: scale(1.01);
}

/* ===== iOS Animations ===== */
@keyframes springIn {
    0% { opacity: 0; transform: scale(0.95) translateY(20px); }
    50% { opacity: 0.5; transform: scale(1.02) translateY(-2px); }
    100% { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes modalSlideUp {
    from { opacity: 0; transform: translateY(50px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* Push Transition */
.push-enter {
    animation: pushIn 0.35s var(--smooth-ease) forwards;
}

.push-exit {
    animation: pushOut 0.35s var(--smooth-ease) forwards;
}

@keyframes pushIn {
    from { opacity: 0; transform: translateX(30px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes pushOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(-30px); }
}

/* Dissolve Transition */
.dissolve-enter {
    animation: dissolveIn 0.3s ease-out forwards;
}

.dissolve-exit {
    animation: dissolveOut 0.2s ease-in forwards;
}

@keyframes dissolveIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes dissolveOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* ===== iOS Toast ===== */
.ios-toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(20px);
    color: white;
    padding: 12px 24px;
    border-radius: 100px;
    font-size: 15px;
    z-index: 3000;
    transition: transform 0.4s var(--spring-ease);
    white-space: nowrap;
}

.ios-toast.show {
    transform: translateX(-50%) translateY(0);
}

/* ===== iOS Tab Bar ===== */
.ios-tab-bar {
    display: none;
    background: var(--glass-background);
    backdrop-filter: blur(25px);
    border-top: 0.5px solid var(--ios-separator);
    padding: 8px 0 20px;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 999;
}

.ios-tab-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    font-size: 11px;
    color: var(--ios-tertiary-label);
    transition: all 0.2s var(--spring-ease);
    padding: 8px 0;
}

.ios-tab-item.active {
    color: var(--ios-blue);
}

.ios-tab-item:active {
    transform: scale(0.95);
}

/* Показать таббар только на мобильных */
@media (max-width: 768px) {
    .ios-tab-bar {
        display: flex;
    }
    
    main {
        margin-bottom: 70px;
        padding: 10px;
    }
}

/* ===== Desktop стили ===== */
@media (min-width: 769px) {
    body {
        background: linear-gradient(135deg, var(--ios-secondary-background) 0%, var(--ios-background) 100%);
    }
    
    .ios-container {
        max-width: 1200px;
        margin: 0 auto;
        padding: 0 24px;
    }
    
    .ios-card:hover {
        transform: translateY(-4px);
        box-shadow: 0 12px 32px rgba(0, 0, 0, 0.15);
    }
}

/* ===== Pull to Refresh ===== */
.ios-pull-to-refresh {
    text-align: center;
    padding: 20px;
    color: var(--ios-tertiary-label);
    transition: transform 0.3s var(--spring-ease);
    font-size: 14px;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--ios-separator);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--ios-gray);
}

/* ===== Skeleton Loading ===== */
.skeleton {
    background: linear-gradient(90deg, var(--ios-separator) 25%, var(--ios-light-gray) 50%, var(--ios-separator) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: 8px;
}

/* ===== Responsive Grid ===== */
.ios-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    padding: 20px 0;
}

@media (max-width: 768px) {
    .ios-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
}

/* assets/css/style.css - добавляем/исправляем theme-toggle */

/* ===== Theme Toggle Switch (iOS стиль) ===== */
.theme-toggle {
    width: 52px;
    height: 32px;
    background: var(--ios-separator);
    border-radius: 32px;
    position: relative;
    cursor: pointer;
    transition: background 0.3s var(--spring-ease);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

.theme-toggle.active {
    background: var(--ios-blue);
}

/* Кружок-ползунок */
.theme-toggle::before {
    content: '';
    position: absolute;
    width: 28px;
    height: 28px;
    background: white;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: transform 0.3s var(--spring-ease);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* Иконки внутри кружка через ::after */
.theme-toggle::after {
    content: '☀️';
    position: absolute;
    width: 28px;
    height: 28px;
    top: 2px;
    left: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: transform 0.3s var(--spring-ease), opacity 0.2s ease;
    pointer-events: none;
    z-index: 1;
}

/* Активное состояние (темная тема) */
.theme-toggle.active::before {
    transform: translateX(20px);
}

.theme-toggle.active::after {
    content: '🌙';
    transform: translateX(20px);
}

/* Hover эффект для десктопа */
@media (min-width: 769px) {
    .theme-toggle:hover {
        transform: scale(1.02);
    }
    
    .theme-toggle:active::before {
        transform: scale(0.95);
    }
    
    .theme-toggle.active:active::before {
        transform: translateX(20px) scale(0.95);
    }
}

/* Добавь в конец style.css */

/* ===== Мобильная навигация ===== */
.ios-nav-title {
    font-size: 17px;
    font-weight: 600;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
}

/* Кнопка назад */
.ios-back-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--ios-light-gray);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 18px;
}

.ios-back-btn:active {
    transform: scale(0.92);
    background: var(--ios-separator);
}

/* Кнопка меню */
.ios-menu-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--ios-light-gray);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 18px;
}

.ios-menu-btn:active {
    transform: scale(0.92);
    background: var(--ios-separator);
}

/* Выпадающее меню снизу (iOS style) */
.ios-bottom-menu {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--glass-background);
    backdrop-filter: blur(25px);
    border-radius: 20px 20px 0 0;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.34, 1.2, 0.64, 1);
    z-index: 1500;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
}

.ios-bottom-menu.open {
    transform: translateY(0);
}

.ios-bottom-menu-header {
    display: flex;
    justify-content: center;
    padding: 12px;
    border-bottom: 0.5px solid var(--ios-separator);
}

.ios-bottom-menu-handle {
    width: 40px;
    height: 4px;
    background: var(--ios-separator);
    border-radius: 2px;
}

.ios-bottom-menu-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    border-bottom: 0.5px solid var(--ios-separator);
    cursor: pointer;
    transition: background 0.2s;
}

.ios-bottom-menu-item:active {
    background: var(--ios-light-gray);
}

.ios-bottom-menu-item-icon {
    width: 28px;
    font-size: 22px;
}

/* Кастомный pull-to-refresh */
.ios-pull-to-refresh {
    position: relative;
    text-align: center;
    padding: 20px;
    color: var(--ios-tertiary-label);
    font-size: 14px;
    transform: translateY(-60px);
    transition: transform 0.2s ease;
    pointer-events: none;
}

.refresh-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--ios-tertiary-label);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}

/* Скрываем стандартный заголовок на мобильных */
@media (max-width: 768px) {
    .page-header {
        display: none;
    }
    
    .ios-nav-title {
        display: block;
    }
    
    /* Отступ для контента под навбар */
    .ios-container {
        padding-top: 8px;
    }
}

@media (min-width: 769px) {
    .ios-nav-title {
        display: none;
    }
    
    .ios-back-btn {
        display: none;
    }
}

/* iOS Tab Bar - обновленный */
.ios-tab-bar {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--glass-background);
    backdrop-filter: blur(25px);
    border-top: 0.5px solid var(--ios-separator);
    padding: 8px 16px 20px;
    z-index: 100;
}

.ios-tab-bar.show {
    display: flex;
}

.ios-tab-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    font-size: 10px;
    color: var(--ios-tertiary-label);
    transition: all 0.2s ease;
    padding: 8px 0;
}

.ios-tab-item.active {
    color: var(--ios-blue);
}

.ios-tab-item.center {
    transform: translateY(-8px);
}

.ios-tab-item.center .tab-icon {
    width: 50px;
    height: 50px;
    background: var(--ios-blue);
    border-radius: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 24px;
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.3);
}

.tab-icon {
    font-size: 22px;
}

@media (max-width: 768px) {
    .ios-tab-bar.show {
        display: flex;
    }
    
    body {
        padding-bottom: 70px;
    }
}

/* Фиксированный навбар */
.ios-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(25px);
    border-bottom: 0.5px solid var(--ios-separator);
    z-index: 1000;
    transform: translateZ(0);
}

/* Отступ для контента под навбар */
.ios-container {
    padding-top: 72px;
    max-width: 1200px;
    margin: 0 auto;
    padding-left: 16px;
    padding-right: 16px;
}

/* Убираем стандартный pull-to-refresh в браузере */
body {
    overscroll-behavior: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Кастомный индикатор обновления */
.pull-to-refresh {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: transparent;
    z-index: 999;
    pointer-events: none;
    transition: transform 0.2s ease;
    transform: translateY(-100%);
}

.pull-to-refresh.active {
    transform: translateY(0);
}

.pull-to-refresh-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    background: var(--glass-background);
    backdrop-filter: blur(20px);
    color: var(--ios-tertiary-label);
    font-size: 14px;
}

.pull-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--ios-tertiary-label);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* Нижний индикатор загрузки */
.load-more-indicator {
    text-align: center;
    padding: 20px;
    color: var(--ios-tertiary-label);
    font-size: 14px;
}

.load-more-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--ios-tertiary-label);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}

/* Убираем стандартный скролл бар на мобильных */
::-webkit-scrollbar {
    width: 0;
    background: transparent;
}

@media (min-width: 769px) {
    ::-webkit-scrollbar {
        width: 8px;
    }
    ::-webkit-scrollbar-track {
        background: transparent;
    }
    ::-webkit-scrollbar-thumb {
        background: var(--ios-separator);
        border-radius: 10px;
    }
}

/* Адаптация под навбар */
@media (max-width: 768px) {
    .ios-container {
        padding-top: 60px;
    }
}