/* Custom CSS styles - Elia Design System */

/* Цветовая палитра из Figma */
:root {
    --elia-dark: #1A1A1A;
    --elia-lavender: #D0BAFF;
    --elia-cyan: #CFFAFE;
    --elia-pink: #FCE7F3;
    --elia-yellow: #FEF3C7;
    --elia-green: #D1FAE5;
    --elia-white: #FFFFFF;
    --elia-gray-50: #F9FAFB;
    --elia-gray-100: #F3F4F6;
    --elia-gray-200: #E5E7EB;
    --elia-gray-600: #6B7280;
}

/* Smooth transitions */
* {
    transition: all 0.2s ease-in-out;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--elia-gray-100);
}

::-webkit-scrollbar-thumb {
    background: var(--elia-lavender);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #C0A7FF;
}

/* Card hover effect */
.appointment-card {
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.appointment-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.appointment-card.active {
    background: var(--elia-lavender);
    color: var(--elia-dark);
}

.appointment-card.active .badge {
    background: rgba(255, 255, 255, 0.5);
    color: var(--elia-dark);
}

/* Фиолетовая подсветка последнего приема */
.appointment-card.latest-appointment {
    background: var(--elia-lavender) !important;
    border-color: #B794F6 !important;
    border-width: 2px !important;
    box-shadow: 0 4px 12px rgba(208, 186, 255, 0.4) !important;
}

.appointment-card.latest-appointment h3 {
    color: var(--elia-dark) !important;
}

.appointment-card.latest-appointment .flex {
    color: var(--elia-dark) !important;
}

.appointment-card.latest-appointment .badge {
    background: rgba(255, 255, 255, 0.7) !important;
    color: var(--elia-dark) !important;
}

/* Если latest-appointment также active, latest-appointment имеет приоритет */
.appointment-card.latest-appointment.active {
    background: var(--elia-lavender) !important;
    border-color: #B794F6 !important;
    border-width: 2px !important;
}

/* Badge styles */
.badge {
    display: inline-block;
    padding: 6px 14px;
    border-radius: 16px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-cyan {
    background-color: var(--elia-cyan);
    color: #0E7490;
}

.badge-pink {
    background-color: var(--elia-pink);
    color: #BE185D;
}

.badge-yellow {
    background-color: var(--elia-yellow);
    color: #B45309;
}

.badge-purple {
    background-color: var(--elia-lavender);
    color: var(--elia-dark);
}

/* Toast notifications */
.toast {
    min-width: 300px;
    padding: 16px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    animation: slideIn 0.3s ease-out;
}

.toast-success {
    background-color: #10B981;
    color: white;
}

.toast-error {
    background-color: #EF4444;
    color: white;
}

.toast-info {
    background-color: #3B82F6;
    color: white;
}

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

/* Progress bar */
.progress-bar {
    height: 4px;
    background-color: var(--elia-gray-200);
    border-radius: 2px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: var(--elia-lavender);
    transition: width 0.3s ease;
}

/* Loading spinner */
.spinner {
    border: 3px solid var(--elia-gray-100);
    border-top: 3px solid var(--elia-lavender);
    border-radius: 50%;
    width: 24px;
    height: 24px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Tab active state */
.tab-active {
    background-color: var(--elia-lavender) !important;
    color: var(--elia-dark) !important;
}

/* Health indicator card */
.health-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.health-card-value {
    font-size: 2rem;
    font-weight: 700;
    margin: 8px 0 4px;
}

.health-card-unit {
    font-size: 0.875rem;
    color: #6B7280;
}

/* Drag & drop area */
.drop-zone {
    border: 2px dashed var(--elia-gray-200);
    border-radius: 12px;
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
}

.drop-zone:hover,
.drop-zone.drag-over {
    border-color: var(--elia-lavender);
    background-color: #F5F3FF;
}

/* Audio player custom */
audio {
    width: 100%;
    border-radius: 8px;
    outline: none;
}

audio::-webkit-media-controls-panel {
    background-color: #F9FAFB;
}

/* Gradient button */
.btn-gradient {
    background: var(--elia-lavender);
    color: var(--elia-dark);
    padding: 12px 24px;
    border-radius: 12px;
    border: none;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-gradient:hover {
    background: #C0A7FF;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(208, 186, 255, 0.3);
}

.btn-gradient:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Form textarea */
textarea {
    resize: vertical;
    min-height: 100px;
}

/* Section headers */
.section-header {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--elia-dark);
}

/* Color-coded sections - из дизайна Figma */
.section-cyan {
    background-color: var(--elia-cyan);
    padding: 24px;
    border-radius: 16px;
    margin-bottom: 16px;
}

.section-pink {
    background-color: var(--elia-pink);
    padding: 24px;
    border-radius: 16px;
    margin-bottom: 16px;
}

.section-yellow {
    background-color: var(--elia-yellow);
    padding: 24px;
    border-radius: 16px;
    margin-bottom: 16px;
}

.section-lavender {
    background-color: var(--elia-lavender);
    padding: 24px;
    border-radius: 16px;
    margin-bottom: 16px;
}

.section-green {
    background-color: var(--elia-green);
    padding: 24px;
    border-radius: 16px;
    margin-bottom: 16px;
}

.section-blue {
    background-color: var(--elia-cyan);
    padding: 24px;
    border-radius: 16px;
    margin-bottom: 16px;
}

/* Digital Portrait Layout */
.digital-portrait-container {
    max-width: 100%;
    width: 100%;
}

/* Верхняя сетка - три карточки */
.portrait-grid-top {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 16px;
}

/* Нижняя сетка - две карточки */
.portrait-grid-bottom {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 16px;
}

/* Сетка показателей здоровья */
.health-indicators-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

/* Адаптивность для планшетов (до 1024px) */
@media (max-width: 1024px) {
    .portrait-grid-top {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .portrait-grid-bottom {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .health-indicators-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
}

/* Адаптивность для мобильных устройств (до 768px) */
@media (max-width: 768px) {
    .digital-portrait-container {
        padding: 0;
    }
    
    .section-cyan,
    .section-pink,
    .section-yellow,
    .section-blue,
    .section-green {
        padding: 16px;
        border-radius: 12px;
    }
    
    .portrait-grid-top {
        gap: 10px;
    }
    
    .portrait-grid-bottom {
        gap: 10px;
    }
    
    .health-indicators-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .health-card {
        padding: 16px;
    }
    
    .section-header {
        font-size: 1.125rem;
    }
}

/* Большие экраны (от 1440px) */
@media (min-width: 1440px) {
    .digital-portrait-container {
        max-width: 1400px;
    }
    
    .portrait-grid-top {
        gap: 20px;
    }
    
    .portrait-grid-bottom {
        gap: 20px;
    }
    
    .health-indicators-grid {
        gap: 20px;
    }
}

/* ========================================
   MOBILE NAVIGATION & RESPONSIVE LAYOUT
   ======================================== */

/* Бургер кнопка */
.mobile-menu-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 8px;
    background: white;
    border: 1px solid var(--elia-gray-200);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.mobile-menu-button:hover {
    background-color: var(--elia-gray-50);
}

.mobile-menu-button:active {
    transform: scale(0.95);
}

/* Иконка бургера */
.burger-icon {
    position: relative;
    width: 24px;
    height: 18px;
}

.burger-icon span {
    position: absolute;
    left: 0;
    width: 100%;
    height: 2px;
    background-color: var(--elia-dark);
    transition: all 0.3s ease;
}

.burger-icon span:nth-child(1) {
    top: 0;
}

.burger-icon span:nth-child(2) {
    top: 8px;
}

.burger-icon span:nth-child(3) {
    top: 16px;
}

/* Анимация бургера в крестик */
.mobile-menu-button-active .burger-icon span:nth-child(1) {
    top: 8px;
    transform: rotate(45deg);
}

.mobile-menu-button-active .burger-icon span:nth-child(2) {
    opacity: 0;
}

.mobile-menu-button-active .burger-icon span:nth-child(3) {
    top: 8px;
    transform: rotate(-45deg);
}

/* Mobile header */
.mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: white;
    border-bottom: 1px solid var(--elia-gray-200);
}

/* Overlay для затемнения */
#mobile-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0);
    z-index: 40;
    transition: background-color 0.3s ease;
}

#mobile-menu-overlay.mobile-menu-overlay-active {
    background-color: rgba(0, 0, 0, 0.5);
}

/* Mobile sidebar */
#mobile-sidebar {
    position: fixed;
    top: 0;
    left: -280px;
    width: 280px;
    height: 100%;
    background: white;
    z-index: 50;
    transition: left 0.3s ease;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
    overflow-y: auto;
}

#mobile-sidebar.mobile-sidebar-open {
    left: 0;
}

