/* ===== RESET & BASE ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Prevent iOS zoom on input focus */
input, textarea, select {
    font-size: 16px;
}

:root {
    --primary: #764ba2;
    --primary-light: #667eea;
    --bg-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --text-white: #fff;
    --text-dark: #333;
    --text-muted: #666;
    --surface: rgba(255, 255, 255, 0.95);
    --surface-glass: rgba(255, 255, 255, 0.1);
    --border: #ddd;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.2);
    --transition: 0.2s ease;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-top: env(safe-area-inset-top, 0px);
    --header-height: 56px;
}

html {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    height: var(--app-height, 100dvh);
    max-height: var(--app-height, 100dvh);
    display: flex;
    flex-direction: column;
    background: var(--bg-gradient);
    color: var(--text-white);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow: hidden;
}

/* ===== NAVIGATION / TABS ===== */
.nav-header {
    position: sticky;
    top: 0;
    z-index: 10000;
    background: #522687;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    padding: 0.5rem 1rem;
    padding-top: calc(0.5rem + var(--safe-top));
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-height);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.nav-brand {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-white);
    letter-spacing: -0.5px;
}

.hamburger {
    display: none;
    flex-direction: column;
    gap: 5px;
    cursor: pointer;
    padding: 8px;
    border: none;
    background: transparent;
    z-index: 200;
}

.hamburger span {
    display: block;
    width: 24px;
    height: 2.5px;
    background: var(--text-white);
    border-radius: 2px;
    transition: var(--transition);
}

.hamburger.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}
.hamburger.active span:nth-child(2) {
    opacity: 0;
}
.hamburger.active span:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
}

.tabs {
    display: flex;
    gap: 0.25rem;
    align-items: center;
}

.tab {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    font-weight: 500;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: rgba(255, 255, 255, 0.75);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.tab.active {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    font-weight: 600;
}

.tab:hover:not(.active) {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

/* ===== TAB CONTENT ===== */
.tab-content {
    display: none;
    width: 100%;
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
    min-height: 0;
}

.tab-content.active {
    display: block;
}

#tab-chat.active {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0;
}

#tab-calendar.active {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0.5rem;
}

#tab-documents.active {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0;
}

/* ===== CONTAINER / HOME ===== */
.container {
    text-align: center;
    padding: 2rem 1rem;
    max-width: 600px;
    margin: 0 auto;
}

h1 {
    font-size: clamp(1.8rem, 5vw, 2.5rem);
    margin-bottom: 0.5rem;
    font-weight: 700;
}

h1[style] {
    font-size: unset;
    margin-bottom: unset;
}

p {
    font-size: 1rem;
    margin-bottom: 1.5rem;
    opacity: 0.9;
}

.btn {
    display: inline-block;
    padding: 0.8rem 1.6rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary);
    background: #fff;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    box-shadow: var(--shadow);
    text-decoration: none;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn:active {
    transform: translateY(0);
}

/* ===== MODAL ===== */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 15px;
    overflow-y: auto;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: #fff;
    color: var(--text-dark);
    border-radius: var(--radius);
    padding: 1.5rem;
    width: 100%;
    max-width: 450px;
    box-shadow: var(--shadow-lg);
    max-height: 90vh;
    overflow-y: auto;
}

.modal h2 {
    margin-bottom: 1.25rem;
    color: var(--primary);
    font-size: 1.3rem;
}

.form-group {
    margin-bottom: 1rem;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 0.3rem;
    font-weight: 500;
    font-size: 0.9rem;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.7rem 0.9rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-family: inherit;
    transition: border-color var(--transition);
}

.form-group input[type="checkbox"] {
    width: auto;
    padding: 0;
    border: none;
    appearance: checkbox;
    -webkit-appearance: checkbox;
    width: 18px;
    height: 18px;
    cursor: pointer;
    vertical-align: middle;
    margin-right: 0.5rem;
    accent-color: var(--primary);
}

.form-group input[type="time"],
.form-group input[type="date"] {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    border-radius: var(--radius-sm);
    -webkit-border-radius: var(--radius-sm);
    background: #fff;
    padding: 0.7rem 0.9rem;
    border: 1.5px solid var(--border);
    font-size: 1rem;
    color: var(--text-dark);
    min-height: 44px;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(118, 75, 162, 0.1);
}

