/**
 * Основные стили для приложения
 */

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

:root {
    --primary-color: #007bff;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #17a2b8;
    --dark-color: #343a40;
    --light-color: #f8f9fa;
    --border-color: #dee2e6;
    --text-color: #212529;
    --border-radius: 8px;
    --box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--light-color);
}

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

/* Карточки */
.auth-card {
    max-width: 500px;
    margin: 50px auto;
    padding: 40px;
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
}

.auth-card h1 {
    margin-bottom: 10px;
    color: var(--dark-color);
    font-size: 28px;
}

.auth-card .description {
    color: #6c757d;
    margin-bottom: 30px;
}

.auth-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 4px;
}

.auth-tab {
    padding: 8px 16px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: var(--border-radius) var(--border-radius) 0 0;
    font-size: 14px;
    color: #495057;
}

.auth-tab--active {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-bottom-color: #ffffff;
    color: var(--primary-color);
    font-weight: 500;
}

.auth-tab-content {
    display: none;
}

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

/* Формы */
.form-group {
    margin-bottom: 20px;
}

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

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

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

.form-group small {
    display: block;
    margin-top: 5px;
    color: #6c757d;
    font-size: 14px;
}

.checkbox-group {
    display: block;
}

.checkbox-group label {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: flex-start;
    column-gap: 6px;
    font-weight: normal;
    color: #495057;
}

.checkbox-group input[type="checkbox"] {
    margin-top: 3px;
}

.checkbox-group span {
    line-height: 1.4;
}

/* Кнопки */
.btn {
    display: inline-block;
    padding: 12px 24px;
    border: none;
    border-radius: var(--border-radius);
    font-size: 16px;
    font-weight: 500;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.1s;
}

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

.btn:not(:disabled):hover {
    transform: translateY(-1px);
}

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

.btn-primary {
    background-color: var(--primary-color);
    color: white;
    width: 100%;
}

.btn-primary:hover:not(:disabled) {
    background-color: #0056b3;
}

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

.btn-success:hover:not(:disabled) {
    background-color: #218838;
}

.btn-danger {
    background-color: var(--danger-color);
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background-color: #c82333;
}

/* Информация о звонке */
.call-info {
    text-align: center;
    margin-top: 30px;
}

.call-info h2 {
    margin-bottom: 20px;
    color: var(--dark-color);
}

.phone-number {
    font-size: 32px;
    font-weight: bold;
    color: var(--primary-color);
    margin: 20px 0;
    padding: 15px;
    background: var(--light-color);
    border-radius: var(--border-radius);
}

.call-link {
    margin: 20px 0;
}

.phone-icon {
    font-size: 20px;
    margin-right: 8px;
}

.hint {
    color: #6c757d;
    font-size: 14px;
    margin-top: 15px;
}

.timer {
    margin: 20px 0;
    font-size: 18px;
    font-weight: 500;
}

.timer span:last-child {
    color: var(--primary-color);
    font-size: 24px;
}

/* Сообщения */
.alert {
    padding: 12px 16px;
    border-radius: var(--border-radius);
    margin: 15px 0;
}

.alert-error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert-success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-info {
    background-color: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

.status-message {
    margin-top: 20px;
}

/* Sticky Header в стиле Apple */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: rgba(251, 251, 253, 0.8);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 0.5px solid rgba(0, 0, 0, 0.1);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 0;
}

.navbar.scrolled {
    background: rgba(251, 251, 253, 0.95);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.navbar-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 44px;
}

.navbar-logo {
    font-size: 17px;
    font-weight: 400;
    color: #1d1d1f;
    text-decoration: none;
    letter-spacing: -0.01em;
    transition: opacity 0.3s;
}

.navbar-logo:hover {
    opacity: 0.8;
    text-decoration: none;
}

