/* Основные переменные */
:root {
    --primary-color: #4F46E5;
    --primary-hover: #4338CA;
    --secondary-color: #6B7280;
    --success-color: #10B981;
    --danger-color: #EF4444;
    --warning-color: #F59E0B;
    --background: #F3F4F6;
    --card-bg: #FFFFFF;
    --text-primary: #1F2937;
    --text-secondary: #6B7280;
    --border-color: #E5E7EB;
    --slot-available: #D1FAE5;
    --slot-booked: #FEE2E2;
    --slot-selected: #C7D2FE;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--background);
    min-height: 100vh;
    color: var(--text-primary);
    line-height: 1.6;
}

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

/* Переключатель ролей */
.role-switcher {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 30px;
    background: var(--card-bg);
    padding: 10px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.role-btn {
    padding: 12px 30px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.role-btn:hover {
    background: var(--background);
}

.role-btn.active {
    background: var(--primary-color);
    color: white;
}

/* Представления */
.view {
    display: none;
    animation: fadeIn 0.3s ease;
}

.view.active {
    display: block;
}

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

h1 {
    font-size: 2rem;
    color: var(--text-primary);
    margin-bottom: 10px;
    text-align: center;
}

h2 {
    font-size: 1.3rem;
    color: var(--text-primary);
    margin-bottom: 15px;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 10px;
}

.subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 30px;
}

/* Формы */
.student-form, .teacher-panel {
    background: var(--card-bg);
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin-bottom: 25px;
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-primary);
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s ease;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

/* Кнопки */
.btn-primary {
    background: var(--primary-color);
    color: white;
    padding: 12px 25px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
    padding: 12px 25px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-secondary:hover {
    background: #5B6370;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
    padding: 12px 25px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 15px;
}

.btn-danger:hover {
    background: #DC2626;
}

/* Календарь */
.calendar-section {
    background: var(--card-bg);
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin-bottom: 25px;
}

.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.calendar-header span {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
}

.nav-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.3s ease;
}

.nav-btn:hover {
    background: var(--primary-hover);
    transform: scale(1.1);
}

.calendar .weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 5px;
    margin-bottom: 10px;
}

.calendar .weekdays span {
    text-align: center;
    font-weight: 600;
    color: var(--text-secondary);
    padding: 10px 0;
}

.calendar .days-wrapper {
    position: relative;
}

.calendar .days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 5px;
}

.calendar .day {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
    background: var(--background);
}

.calendar .day:hover:not(.empty):not(.past) {
    background: var(--primary-color);
    color: white;
}

.calendar .day.empty {
    background: transparent;
    cursor: default;
}

.calendar .day.today {
    border: 2px solid var(--primary-color);
}

.calendar .day.has-slots {
    background: var(--slot-available);
    color: var(--success-color);
    font-weight: 700;
}

.calendar .day.has-slots:hover {
    background: var(--success-color);
    color: white;
}

.calendar .day.selected {
    background: var(--primary-color);
    color: white;
}

.calendar .day.past {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Выпадающий список слотов для студента */
.slots-dropdown {
    position: absolute;
    z-index: 100;
    width: 280px;
    background: var(--card-bg);
    border: 2px solid var(--primary-color);
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(79, 70, 229, 0.25);
    overflow: visible;
    animation: popIn 0.2s ease;
}

.slots-dropdown::before {
    content: '';
    position: absolute;
    top: -10px;
    left: 20px;
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-bottom: 10px solid var(--primary-color);
}

.slots-dropdown::after {
    content: '';
    position: absolute;
    top: -6px;
    left: 22px;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 8px solid var(--primary-color);
}

@keyframes popIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.dropdown-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    color: white;
    border-radius: 10px 10px 0 0;
}

.dropdown-header span {
    font-weight: 600;
    font-size: 1.1rem;
}

.dropdown-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
}

.dropdown-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.dropdown-slots {
    padding: 15px;
    max-height: 300px;
    overflow-y: auto;
}

.dropdown-slot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    margin-bottom: 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.dropdown-slot:last-child {
    margin-bottom: 0;
}

.dropdown-slot.available {
    background: var(--slot-available);
    border: 2px solid transparent;
}

.dropdown-slot.available:hover {
    border-color: var(--success-color);
    transform: translateX(5px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2);
}

.dropdown-slot.booked {
    background: var(--slot-booked);
    cursor: not-allowed;
    opacity: 0.7;
}

.dropdown-slot.selected {
    background: var(--slot-selected);
    border: 2px solid var(--primary-color);
}

