@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700&display=swap');

:root {
    --primary-color: var(--tg-theme-button-color);
    --text-color: var(--tg-theme-text-color);
    --bg-color: var(--tg-theme-bg-color);
    --secondary-bg: var(--tg-theme-secondary-bg-color);
    --hint-color: var(--tg-theme-hint-color);
    --border-radius: 12px;
    --box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Montserrat', sans-serif;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

body {
    background: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
    padding: 16px;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

.search-container {
    background: var(--secondary-bg);
    border-radius: var(--border-radius);
    padding: 24px;
    box-shadow: var(--box-shadow);
    margin-bottom: 24px;
    animation: fadeInDown 0.5s ease-out;
}

h1 {
    text-align: center;
    font-size: 24px;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 24px;
}

.search-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.search-type-selector {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
    gap: 12px;
    margin-bottom: 20px;
    max-width: 300px;
    margin-left: auto;
    margin-right: auto;
}

.type-btn {
    padding: 16px 12px;
    border: none;
    border-radius: var(--border-radius);
    background: var(--bg-color);
    color: var(--text-color);
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    text-align: center;
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.type-btn:nth-child(3) {
    grid-column: 1 / -1;
    justify-self: center;
    max-width: 200px;
}

.type-btn:active {
    transform: scale(0.98);
}

.type-btn.active {
    background: var(--primary-color);
    color: var(--tg-theme-button-text-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Дополнительные стили для лучшего отображения на мобильных */
@media (max-width: 400px) {
    .search-type-selector {
        max-width: 260px;
        gap: 8px;
    }

    .type-btn {
        font-size: 14px;
        padding: 12px 8px;
        min-height: 42px;
    }

    .type-btn:nth-child(3) {
        max-width: 160px;
    }
}

.search-inputs {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.input-group {
    width: 100%;
    position: relative;
}

.search-input {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: var(--border-radius);
    background: var(--bg-color);
    color: var(--text-color);
    font-size: 16px;
    transition: var(--transition);
}

.search-input:focus {
    outline: none;
    box-shadow: 0 0 0 2px var(--primary-color);
}

/* Специальные стили для поля ввода даты */
input[type="date"] {
    width: 100%;
    min-width: 0;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    text-align: left;
    padding-left: 12px;
    padding-right: 12px;
}

/* Стили для iOS */
input[type="date"]::-webkit-date-and-time-value {
    text-align: left;
    margin-left: 0;
}

/* Стили для иконки календаря в поле даты */
input[type="date"]::-webkit-calendar-picker-indicator {
    cursor: pointer;
    padding: 0;
    margin: 0;
    opacity: 0.7;
    transition: var(--transition);
    position: absolute;
    right: 12px;
}

input[type="date"]::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
}

.search-button {
    width: 100%;
    padding: 12px;
    background: var(--primary-color);
    color: var(--tg-theme-button-text-color);
    border: none;
    border-radius: var(--border-radius);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    margin-top: 8px;
}

.search-button:active {
    transform: scale(0.98);
}

.results-container {
    background: var(--secondary-bg);
    border-radius: var(--border-radius);
    padding: 24px;
    box-shadow: var(--box-shadow);
    animation: fadeInUp 0.5s ease-out;
}

.schedule-header {
    text-align: center;
    margin-bottom: 24px;
}

.schedule-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 8px;
}

.schedule-date {
    font-size: 14px;
    color: var(--hint-color);
}

.schedule-table {
    width: 100%;
    background: transparent;
    border-radius: var(--border-radius);
    padding: 8px 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.schedule-row {
    display: flex;
    align-items: stretch;
    min-height: 70px;
    background: var(--bg-color);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.schedule-row:last-child {
    margin-bottom: 0;
}

.schedule-row.header {
    font-weight: 600;
    background: var(--primary-color);
    color: var(--tg-theme-button-text-color);
    min-height: 55px;
    margin-bottom: 8px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.time, .subject, .room {
    padding: 12px 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

.time {
    flex: 0 0 95px;
    min-width: 95px;
    flex-direction: column;
    gap: 6px;
    font-size: 12px;
    line-height: 1.2;
    padding: 12px 8px;
    background: rgba(52, 152, 219, 0.05);
    border-radius: 6px 0 0 6px;
}

.subject {
    flex: 1;
    text-align: center;
    justify-content: center;
    padding: 12px;
    min-width: 0;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: center;
}

.subject-name {
    font-weight: 600;
    color: var(--text-color);
    font-size: 14px;
    line-height: 1.3;
    text-align: center;
}

.room {
    flex: 0 0 85px;
    min-width: 85px;
    font-size: 13px;
    text-align: center;
    padding: 12px 8px;
    background: rgba(46, 204, 113, 0.05);
    border-radius: 0 6px 6px 0;
    font-weight: 500;
    color: var(--text-color);
}

.schedule-row.header .room {
    color: var(--tg-theme-button-text-color);
}

.error-message {
    background: #ff3b30;
    color: white;
    padding: 12px;
    border-radius: var(--border-radius);
    text-align: center;
    margin-top: 16px;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

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

/* Адаптивность для Telegram Web App - минимальная, так как приложение оптимизировано для мобильных устройств */
@media (max-width: 480px) {
    .container {
        padding: 12px;
    }

    .search-container,
    .results-container {
        padding: 16px;
    }

    h1 {
        font-size: 20px;
    }

    .search-type-selector {
        max-width: 280px;
        gap: 10px;
    }

    .type-btn {
        font-size: 15px;
        padding: 14px 10px;
        min-height: 45px;
    }

    .type-btn:nth-child(3) {
        max-width: 180px;
    }

    .schedule-title {
        font-size: 18px;
    }

    .schedule-row {
        min-height: 65px;
        margin-bottom: 3px;
    }

    .time {
        flex: 0 0 80px;
        min-width: 80px;
        font-size: 11px;
        padding: 10px 6px;
        gap: 4px;
    }

    .subject {
        font-size: 13px;
        padding: 10px 8px;
        gap: 3px;
    }

    .subject-name {
        font-size: 13px;
    }

    .room {
        flex: 0 0 75px;
        min-width: 75px;
        font-size: 12px;
        padding: 10px 6px;
    }

    .pair-number {
        font-size: 11px;
    }

    .time-range {
        font-size: 10px;
    }

    .teacher, .group {
        font-size: 11px;
    }
}

.teacher, .group {
    font-size: 12px;
    color: var(--hint-color);
    margin-top: 2px;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    line-height: 1.3;
}

.time {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    min-width: 90px;
}

.pair-number {
    font-size: 14px;
    color: var(--hint-color);
    font-weight: 500;
}

.time-range {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    font-size: 14px;
    line-height: 1.2;
}

.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--secondary-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    margin-top: 4px;
}

.dropdown-item {
    padding: 12px;
    cursor: pointer;
    transition: var(--transition);
    border-bottom: 1px solid var(--hint-color);
}

.dropdown-item:last-child {
    border-bottom: none;
}

/* Hover эффекты убраны для Telegram Web App */

.schedule-divider {
    width: 100%;
    margin: 16px 0;
    position: relative;
    text-align: center;
    padding: 16px 0;
    background: var(--secondary-bg);
    border-radius: var(--border-radius);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.divider-text {
    font-weight: 600;
    color: var(--text-color);
    font-size: 15px;
    position: relative;
}

.divider-text::before,
.divider-text::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 30px;
    height: 1px;
    background: var(--hint-color);
}

.divider-text::before {
    left: 20px;
}

.divider-text::after {
    right: 20px;
}

.schedule-row.combined {
    background: rgba(52, 152, 219, 0.08);
    border-left: 4px solid var(--primary-color);
    box-shadow: 0 2px 6px rgba(52, 152, 219, 0.1);
} 