.navbar-menu {
    display: flex;
    align-items: center;
    gap: 8px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.navbar-item {
    margin: 0;
}

.navbar-link {
    display: inline-block;
    padding: 8px 16px;
    font-size: 12px;
    font-weight: 400;
    color: #1d1d1f;
    text-decoration: none;
    border-radius: 20px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    letter-spacing: -0.01em;
    white-space: nowrap;
}

.navbar-link:hover {
    background: rgba(0, 0, 0, 0.05);
    text-decoration: none;
    color: #1d1d1f;
}

.navbar-link.navbar-link--primary {
    background: #0071e3;
    color: #ffffff;
}

.navbar-link.navbar-link--primary:hover {
    background: #0077ed;
    text-decoration: none;
    color: #ffffff;
}

.navbar-link.navbar-link--danger {
    color: #d70015;
}

.navbar-link.navbar-link--danger:hover {
    background: rgba(215, 0, 21, 0.1);
    color: #d70015;
}

/* Мобильное меню */
.navbar-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    color: #1d1d1f;
    font-size: 17px;
    line-height: 1;
    width: 32px;
    height: 32px;
    display: none;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.navbar-toggle:hover {
    background: rgba(0, 0, 0, 0.05);
}

.navbar-toggle span {
    display: block;
    font-weight: 300;
}

.navbar-menu-mobile {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: rgba(251, 251, 253, 0.98);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 0.5px solid rgba(0, 0, 0, 0.1);
    padding: 8px 0;
    flex-direction: column;
    gap: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.navbar-menu-mobile.active {
    display: flex;
}

.navbar-menu-mobile .navbar-item {
    width: 100%;
}

.navbar-menu-mobile .navbar-link {
    width: 100%;
    text-align: left;
    padding: 12px 22px;
    font-size: 14px;
    border-radius: 0;
    display: block;
}

.navbar-menu-mobile .navbar-link:hover {
    background: rgba(0, 0, 0, 0.05);
}

/* Отступ для контента под sticky header */
body.has-navbar {
    padding-top: 44px;
}

/* Старый header для обратной совместимости */
.header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    margin-bottom: 30px;
}

.header-main {
    max-width: 70%;
}

.header-subtitle {
    color: #6c757d;
    font-size: 14px;
}

.header-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.user-password-card {
    margin-bottom: 30px;
    padding: 20px;
    background: #ffffff;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
}

.user-password-value {
    font-family: monospace;
    font-size: 18px;
    padding: 8px 12px;
    border-radius: var(--border-radius);
    background: #f1f3f5;
    display: inline-block;
    margin-bottom: 8px;
}

.user-password-hint {
    font-size: 14px;
    color: #6c757d;
}

.text-danger {
    color: var(--danger-color);
    font-weight: 500;
}

.date-unavailable {
    color: #6c757d;
    border-color: #ced4da;
}

/* Список услуг в кабинете */
.services-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.service-card {
    background: #ffffff;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 16px 16px 12px;
    border: 1px solid var(--border-color);
}

.service-card-body h3 {
    margin-bottom: 8px;
}

.service-description {
    margin-bottom: 10px;
    color: #495057;
}

.service-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 14px;
    color: #6c757d;
}

.service-card-footer {
    border-top: 1px dashed var(--border-color);
    margin-top: 12px;
    padding-top: 12px;
    display: flex;
    justify-content: flex-end;
}

.service-card-footer .btn-primary {
    width: auto;
}

/* Список записей */
.bookings-section {
    margin-bottom: 40px;
}

.bookings-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 15px;
}

.booking-item {
    background: #ffffff;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    border: 1px solid var(--border-color);
    padding: 16px 16px 12px;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 12px;
}

.booking-item--past {
    opacity: 0.9;
    background: #f8f9fa;
}

.booking-main {
    flex: 1 1 260px;
}

.booking-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 4px;
}

.booking-datetime {
    font-weight: 500;
    margin-bottom: 6px;
}

.booking-comment {
    font-size: 14px;
    color: #495057;
}

.booking-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

.booking-actions .btn {
    width: auto;
}