.dropdown-slot .slot-time {
    font-weight: 700;
    font-size: 1rem;
}

.dropdown-slot .slot-room {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.dropdown-slot .slot-status {
    font-size: 0.8rem;
    padding: 3px 8px;
    border-radius: 12px;
    font-weight: 500;
}

.dropdown-slot.available .slot-status {
    background: var(--success-color);
    color: white;
}

.dropdown-slot.booked .slot-status {
    background: var(--danger-color);
    color: white;
}

.dropdown-empty {
    text-align: center;
    padding: 30px;
    color: var(--text-secondary);
}

.dropdown-empty span {
    font-size: 2.5rem;
    display: block;
    margin-bottom: 10px;
}

.dropdown-empty p {
    font-size: 1rem;
}

/* Слоты */
.slots-section, .manage-slots-section {
    background: var(--card-bg);
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin-bottom: 25px;
}

.slots-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
    margin-top: 15px;
}

.slot {
    padding: 15px 10px;
    border-radius: 8px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
    border: 2px solid transparent;
}

.slot.available {
    background: var(--slot-available);
    color: #065F46;
}

.slot.available:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
    border-color: var(--success-color);
}

.slot.booked {
    background: var(--slot-booked);
    color: #991B1B;
    cursor: not-allowed;
    opacity: 0.7;
}

.slot.selected {
    background: var(--slot-selected);
    color: var(--primary-color);
    border-color: var(--primary-color);
    transform: translateY(-3px);
}

/* Подтверждение бронирования */
.booking-confirmation {
    background: var(--card-bg);
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin-bottom: 25px;
    border: 2px solid var(--primary-color);
}

.booking-confirmation h3 {
    color: var(--success-color);
    margin-bottom: 15px;
}

#confirmationDetails {
    background: var(--background);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
}

#confirmationDetails p {
    margin-bottom: 8px;
}

.booking-confirmation button {
    margin-right: 10px;
}

/* Список слотов преподавателя */
.slots-list {
    max-height: 400px;
    overflow-y: auto;
}

.slot-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: var(--background);
    border-radius: 8px;
    margin-bottom: 10px;
    transition: all 0.3s ease;
}

.slot-item:hover {
    transform: translateX(5px);
}

.slot-item.booked {
    background: var(--slot-booked);
}

.slot-item .slot-time {
    font-weight: 600;
    font-size: 1.1rem;
}