.form-group input[type="checkbox"]:focus {
    box-shadow: none;
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.modal-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
    justify-content: flex-end;
    flex-wrap: wrap;
}

/* ===== BUTTONS ===== */
.btn-submit {
    padding: 0.7rem 1.4rem;
    font-size: 1rem;
    font-weight: 600;
    color: #fff;
    background: #5a2d82;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition);
    touch-action: manipulation;
}

.btn-submit:hover {
    background: #4a1d72;
}

.btn-cancel {
    padding: 0.7rem 1.4rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-muted);
    background: #f0f0f0;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition);
}

.btn-cancel:hover {
    background: #e0e0e0;
}

.btn-delete {
    padding: 0.7rem 1.4rem;
    font-size: 1rem;
    font-weight: 600;
    background: #dc3545;
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition);
}

.btn-delete:hover {
    background: #c82333;
}

.btn-nav {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    background: rgba(255, 255, 255, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: var(--radius-sm);
    color: #fff;
    cursor: pointer;
    transition: background var(--transition);
    font-weight: 600;
    white-space: nowrap;
    touch-action: manipulation;
}

.btn-nav:hover {
    background: rgba(255, 255, 255, 0.4);
}

#prevWeek, #nextWeek {
    padding: 4px 10px;
    min-width: unset;
    flex: none;
    width: auto;
}