/* Блокировка скролла body */
body.overflow-hidden {
    overflow: hidden;
}

/* ========================================
   RESPONSIVE TYPOGRAPHY & SPACING
   ======================================== */

/* Mobile-first подход - базовые стили для mobile */

/* Адаптивные заголовки */
@media (max-width: 767px) {
    h1, .text-3xl {
        font-size: 1.5rem !important; /* 24px */
        line-height: 2rem !important;
    }
    
    h2, .text-2xl {
        font-size: 1.25rem !important; /* 20px */
        line-height: 1.75rem !important;
    }
    
    .text-xl {
        font-size: 1.125rem !important; /* 18px */
    }
}

/* Адаптивные отступы */
@media (max-width: 767px) {
    .px-8 {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
    
    .py-6 {
        padding-top: 1rem !important;
        padding-bottom: 1rem !important;
    }
}

/* ========================================
   RESPONSIVE BUTTONS & FORMS
   ======================================== */

/* Touch-friendly кнопки */
@media (max-width: 767px) {
    button, .btn-gradient, input[type="button"], input[type="submit"] {
        min-height: 44px;
        touch-action: manipulation;
    }
    
    /* Полная ширина для основных кнопок на mobile */
    .btn-primary-mobile-full {
        width: 100%;
    }
    
    /* Input поля с увеличенным tap target */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="tel"],
    textarea,
    select {
        min-height: 44px;
        font-size: 16px; /* Предотвращает zoom на iOS */
    }
}