.slot-item .slot-status {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.slot-item .slot-student {
    font-size: 0.9rem;
    color: var(--primary-color);
    font-weight: 500;
}

.slot-item .delete-slot {
    background: var(--danger-color);
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.slot-item .delete-slot:hover {
    background: #DC2626;
}

/* Список бронирований */
.bookings-section {
    background: var(--card-bg);
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin-top: 25px;
}

.bookings-list {
    max-height: 500px;
    overflow-y: auto;
}

.booking-item {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr auto;
    gap: 15px;
    align-items: center;
    padding: 15px;
    background: var(--background);
    border-radius: 8px;
    margin-bottom: 10px;
    border-left: 4px solid var(--primary-color);
}

.booking-item span {
    font-size: 0.95rem;
}

.booking-item .booking-date {
    font-weight: 600;
    color: var(--primary-color);
}

.booking-item .booking-time {
    font-weight: 600;
}

.booking-item .cancel-booking {
    background: var(--danger-color);
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.3s ease;
}

.booking-item .cancel-booking:hover {
    background: #DC2626;
}

/* Уведомления */
.notification {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: var(--primary-color);
    color: white;
    padding: 15px 25px;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    transform: translateX(150%);
    transition: transform 0.3s ease;
    z-index: 1000;
}

.notification.show {
    transform: translateX(0);
}

.notification.success {
    background: var(--success-color);
}

.notification.error {
    background: var(--danger-color);
}

.notification.warning {
    background: var(--warning-color);
}

/* Секции преподавателя */
.create-slots-section {
    background: var(--background);
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 25px;
}

/* Пустое состояние */
.empty-state {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

.empty-state span {
    font-size: 3rem;
    display: block;
    margin-bottom: 15px;
}

/* Адаптивность */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    h1 {
        font-size: 1.5rem;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .slots-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .booking-item {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .role-btn {
        padding: 10px 20px;
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .slots-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .slot {
        padding: 12px 8px;
        font-size: 0.9rem;
    }
}

/* Подсказка о слотах */
.slots-legend {
    display: flex;
    gap: 20px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
}

.legend-color {
    width: 20px;
    height: 20px;
    border-radius: 4px;
}

.legend-color.available {
    background: var(--slot-available);
}

.legend-color.booked {
    background: var(--slot-booked);
}

.legend-color.selected {
    background: var(--slot-selected);
}

/* ==========================================
   Страница входа
   ========================================== */

.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-card {
    background: var(--card-bg);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    max-width: 600px;
    width: 100%;
}

.login-header {
    background: var(--primary-color);
    color: white;
    padding: 40px;
    text-align: center;
}

.login-header h1 {
    color: white;
    margin-bottom: 5px;
}

.login-header p {
    opacity: 0.9;
}

.login-form {
    padding: 40px;
}

.login-form h2 {
    text-align: center;
    margin-bottom: 30px;
    border: none;
}

/* Карточки ролей */
.role-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.role-card {
    background: var(--background);
    border-radius: 15px;
    padding: 30px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    text-decoration: none;
    color: var(--text-primary);
    position: relative;
}

.role-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    border-color: var(--primary-color);
}

.role-card .role-icon {
    font-size: 3rem;
    margin-bottom: 15px;
}

.role-card h3 {
    margin-bottom: 10px;
    color: var(--primary-color);
}

.role-card p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 15px;
}

.role-card .role-arrow {
    font-size: 1.5rem;
}

.student-card:hover {
    background: var(--slot-available);
}

.teacher-card:hover {
    background: var(--slot-selected);
}

/* Форма входа преподавателя */
.teacher-login {
    background: var(--background);
    padding: 25px;
    border-radius: 15px;
    margin-top: 20px;
}

.teacher-login h3 {
    text-align: center;
    margin-bottom: 20px;
    color: var(--primary-color);
}

.password-input {
    position: relative;
}

.password-input input {
    padding-right: 50px;
}

.toggle-password {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 5px;
}

.login-error {
    background: var(--slot-booked);
    color: #991B1B;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 15px;
    text-align: center;
    font-weight: 500;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.form-actions button {
    flex: 1;
}

.credentials-hint {
    margin-top: 20px;
    padding: 15px;
    background: #FEF3C7;
    border-radius: 8px;
    border-left: 4px solid var(--warning-color);
}

.credentials-hint p {
    margin-bottom: 5px;
    font-size: 0.9rem;
}

.credentials-hint code {
    background: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: bold;
}

.login-footer {
    background: var(--background);
    padding: 15px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* ==========================================
   Шапка страницы
   ========================================== */

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--card-bg);
    padding: 15px 25px;
    border-radius: 12px;
    margin-bottom: 25px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.back-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
}

.back-link:hover {
    color: var(--primary-hover);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-role {
    background: var(--slot-selected);
    color: var(--primary-color);
    padding: 8px 15px;
    border-radius: 20px;
    font-weight: 600;
}

.user-name {
    color: var(--text-secondary);
}

/* ==========================================
   Доступ запрещён
   ========================================== */

.access-denied {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
}

.access-denied-content {
    text-align: center;
    background: var(--card-bg);
    padding: 60px;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
}

.access-denied-content .lock-icon {
    font-size: 5rem;
    display: block;
    margin-bottom: 20px;
}

.access-denied-content h2 {
    color: var(--danger-color);
    margin-bottom: 15px;
    border: none;
}

.access-denied-content p {
    color: var(--text-secondary);
    margin-bottom: 25px;
}

.access-denied-content .btn-primary {
    display: inline-block;
    text-decoration: none;
}

/* ==========================================
   Мои бронирования (студент)
   ========================================== */

.my-bookings-section {
    background: var(--card-bg);
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin-top: 25px;
}

.my-booking-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    padding: 15px;
    background: var(--background);
    border-radius: 8px;
    margin-bottom: 10px;
    border-left: 4px solid var(--success-color);
}

.my-booking-item .booking-info {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: center;
}

.my-booking-item .booking-date {
    font-weight: 600;
    color: var(--primary-color);
}

/* ==========================================
   Поиск бронирований
   ========================================== */

.bookings-filters {
    margin-bottom: 15px;
}

.search-input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s ease;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* ==========================================
   Адаптивность для страницы входа
   ========================================== */

@media (max-width: 600px) {
    .role-cards {
        grid-template-columns: 1fr;
    }
    
    .login-card {
        margin: 10px;
    }
    
    .login-header, .login-form {
        padding: 25px;
    }
    
    .page-header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .my-booking-item {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .my-booking-item .booking-info {
        flex-direction: column;
        align-items: flex-start;
    }
}