/* ===== TOAST ===== */
.toast {
    position: fixed;
    bottom: calc(1.5rem + var(--safe-bottom));
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #333;
    color: #fff;
    padding: 0.8rem 1.5rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    opacity: 0;
    transition: transform 0.3s, opacity 0.3s;
    z-index: 2000;
    max-width: calc(100% - 2rem);
    text-align: center;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* ===== NOTIFICATIONS ===== */
.notification {
    position: fixed;
    top: calc(var(--header-height) + 10px);
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    background: #28a745;
    color: #fff;
    padding: 0.8rem 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    font-weight: 500;
    z-index: 1500;
    transition: transform 0.3s ease;
    max-width: calc(100% - 2rem);
    text-align: center;
}

.notification.show {
    transform: translateX(-50%) translateY(0);
}

.notification-success { background: #28a745; }
.notification-error { background: #dc3545; }
.notification-info { background: #17a2b8; }

/* ===== REQUESTS PANEL ===== */
.requests-panel {
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    padding: 1.5rem;
    background: var(--surface-glass);
    border-radius: var(--radius);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.requests-panel h2 {
    margin-bottom: 1.25rem;
    font-size: 1.4rem;
}

.requests-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    color: var(--text-dark);
    border-radius: var(--radius);
    overflow: hidden;
    font-size: 0.9rem;
}

.requests-table thead {
    background: var(--primary);
    color: #fff;
}

.requests-table th,
.requests-table td {
    padding: 0.6rem 0.75rem;
    text-align: left;
}

.requests-table tbody tr:nth-child(even) {
    background: #f8f8fa;
}

.requests-table tbody tr:hover {
    background: #eee;
}

.empty-state {
    text-align: center;
    opacity: 0.8;
    padding: 2rem;
    font-size: 1rem;
}

/* ===== LOGIN SECTION ===== */
.login-section {
    max-width: 350px;
    margin: 0 auto;
}

.login-prompt {
    text-align: center;
    margin-bottom: 1.25rem;
    opacity: 0.9;
}

.login-form .form-group input {
    background: rgba(255, 255, 255, 0.9);
}

.login-form .btn-submit {
    width: 100%;
    margin-top: 0.5rem;
}

/* ===== BADGES ===== */
.badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-paid { background: #d4edda; color: #155724; }
.badge-pending { background: #fff3cd; color: #856404; }
.badge-verified { background: #d4edda; color: #155724; }

/* ===== CHAT PANEL ===== */
.chat-panel {
    width: 100%;
    max-width: 700px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    background: var(--surface-glass);
    border-radius: var(--radius);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    overflow: hidden;
    flex: 1;
    min-height: 0;
    max-height: 100%;
}

.chat-view-hidden {
    display: none !important;
}

.chat-view-visible {
    display: flex !important;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    height: 100%;
}

.chat-header {
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.1);
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    flex-shrink: 0;
}

.language-buttons {
    display: flex;
    gap: 0.5rem;
}

.lang-btn {
    padding: 0.45rem 0.9rem;
    font-size: 0.85rem;
    font-weight: 600;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: var(--radius-sm);
    background: transparent;
    color: #fff;
    cursor: pointer;
    transition: all var(--transition);
    touch-action: manipulation;
}

.lang-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.5);
}

.lang-btn.active {
    background: #fff;
    color: var(--primary);
    border-color: #fff;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    -webkit-overflow-scrolling: touch;
}

.chat-message {
    display: flex;
    margin-bottom: 0.25rem;
}

.chat-message.own { justify-content: flex-end; }
.chat-message.other { justify-content: flex-start; }
.chat-message.system { justify-content: center; }

.message-content {
    max-width: 80%;
    padding: 0.6rem 0.9rem;
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.9);
    color: var(--text-dark);
    word-break: break-word;
}

.chat-message.own .message-content {
    background: var(--primary);
    color: #fff;
}

.message-text {
    margin: 0;
    word-wrap: break-word;
    font-size: 0.95rem;
}

.message-time {
    display: block;
    font-size: 0.7rem;
    opacity: 0.7;
    margin-top: 0.2rem;
}

.system-text {
    margin: 0;
    font-size: 0.85rem;
    opacity: 0.7;
    font-style: italic;
}

.chat-input-area {
    padding: 0.75rem 1rem;
    padding-bottom: calc(0.75rem + var(--safe-bottom));
    background: rgba(255, 255, 255, 0.1);
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    flex-shrink: 0;
}

.chat-form {
    display: flex;
    gap: 0.5rem;
}

#chatInput {
    flex: 1;
    padding: 0.7rem 0.9rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-family: inherit;
    min-width: 0;
}

.chat-form .btn-submit {
    padding: 0.7rem 1.2rem;
    white-space: nowrap;
    flex-shrink: 0;
}

/* ===== CALENDAR PANEL ===== */
.calendar-panel {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
    background: var(--surface-glass);
    border-radius: var(--radius);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    gap: 0.4rem;
    flex-wrap: nowrap;
    position: sticky;
    top: 0;
    z-index: 10;
    padding: 0.5rem 0;
}

.calendar-header h2 {
    margin: 0;
    font-size: 0.85rem;
    min-width: 0;
    text-align: center;
    flex: 1;
    white-space: nowrap;
}

.week-calendar {
    background: var(--surface);
    border-radius: var(--radius);
    overflow: auto;
    margin-bottom: 0.5rem;
    border: 1px solid rgba(0, 0, 0, 0.1);
    flex: 1;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
}

.calendar-table-container {
    width: 100%;
    -webkit-overflow-scrolling: touch;
    position: relative;
}

.calendar-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: #fff;
    color: var(--text-dark);
    table-layout: fixed;
    min-width: 700px;
}

.calendar-table th,
.calendar-table td {
    border: none;
    padding: 0;
    height: 45px;
    vertical-align: top;
    position: relative;
    overflow: hidden;
}

.calendar-table .day-header {
    background: #e8e8f0;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 20;
    text-align: center;
    color: var(--text-dark);
    padding: 0.2rem;
    border-right: 1px solid #ddd;
    border-bottom: 1px solid #ddd;
    height: auto;
    vertical-align: middle;
    position: sticky;
    top: 0;
    z-index: 10;
}

.calendar-table .time-header {
    background: #e9ecef;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 20;
    text-align: center;
    width: 80px;
    min-width: 80px;
    padding: 0.4rem;
    border-right: 2px solid #999;
    height: auto;
    vertical-align: middle;
    position: sticky;
    left: 0;
    top: 0;
    z-index: 40;
}

.calendar-table .day-header.today {
    background: var(--primary);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 20;
}

.calendar-table .day-name { font-size: 0.7rem; font-weight: 600; }
.calendar-table .day-number { font-size: 0.95rem; font-weight: 700; }
.calendar-table .day-date { font-size: 0.6rem; opacity: 0.85; font-weight: 500; }
.calendar-table .day-header.today .day-date { opacity: 1; }

.calendar-table .time-cell {
    background: #f8f9fa;
    font-weight: 600;
    text-align: right;
    font-size: 0.7rem;
    width: 80px;
    min-width: 80px;
    padding: 0.2rem 0.4rem;
    border-right: 2px solid #999;
    border-bottom: 1px solid #ccc;
    vertical-align: top;
    line-height: 1.2;
    position: sticky;
    left: 0;
    z-index: 25;
    box-shadow: 2px 0 4px rgba(0,0,0,0.08);
}

.calendar-table .time-cell.business-hours-time {
    background: #c8dcf8;
    color: #1a3a6b;
    font-weight: 700;
}

.calendar-table .time-cell .moscow-time {
    font-size: 0.7rem;
    font-weight: 600;
}

.calendar-table .time-cell .edt-time {
    font-size: 0.6rem;
    font-weight: 500;
    opacity: 0.8;
    color: var(--text-muted);
}

.calendar-table .time-cell.hour-start {
    border-bottom: 3px solid #333;
}

.calendar-table .day-cell {
    background: #fff;
    cursor: pointer;
    transition: background var(--transition);
    position: relative;
    border-right: 1px solid #ddd;
    border-bottom: 3px solid #333;
    vertical-align: top;
    padding: 0;
    overflow: visible;
}

.calendar-table .day-cell:hover { background: rgba(102, 126, 234, 0.2); }
.calendar-table .day-cell.business-hours { background: #d4e4ff; }
.calendar-table .day-cell.business-hours:hover { background: #b8d4ff; }
.calendar-table .day-cell.selected { background: rgba(102, 126, 234, 0.35); border-color: var(--primary-light); }

/* ===== EVENT BLOCKS ===== */
.event-block {
    background: var(--primary-light);
    color: #fff;
    border-radius: 4px;
    padding: 0.25rem;
    cursor: pointer;
    overflow: hidden;
    transition: all var(--transition);
    border: 2px solid var(--primary-light);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    z-index: 10;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
    position: absolute;
    left: 1px;
    right: 1px;
    width: calc(100% - 2px);
    box-sizing: border-box;
    pointer-events: auto;
}

.event-block:hover {
    background: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    z-index: 20;
}

.event-block.full-day {
    min-height: 2rem;
    display: flex;
    align-items: flex-start;
    position: absolute;
    top: 0;
    left: 1px;
    right: auto;
    width: calc(100% - 2px);
    margin: 0;
    padding: 0.25rem;
    box-sizing: border-box;
}

.event-block.short-event {
    min-height: 1.2rem;
    padding: 0.15rem;
}

.event-block.short-event .event-title {
    font-size: 0.6rem;
    line-height: 1;
}

.event-title {
    font-weight: 600;
    font-size: 0.75rem;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    line-height: 1.1;
    word-break: break-word;
    width: 100%;
    max-height: 100%;
}

.event-time {
    font-size: 0.7rem;
    opacity: 0.9;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 0.15rem;
}

/* ===== FULL DAY EVENTS ===== */
.full-day-events-container {
    background: var(--surface);
    border-radius: 0 0 var(--radius) var(--radius);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-top: none;
    padding: 0.5rem;
    margin-bottom: 1.5rem;
}

.full-day-events-row {
    display: grid;
    grid-template-columns: 80px repeat(7, 1fr);
    gap: 1px;
    margin-bottom: 0.5rem;
}

.full-day-events-row:last-child { margin-bottom: 0; }

.full-day-label {
    font-weight: 600;
    font-size: 0.7rem;
    padding: 0.25rem 0.4rem;
    text-align: right;
    color: var(--text-muted);
}

.full-day-cell {
    min-height: 1.6rem;
    display: flex;
    align-items: center;
    padding: 0.2rem;
    position: relative;
}

.full-day-event {
    background: var(--primary-light);
    color: #fff;
    border-radius: 4px;
    padding: 0.25rem 0.4rem;
    cursor: pointer;
    overflow: hidden;
    transition: all var(--transition);
    border: 2px solid var(--primary-light);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    z-index: 10;
    width: 100%;
    font-size: 0.7rem;
    font-weight: 600;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.full-day-event:hover {
    background: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* ===== BOOKING SECTION ===== */
.booking-section {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.5rem;
    color: var(--text-dark);
    overflow: hidden;
}

.booking-section form {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

.booking-section h3 {
    margin-top: 0;
    color: var(--primary);
    margin-bottom: 1.25rem;
    font-size: 1.1rem;
}

.booking-section .form-group {
    margin-bottom: 1rem;
    max-width: 100%;
    overflow: hidden;
}

.booking-section .form-group input,
.booking-section .form-group textarea,
.booking-section .form-group select {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
    max-width: 100%;
}

.checkbox-group {
    display: flex;
    align-items: center;
}

.checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-weight: 500;
    font-size: 1rem;
    gap: 0.5rem;
    padding: 0.5rem 0;
    user-select: none;
}

.checkbox-label input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin: 0;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.25rem;
    flex-wrap: wrap;
}

/* ===== DELETE MODAL ===== */
.delete-modal {
    background: #fff;
    color: var(--text-dark);
    border-radius: var(--radius);
    padding: 1.5rem;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
}

.delete-modal h3 {
    color: #dc3545;
    margin-bottom: 0.75rem;
    font-size: 1.2rem;
}

.delete-modal p {
    margin-bottom: 1.25rem;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.delete-modal .modal-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

/* ===== DOCUMENTS PANEL ===== */
.documents-panel {
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
    padding: 1.5rem;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.documents-panel h2 {
    margin-bottom: 1.5rem;
    font-size: 1.4rem;
    color: var(--text-dark);
}

.documents-panel h3 {
    margin-bottom: 1.25rem;
    font-size: 1.1rem;
    color: #444;
}

/* ===== UPLOAD SECTION ===== */
.upload-section {
    background: #f9f9fb;
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    color: var(--text-dark);
    border: 1px solid #eee;
}

.upload-section h3 {
    color: var(--primary);
    margin-top: 0;
}

.upload-form {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
    flex-wrap: wrap;
}

.file-input-wrapper {
    flex: 1;
    min-width: 180px;
    position: relative;
}

.file-input-wrapper input[type="file"] {
    display: none;
}

.file-label {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1rem;
    background: #f0f0f0;
    border: 2px dashed var(--primary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-align: center;
    font-weight: 500;
    transition: all var(--transition);
    color: var(--primary);
    min-height: 2.5rem;
    word-break: break-word;
    font-size: 0.9rem;
}

.file-label:hover {
    background: #f8f8f8;
    border-color: var(--primary-light);
    color: var(--primary-light);
}

.language-select-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.language-select-wrapper label {
    font-size: 0.8rem;
    color: #555;
    font-weight: 500;
}

.language-select-wrapper select {
    padding: 0.6rem 0.9rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    background: #fff;
    cursor: pointer;
}

.source-lang {
    color: var(--primary);
    font-weight: 500;
}

.upload-status {
    margin-top: 0.75rem;
    padding: 0.7rem 1rem;
    border-radius: var(--radius-sm);
    font-weight: 500;
    display: none;
    font-size: 0.9rem;
}

.upload-status.loading { display: block; background: #e3f2fd; color: #1976d2; }
.upload-status.success { display: block; background: #e8f5e9; color: #388e3c; }
.upload-status.error { display: block; background: #ffebee; color: #d32f2f; }

/* ===== DOCUMENTS LIST ===== */
.documents-list-section {
    background: #f9f9fb;
    border-radius: var(--radius);
    padding: 1.5rem;
    color: var(--text-dark);
    border: 1px solid #eee;
}

.documents-list-section h3 {
    color: var(--primary);
    margin-top: 0;
}

.documents-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.no-documents {
    text-align: center;
    padding: 2rem;
    color: #999;
    font-style: italic;
}

.error-message {
    text-align: center;
    padding: 1rem;
    background: #ffebee;
    color: #d32f2f;
    border-radius: var(--radius-sm);
}

.document-item {
    /* Styles handled inline in documents.js */
}

.document-item:hover {
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
}

.document-info {
    flex: 1;
    min-width: 0;
}

.document-name {
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 0.3rem;
    word-break: break-word;
    font-size: 0.95rem;
}

.document-meta {
    display: flex;
    gap: 0.75rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    flex-wrap: wrap;
}

.file-size::before { content: "📦 "; }
.upload-date::before { content: "📅 "; }

.document-actions {
    display: flex;
    gap: 0.4rem;
    margin-left: 0.75rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.btn-preview,
.btn-download,
.btn-translate,
.document-actions .btn-delete {
    padding: 0.45rem 0.7rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    transition: all var(--transition);
    white-space: nowrap;
    touch-action: manipulation;
}

.btn-preview { background: #e3f2fd; color: #1976d2; }
.btn-preview:hover { background: #bbdefb; }
.btn-download { background: #e8f5e9; color: #388e3c; }
.btn-download:hover { background: #c8e6c9; }
.btn-translate { background: #e3f2fd; color: #1976d2; }
.btn-translate:hover { background: #bbdefb; }
.document-actions .btn-delete { background: #ffebee; color: #d32f2f; }
.document-actions .btn-delete:hover { background: #ffcdd2; }

/* ===== TRANSLATIONS ===== */
.translations-list {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
    margin-top: 0.4rem;
}

.translation-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    background: #d4edda;
    color: #155724;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
}

.translation-badge::before { content: "✓ "; }

/* Modal select */
.modal select {
    width: 100%;
    padding: 0.7rem 0.9rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-family: inherit;
    background: #fff;
    color: var(--text-dark);
}

.modal select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(118, 75, 162, 0.1);
}

/* Loading spinner */
@keyframes spin {
    to { transform: rotate(360deg); }
}

.upload-status.loading::before {
    content: "⏳ ";
    display: inline-block;
    margin-right: 0.4rem;
}

/* ===== RESPONSIVE: MOBILE (max-width: 768px) ===== */
@media (max-width: 768px) {
    :root {
        --header-height: 52px;
    }

    .hamburger {
        display: flex;
    }

    .tabs {
        position: fixed;
        top: var(--header-height);
        left: 0;
        right: 0;
        bottom: 0;
        background: #0d0517;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        flex-direction: column;
        align-items: stretch;
        padding: 2rem 1.5rem;
        gap: 0.5rem;
        z-index: 9999;
        transform: translateX(100%);
        transition: transform 0.3s ease;
        overflow-y: auto;
    }

    .tabs.open {
        transform: translateX(0);
    }

    .tab {
        padding: 1rem 1.5rem;
        font-size: 1.2rem;
        text-align: left;
        border-radius: var(--radius);
        color: #fff;
        font-weight: 600;
    }

    .tab.active {
        background: rgba(255, 255, 255, 0.2);
        color: #fff;
    }

    .tab-content {
        padding: 0.75rem;
    }

    /* Home */
    .container {
        padding: 1.5rem 0.75rem;
    }

    .container .btn {
        display: block;
        width: 100%;
        margin-bottom: 0.75rem;
        margin-left: 0 !important;
    }

    /* Requests */
    .requests-panel {
        padding: 1rem;
    }

    .requests-table {
        font-size: 0.8rem;
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .requests-table th,
    .requests-table td {
        padding: 0.5rem;
        white-space: nowrap;
    }

    /* Chat */
    .chat-panel {
        max-height: 100%;
        border-radius: 0;
    }

    .language-buttons {
        justify-content: center;
    }

    .lang-btn {
        flex: 1;
        text-align: center;
        padding: 0.5rem;
        font-size: 0.8rem;
    }

    .message-content {
        max-width: 85%;
    }

    /* Calendar */
    .calendar-panel {
        padding: 0.75rem;
    }

    .calendar-header {
        flex-wrap: nowrap;
        gap: 0.3rem;
    }

    .calendar-header h2 {
        font-size: 0.75rem;
    }

    .btn-nav {
        padding: 0.45rem 0.75rem;
        font-size: 0.8rem;
        flex: 1;
    }

    .calendar-table {
        min-width: unset;
    }

    .calendar-table .time-header,
    .calendar-table .time-cell {
        width: 65px;
        min-width: 65px;
    }

    .booking-section {
        padding: 1rem;
    }

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

    #timeInputs {
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
    }

    .form-actions {
        flex-direction: column;
    }

    .form-actions button {
        width: 100%;
    }

    /* Documents */
    .documents-panel {
        padding: 1rem;
    }

    .upload-section,
    .documents-list-section {
        padding: 1rem;
    }

    .upload-form {
        flex-direction: column;
    }

    .file-input-wrapper {
        width: 100%;
        min-width: unset;
    }

    .upload-form .btn-submit {
        width: 100%;
    }

    .document-item {
        /* Handled inline */
    }

    .document-actions {
        /* Handled inline */
    }

    .document-actions button {
        /* Handled inline */
    }

    /* Modal */
    .modal {
        padding: 1.25rem;
        max-height: 85vh;
    }

    .modal-actions {
        flex-direction: column-reverse;
    }

    .modal-actions button {
        width: 100%;
    }

    /* Full day events */
    .full-day-events-row {
        grid-template-columns: 65px repeat(7, 1fr);
    }
}

/* ===== RESPONSIVE: SMALL PHONES (max-width: 480px) ===== */
@media (max-width: 480px) {
    .calendar-table {
        min-width: unset;
        width: 100%;
    }

    .calendar-table .time-header,
    .calendar-table .time-cell {
        width: 55px;
        min-width: 55px;
    }

    .calendar-table .time-cell .moscow-time {
        font-size: 0.65rem;
    }

    .calendar-table .time-cell .edt-time {
        font-size: 0.55rem;
    }

    .calendar-table .day-name { font-size: 0.7rem; }
    .calendar-table .day-number { font-size: 0.9rem; }
    .calendar-table .day-date { font-size: 0.6rem; }
}

/* Mobile day selector */
.mobile-day-selector {
    display: none;
    gap: 4px;
    padding: 8px;
    overflow-x: auto;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 10px;
}

.mobile-day-btn {
    flex: 1;
    min-width: 40px;
    padding: 6px 4px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: white;
    cursor: pointer;
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    transition: all 0.2s;
}

.mobile-day-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: transparent;
}

.mobile-day-btn .day-label {
    display: block;
    font-size: 10px;
    opacity: 0.8;
}

.mobile-day-btn .day-num {
    display: block;
    font-size: 14px;
    font-weight: 700;
}

@media (max-width: 768px) {
    .mobile-day-selector {
        display: flex;
    }
    
    .calendar-table {
        min-width: unset;
        width: 100%;
    }
    
    /* Hide all day columns except the active one */
    .calendar-table .day-header { display: none; }
    .calendar-table .day-cell { display: none; }
    .calendar-table .day-header.mobile-visible { display: table-cell; }
    .calendar-table .day-cell.mobile-visible { display: table-cell; }
}

    .chat-form .btn-submit {
        padding: 0.7rem 0.9rem;
        font-size: 0.85rem;
    }

    .document-actions {
        /* Handled inline */
    }

    .btn-nav {
        font-size: 0.75rem;
        padding: 0.4rem 0.6rem;
    }

    h1 {
        font-size: 1.6rem;
    }
}

/* ===== RESPONSIVE: LARGE SCREENS (min-width: 769px) ===== */
@media (min-width: 769px) {
    .hamburger {
        display: none;
    }

    .tabs {
        display: flex;
    }

    .tab-content {
        padding: 1.5rem 2rem;
    }

    .calendar-table .time-header,
    .calendar-table .time-cell {
        width: 100px;
        min-width: 100px;
    }

    .full-day-events-row {
        grid-template-columns: 100px repeat(7, 1fr);
    }
}

/* ===== RESPONSIVE: WIDE DESKTOP (min-width: 1200px) ===== */
@media (min-width: 1200px) {
    .tab-content {
        padding: 2rem 3rem;
    }

    .chat-panel {
        max-height: 100%;
    }
}

/* ===== ACCESSIBILITY & CROSS-BROWSER ===== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus visible for keyboard navigation */
:focus-visible {
    outline: 3px solid var(--primary-light);
    outline-offset: 2px;
}

/* Remove tap highlight on mobile */
button, a, input, select, textarea {
    -webkit-tap-highlight-color: transparent;
}

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

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.35);
}

/* Print styles */
@media print {
    .nav-header, .tabs, .hamburger, .toast, .notification {
        display: none !important;
    }
    body {
        background: #fff;
        color: #000;
    }
    .tab-content {
        display: block !important;
    }
}


/* ===== NEW MESSENGER-STYLE CHAT ===== */
.chat-header-new {
    padding: 1rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

.chat-header-content h2 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.chat-header-subtitle {
    margin: 4px 0 0 0;
    font-size: 0.85rem;
    opacity: 0.9;
}

.chat-disclaimer {
    padding: 10px 15px;
    background: #fff3cd;
    color: #856404;
    border-bottom: 1px solid #ffeaa7;
    font-size: 0.85rem;
    text-align: center;
    flex-shrink: 0;
}

.chat-messages-container {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
    background: #f5f5f5;
}

.chat-messages {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 15px;
    flex: 1;
}

.chat-message-item {
    display: flex;
    margin-bottom: 8px;
    animation: slideIn 0.3s ease-out;
}

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

.chat-message-item.sent {
    justify-content: flex-end;
}

.chat-message-item.received {
    justify-content: flex-start;
}

.chat-bubble {
    max-width: 75%;
    padding: 10px 14px;
    border-radius: 18px;
    word-wrap: break-word;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.chat-message-item.sent .chat-bubble {
    background: #667eea;
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-message-item.received .chat-bubble {
    background: white;
    color: #333;
    border-bottom-left-radius: 4px;
    border: 1px solid #e0e0e0;
}

.chat-bubble-text {
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.4;
}

.chat-bubble-time {
    font-size: 0.75rem;
    opacity: 0.7;
    margin-top: 4px;
    display: block;
}

.chat-input-section {
    padding: 12px 15px;
    padding-bottom: calc(12px + var(--safe-bottom));
    background: white;
    border-top: 1px solid #e0e0e0;
    flex-shrink: 0;
}

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

.chat-input-wrapper {
    display: flex;
    flex-direction: row;
    align-items: flex-end;
    gap: 10px;
}

.chat-recipient-field,
.chat-subject-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.chat-recipient-field label,
.chat-subject-field label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #333;
}

.chat-recipient-field input,
.chat-subject-field input {
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.95rem;
    font-family: inherit;
}

.chat-recipient-field input:focus,
.chat-subject-field input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.chat-message-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-message-field textarea {
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.95rem;
    font-family: inherit;
    resize: vertical;
    min-height: 70px;
    max-height: 150px;
}

.chat-message-field textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.chat-send-btn {
    padding: 12px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.chat-send-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.chat-send-btn:active {
    transform: translateY(0);
}

/* Empty state */
.chat-empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #999;
    text-align: center;
    padding: 20px;
    font-size: 1rem;
}

/* Responsive for mobile */
@media (max-width: 768px) {
    .chat-bubble {
        max-width: 85%;
    }

    .chat-messages {
        padding: 10px;
        gap: 6px;
    }

    .chat-input-section {
        padding: 10px 12px;
        padding-bottom: calc(10px + var(--safe-bottom));
    }

    .chat-form-new {
        gap: 8px;
    }

    .chat-input-wrapper {
        gap: 8px;
    }

    .chat-send-btn {
        padding: 10px 16px;
        font-size: 0.9rem;
    }

    .chat-header-new {
        padding: 12px;
    }

    .chat-header-content h2 {
        font-size: 1rem;
    }

    .chat-disclaimer {
        padding: 8px 12px;
        font-size: 0.8rem;
    }
}

/* iPad/Tablet */
@media (min-width: 769px) and (max-width: 1024px) {
    .chat-bubble {
        max-width: 60%;
    }
}

/* Event form modal compact spacing */
#eventFormModal .form-group {
    margin-bottom: 5px;
}

#eventFormModal .form-row {
    gap: 5px;
    margin-bottom: 5px;
}

#eventFormModal .modal-actions {
    gap: 5px;
    margin-top: 5px;
    flex-direction: row !important;
}

#eventFormModal .modal-actions button {
    width: auto !important;
    flex: 1;
}
}

/* Event type colors */
.event-block.event-medicine {
    background: #28a745 !important;
    border-color: #1e7e34 !important;
}

.event-block.event-recreational {
    background: #6f42c1 !important;
    border-color: #5a32a3 !important;
}

.event-block.event-payment {
    background: #ffc107 !important;
    border-color: #e0a800 !important;
    color: #333 !important;
}

.event-block .event-price {
    font-size: 0.65rem;
    font-weight: 700;
    opacity: 0.9;
    margin-top: 1px;
}

/* Lock to portrait - show rotate message in landscape on mobile */
@media (max-height: 500px) and (orientation: landscape) {
    body::after {
        content: 'Please rotate your device to portrait mode';
        position: fixed;
        inset: 0;
        background: #522687;
        color: #fff;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 18px;
        z-index: 99999;
        text-align: center;
        padding: 20px;
    }
}