.status-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
}

.alert-info.status-badge,
.alert-success.status-badge,
.alert-error.status-badge {
    border-radius: 999px;
}

/* Используем цвета alert-классов для бейджей статуса */
.alert-info.status-badge {
    background-color: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

.alert-success.status-badge {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-error.status-badge {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Заголовки */
h1,
h2,
h3,
h4,
h5,
h6 {
    color: var(--dark-color);
    margin-bottom: 15px;
}

/* Ссылки */
a {
    color: var(--primary-color);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* Адаптивность */
@media (max-width: 768px) {
    .auth-card {
        margin: 20px auto;
        padding: 30px 20px;
    }

    .phone-number {
        font-size: 24px;
    }

    .container {
        padding: 10px;
    }

    .header {
        flex-direction: column;
        align-items: flex-start;
    }

    .header-main {
        max-width: 100%;
    }

    .header-actions {
        width: 100%;
    }

    .header-actions .btn {
        width: 100%;
    }

    .booking-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .booking-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .booking-actions .btn {
        width: 100%;
    }

    .checkbox-group span {
        font-size: 13px;
    }

    /* Мобильная навигация */
    .navbar-container {
        padding: 0 16px;
        height: 44px;
    }

    .navbar-menu {
        display: none;
    }

    .navbar-toggle {
        display: flex;
    }

    .navbar-logo {
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    .navbar-container {
        padding: 0 12px;
    }

    .navbar-logo {
        font-size: 15px;
    }
}

/* Переписка и сообщения */
.unread-badge {
    display: inline-block;
    background: #dc3545;
    color: white;
    border-radius: 10px;
    padding: 2px 6px;
    font-size: 11px;
    font-weight: bold;
    margin-left: 5px;
    min-width: 18px;
    text-align: center;
}

/* Модальное окно в стиле Apple Messages */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.4);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
}

.modal-content {
    background-color: #ffffff;
    margin: 2% auto;
    padding: 0;
    border-radius: 12px;
    width: 95%;
    max-width: 800px;
    height: 90vh;
    max-height: 900px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 0.5px solid rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(251, 251, 253, 0.8);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    flex-shrink: 0;
}

.modal-header h2 {
    margin: 0;
    font-size: 17px;
    font-weight: 400;
    color: #1d1d1f;
    letter-spacing: -0.01em;
}

.modal-title-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.modal-close {
    font-size: 24px;
    font-weight: 300;
    color: #1d1d1f;
    cursor: pointer;
    line-height: 1;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: background-color 0.2s;
}

.modal-close:hover {
    background: rgba(0, 0, 0, 0.05);
}

.modal-body {
    padding: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #f5f5f7;
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    background: #f5f5f7;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

.messages-container::-webkit-scrollbar {
    width: 8px;
}

.messages-container::-webkit-scrollbar-track {
    background: transparent;
}

.messages-container::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

.messages-container::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

.message {
    display: flex;
    flex-direction: column;
    max-width: 75%;
    margin-bottom: 4px;
    animation: messageSlideIn 0.3s ease-out;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-admin {
    align-self: flex-start;
}

.message-client {
    align-self: flex-end;
}

.message-bubble {
    padding: 10px 14px;
    border-radius: 18px;
    word-wrap: break-word;
    white-space: pre-wrap;
    line-height: 1.4;
    font-size: 15px;
    position: relative;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.message-admin .message-bubble {
    background: #ffffff;
    color: #1d1d1f;
    border-bottom-left-radius: 4px;
}

.message-client .message-bubble {
    background: #007aff;
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

.message-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
    font-size: 13px;
    padding: 0 4px;
}

.message-admin .message-header {
    justify-content: flex-start;
}

.message-client .message-header {
    justify-content: flex-end;
}

.message-header strong {
    color: #6c757d;
    font-weight: 500;
}

.message-client .message-header strong {
    color: rgba(255, 255, 255, 0.8);
}

.message-time {
    color: #8e8e93;
    font-size: 11px;
    font-weight: 400;
}

.message-client .message-time {
    color: rgba(255, 255, 255, 0.7);
}

.message-text {
    margin: 0;
    line-height: 1.4;
}

.message-input-wrapper {
    padding: 12px 16px;
    background: rgba(251, 251, 253, 0.8);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-top: 0.5px solid rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

.message-input-container {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    max-width: 100%;
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 28px;
    padding: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.message-input-container:focus-within {
    border-color: rgba(0, 122, 255, 0.55);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.12);
}

.message-input-container textarea {
    flex: 1 1 auto;
    min-width: 0;
    padding: 10px 14px;
    border: none;
    border-radius: 22px;
    font-size: 15px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    resize: none;
    min-height: 52px;
    max-height: 220px;
    line-height: 1.4;
    background: transparent;
    color: #1d1d1f;
    transition: all 0.2s;
}

.message-input-container textarea:focus {
    outline: none;
}

.message-input-container textarea::placeholder {
    color: #8e8e93;
}

.message-send-btn {
    height: 44px;
    width: auto;
    min-width: 132px;
    padding: 0 16px;
    border-radius: 22px;
    font-size: 15px;
    font-weight: 500;
    background: linear-gradient(180deg, #0a84ff 0%, #0077ed 100%);
    color: #ffffff;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.message-send-btn:hover {
    background: linear-gradient(180deg, #3098ff 0%, #0a84ff 100%);
    transform: translateY(-1px);
}

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

.message-send-text {
    line-height: 1;
}

.message-send-icon {
    font-size: 14px;
    line-height: 1;
    transform: translateX(1px);
}

/* Кнопки удаления сообщений */
.btn-delete-mode {
    background: transparent;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 6px;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-delete-mode:hover {
    background: rgba(0, 0, 0, 0.05);
}

.btn-delete-selected {
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

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

.message-delete-btn {
    background: rgba(0, 0, 0, 0.05);
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    color: #8e8e93;
    opacity: 0;
    transition: all 0.2s;
    margin-left: 8px;
    padding: 0;
    line-height: 1;
}

.message:hover .message-delete-btn {
    opacity: 1;
}

.message-delete-btn:hover {
    background: rgba(220, 53, 69, 0.1);
    color: #dc3545;
}

.message-checkbox {
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    cursor: pointer;
    z-index: 10;
    accent-color: #007aff;
    cursor: pointer;
}

.message-checkbox:checked {
    accent-color: #007aff;
}

.message {
    position: relative;
    transition: padding-left 0.2s;
}

.messages-container.delete-mode .message {
    padding-left: 36px;
}

@media (max-width: 768px) {
    .modal-content {
        width: 100%;
        height: 100vh;
        max-height: 100vh;
        margin: 0;
        border-radius: 0;
    }

    .modal-header {
        padding: 12px 16px;
        align-items: flex-start;
    }

    .modal-title-actions {
        flex-wrap: wrap;
        gap: 8px;
        padding-right: 8px;
    }

    .messages-container {
        padding: 16px;
    }

    .message {
        max-width: 92%;
    }

    .message-input-wrapper {
        padding: 10px 12px;
    }

    .message-input-container {
        gap: 8px;
        flex-wrap: nowrap;
        align-items: flex-end;
        border-radius: 24px;
        padding: 5px;
    }

    .message-input-container textarea {
        font-size: 16px;
        width: auto;
        /* Предотвращает зум на iOS */
        min-height: 56px;
    }

    .message-send-btn {
        height: 44px;
        min-width: 100px;
        padding: 0 14px;
    }
}

@media (max-width: 480px) {
    .message-send-btn {
        min-width: 44px;
        width: 44px;
        padding: 0;
        border-radius: 50%;
    }

    .message-send-text {
        display: none;
    }

    .message-send-icon {
        font-size: 15px;
        transform: translateX(0);
    }
}