/* Адаптивные формы */
@media (max-width: 767px) {
    .grid-cols-2 {
        grid-template-columns: 1fr !important;
    }
    
    .grid-cols-3 {
        grid-template-columns: 1fr !important;
    }
    
    .grid-cols-4 {
        grid-template-columns: 1fr !important;
    }
}

/* Tablet */
@media (min-width: 768px) and (max-width: 1023px) {
    .grid-cols-3 {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    .grid-cols-4 {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* ========================================
   RESPONSIVE LAYOUT
   ======================================== */

/* Скрытие/показ desktop sidebar */
@media (max-width: 1023px) {
    aside:not(#mobile-sidebar) {
        display: none !important;
    }
}

/* Мобильный header видим только на mobile/tablet */
@media (min-width: 1024px) {
    .mobile-header {
        display: none !important;
    }
    
    #mobile-menu-overlay {
        display: none !important;
    }
    
    #mobile-sidebar {
        display: none !important;
    }
}

/* ========================================
   TOUCH OPTIMIZATIONS
   ======================================== */

/* Отключаем hover эффекты на touch устройствах */
@media (hover: none) {
    .appointment-card:hover {
        transform: none;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    }
    
    button:hover,
    a:hover {
        opacity: 1;
    }
}

/* Улучшенные tap targets */
@media (max-width: 767px) {
    a, button, .clickable {
        min-height: 44px;
        min-width: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Исключения для текстовых ссылок */
    a.inline-text-link {
        min-height: auto;
        min-width: auto;
        display: inline;
    }
}

/* ========================================
   APPOINTMENT CARDS - RESPONSIVE
   ======================================== */

/* Mobile - вертикальный стек */
@media (max-width: 767px) {
    .appointments-date-group .flex {
        flex-direction: column !important;
        overflow-x: visible !important;
    }
    
    .appointment-card {
        width: 100% !important;
        flex-shrink: 1 !important;
        margin-bottom: 12px;
    }
}

/* Tablet и Desktop - горизонтальный скролл с фиксированной шириной */
@media (min-width: 768px) {
    .appointment-card {
        width: 16rem !important; /* 256px - фиксированная ширина */
        flex-shrink: 0 !important;
    }
}

/* ========================================
   PATIENT CARD - RESPONSIVE
   ======================================== */

@media (max-width: 767px) {
    /* Компактный header карточки пациента */
    .patient-card-header {
        padding: 12px 16px !important;
    }
    
    .patient-card-header h1 {
        font-size: 1.25rem !important;
    }
    
    /* Скроллируемые вкладки */
    .tabs-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .tabs-container::-webkit-scrollbar {
        display: none;
    }
    
    /* Уменьшаем padding вкладок */
    .tab-button {
        padding: 10px 16px !important;
        font-size: 0.875rem !important;
        white-space: nowrap;
    }
}

/* ========================================
   STICKY ELEMENTS
   ======================================== */

@media (max-width: 767px) {
    /* Sticky кнопка добавления приёма внизу экрана */
    .sticky-bottom-button {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        padding: 12px 16px;
        background: white;
        border-top: 1px solid var(--elia-gray-200);
        box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1);
        z-index: 30;
    }
    
    .sticky-bottom-button button {
        width: 100%;
    }
}

/* ========================================
   UTILITY CLASSES
   ======================================== */

/* Скрытие на mobile */
@media (max-width: 767px) {
    .hidden-mobile {
        display: none !important;
    }
}

/* Скрытие на tablet */
@media (min-width: 768px) and (max-width: 1023px) {
    .hidden-tablet {
        display: none !important;
    }
}

/* Скрытие на desktop */
@media (min-width: 1024px) {
    .hidden-desktop {
        display: none !important;
    }
}

/* Показ только на mobile */
.show-mobile {
    display: none !important;
}

@media (max-width: 767px) {
    .show-mobile {
        display: block !important;
    }
    
    .show-mobile-flex {
        display: flex !important;
    }
    
    .show-mobile-inline {
        display: inline !important;
    }
}

/* Responsive spacing */
@media (max-width: 767px) {
    .space-y-6 > * + * {
        margin-top: 1rem !important;
    }
    
    .space-y-4 > * + * {
        margin-top: 0.75rem !important;
    }
}

/* ========================================
   RECORDING & PROCESSING ANIMATIONS
   ======================================== */

/* Пульсирующий индикатор записи */
.recording-pulse {
    width: 16px;
    height: 16px;
    background-color: #EF4444;
    border-radius: 50%;
    animation: recording-pulse 1.5s ease-in-out infinite;
}

@keyframes recording-pulse {
    0%, 100% { 
        opacity: 1; 
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
    }
    50% { 
        opacity: 0.7; 
        transform: scale(1.1);
        box-shadow: 0 0 0 8px rgba(239, 68, 68, 0);
    }
}

/* Большой спиннер обработки */
.processing-spinner {
    width: 64px;
    height: 64px;
    border: 4px solid #E5E7EB;
    border-top-color: #8B5CF6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Записи лога */
.log-entry {
    padding: 2px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.log-entry:last-child {
    border-bottom: none;
}

/* Модальное окно */
#health-modal {
    backdrop-filter: blur(4px);
}

/* Анимация появления модального окна */
#health-modal > div {
    animation: modal-appear 0.3s ease-out;
}

@keyframes modal-appear {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Inline spinner для кнопок */
button .spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border-width: 2px;
}

/* Плавный прогресс-бар */
.progress-bar-fill {
    background: linear-gradient(90deg, var(--elia-lavender), #8B5CF6);
    transition: width 0.5s ease-out;
}

