/**
 * Стили приложения
 * Автор: Ратников Евгений
 * Email: eratnikstudio@gmail.com
 * Сайт: https://ersweb.su/
 */

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

:root {
    --primary-color: #2196F3;
    --secondary-color: #FFC107;
    --success-color: #4CAF50;
    --danger-color: #F44336;
    --warning-color: #FF9800;
    --dark-color: #333;
    --light-color: #f5f5f5;
    --border-color: #ddd;
    --text-color: #333;
    --text-light: #666;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    color: var(--text-color);
    background-color: #f9f9f9;
    line-height: 1.6;
}

/* Шапка */
.header {
    background: linear-gradient(135deg, var(--primary-color), #1976D2);
    color: white;
    padding: 1rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.nav-menu {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.nav-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.3s;
    white-space: nowrap;
}

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

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

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.login-btn, .user-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: background 0.3s;
}

.login-btn:hover, .user-btn:hover {
    background: rgba(255,255,255,0.3);
}

.user-photo {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

/* Мобильное меню */
.mobile-menu-btn {
    display: none;
    flex-direction: column;
    justify-content: space-between;
    width: 30px;
    height: 21px;
    cursor: pointer;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 2000;
    background: rgba(255,255,255,0.9);
    padding: 0.5rem;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.mobile-menu-btn span {
    display: block;
    height: 3px;
    width: 100%;
    background-color: var(--primary-color);
    border-radius: 3px;
    transition: all 0.3s;
}

.mobile-menu {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    z-index: 1999;
}

.mobile-menu-content {
    position: absolute;
    top: 0;
    left: 0;
    width: 80%;
    max-width: 300px;
    height: 100%;
    background: white;
    padding: 4rem 1rem 1rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.mobile-nav-btn {
    background: var(--light-color);
    border: none;
    color: var(--text-color);
    padding: 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    text-align: left;
    transition: background 0.3s;
}

.mobile-nav-btn:hover {
    background: var(--border-color);
}

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

/* Основной контент */
.main-content {
    max-width: 100%;
    margin: 0 auto;
    padding: 1rem;
}

.quick-actions-buttons {
    display: block ruby;
}

/* Фильтры */
.filters {
    background: white;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end;
}

.mobile-filter-toggle-wrapper {
    display: none;
    margin-bottom: 1rem;
}

.mobile-filter-toggle {
    width: 100%;
    display: inline-flex;
    justify-content: center;
    align-items: center;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1;
    min-width: 150px;
}

.filter-group label {
    font-size: 0.85rem;
    color: var(--text-light);
}

.filter-group select,
.filter-group input {
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.9rem;
}

/* Кнопки */
.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

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

.btn-primary:hover {
    background: #1976D2;
}

.btn-secondary {
    background: var(--text-light);
    color: white;
}

.btn-secondary:hover {
    background: var(--dark-color);
}

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

.btn-success:hover {
    background: #45a049;
}

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

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

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

.btn-warning:hover {
    background: #e68900;
}

.btn-small {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
}

/* Таблица */
.table-container {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    overflow-x: auto;
}

.requests-table {
    width: 100%;
    border-collapse: collapse;
}

.requests-table th,
.requests-table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.requests-table th {
    background: var(--light-color);
    font-weight: 600;
    position: sticky;
    top: 0;
    font-size: 11px;
}

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

/* Цветовая индикация строк по срокам */
.request-row.status-green {
    background-color: #e8f5e9;
}

.request-row.status-yellow {
    background-color: #fff9c4;
}

.request-row.status-red {
    background-color: #ffebee;
}

.request-row.status-archived {
    background-color: #f5f5f5;
    opacity: 0.8;
}

.request-row.status-failed {
    border-left: 4px solid var(--danger-color);
    background-color: #fdecea;
}

/* Специалист в таблице */
.specialist-cell {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.specialist-photo {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    position: relative;
}

.online-indicator {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid white;
}

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

.online-indicator.offline {
    background: var(--danger-color);
}

.specialist-name {
    font-weight: 500;
}

/* Мобильная версия заявок */
.requests-list-mobile {
    display: none;
    flex-direction: column;
    gap: 1rem;
}

.request-card {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    padding: 1rem;
    position: relative;
    overflow: hidden;
}

.request-card.status-green {
    border-left: 4px solid var(--success-color);
}

.request-card.status-yellow {
    border-left: 4px solid var(--warning-color);
}

.request-card.status-red {
    border-left: 4px solid var(--danger-color);
}

.request-card.status-archived {
    border-left: 4px solid var(--text-light);
}

.request-card.status-failed {
    border-left: 4px solid var(--danger-color);
    background-color: #fdecea;
}

.request-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
}

.request-card-title {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 0.25rem;
    line-height: 1.3;
}

.request-card-district {
    color: var(--text-light);
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
}

.request-card-address {
    color: var(--primary-color);
    text-decoration: none;
    font-size: 0.9rem;
    word-break: break-word;
}

.request-card-number {
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
}

.request-card-phone {
    margin-bottom: 0.5rem;
}

.request-card-phone a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

.request-card-meta {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
    color: var(--text-light);
}

.request-card-specialist {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.25rem;
}

.more-details-btn {
    background: var(--light-color);
    border: none;
    color: var(--text-color);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    width: 100%;
    margin-bottom: 0.75rem;
    transition: background 0.3s;
}

.more-details-btn:hover {
    background: var(--border-color);
}

.request-card-details {
    display: none;
    border-top: 1px solid var(--border-color);
    padding-top: 0.75rem;
}

.request-card-details.show {
    display: block;
}

.request-card-comment {
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
    line-height: 1.4;
}

.request-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: flex-start;
}

.request-card-actions .btn {
    flex: 1;
    min-width: 120px;
    margin-bottom: 0.25rem;
}

/* Модальные окна */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    overflow-y: auto;
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 2rem;
    border-radius: 8px;
    width: 90%;
    max-width: 600px;
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    position: absolute;
    right: 1rem;
    top: 1rem;
}

.close:hover {
    color: var(--dark-color);
}

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

.form-group label {
    display: block;
    margin-bottom: 0.25rem;
    font-weight: 500;
    color: var(--text-color);
}

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

.form-group textarea {
    resize: vertical;
}

.error-message {
    color: var(--danger-color);
    margin-top: 0.5rem;
    font-size: 0.85rem;
}

.remember-me .checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.form-hint {
    display: block;
    margin-top: 0.25rem;
    color: #6b7280;
    font-size: 0.85rem;
}

.comment-block {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 14px;
}

.comment-title {
    font-weight: 600;
    margin-right: 0.35rem;
}

.final-comment {
    background: #f0f7ff;
    border: 1px solid #d1e6ff;
    border-radius: 6px;
    padding: 0.5rem;
}

.history-block,
.address-history {
    background: #f8fafc;
    border-left: 3px solid var(--primary-color);
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
}

.history-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.history-item {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    padding: 0.25rem 0;
    border-bottom: 1px dashed #e5e7eb;
}

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

.history-time {
    color: #6b7280;
    font-size: 0.85rem;
}

.history-sub {
    color: #6b7280;
    font-size: 0.9rem;
}

.card {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.grid-two {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.75rem;
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

/* Список специалистов */
.search-box {
    margin-bottom: 1rem;
}

.search-box input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.9rem;
}

.specialists-list {
    max-height: 400px;
    overflow-y: auto;
}

.specialist-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background 0.3s;
}

.specialist-item:hover {
    background: var(--light-color);
}

.specialist-item-photo {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
    position: relative;
}

.specialist-item-info {
    flex: 1;
}

.specialist-item-name {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.specialist-item-details {
    font-size: 0.85rem;
    color: var(--text-light);
}

/* Личный кабинет */
.profile-section {
    margin-bottom: 1.5rem;
}

.profile-section h3 {
    margin-bottom: 1rem;
    color: var(--primary-color);
}

/* Установка PWA */
.install-prompt {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    padding: 1rem;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    z-index: 1500;
}

.install-prompt-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.install-prompt-content p {
    flex: 1;
    margin: 0;
}

/* Адаптивность */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        align-items: stretch;
        padding-top: 3rem;
    }
    
    .nav-menu {
        display: none;
    }
    
    .mobile-menu-btn {
        display: flex;
    }
    
    .mobile-filter-toggle-wrapper {
        display: block;
    }
    
    .mobile-filter-toggle {
        display: flex;
    }
    
    .filters {
        flex-direction: column;
        display: none;
    }
    
    .filters.open {
        display: flex;
    }
    
    .filter-group {
        width: 100%;
        min-width: auto;
    }
    
    .requests-table {
        font-size: 0.85rem;
    }
    
    .requests-table th,
    .requests-table td {
        padding: 0.5rem;
    }
    
    .modal-content {
        width: 95%;
        margin: 10% auto;
        padding: 1rem;
    }
    
    .install-prompt-content {
        flex-direction: column;
        text-align: center;
    }
    
    .requests-list-mobile {
        display: flex;
    }
    
    #requestsTableContainer {
        display: none;
    }
    
    .admin-page .table-container,
    #expiredPage .table-container {
        display: block;
        overflow-x: auto;
    }
    
    .request-card-actions {
        flex-direction: column;
    }
    
    .request-card-actions .btn {
        min-width: 100%;
    }
}

@media (max-width: 480px) {
    .quick-actions-buttons {
    display: block;
}
.btn.btn-primary {
        padding: 0.5rem 1rem;
    font-size: 0.7rem;
    margin-bottom: 5px;
    }
    .main-content {
        padding: 0.5rem;
    }
    
    .filters {
        padding: 0.75rem;
    }
    
    .filter-group {
        min-width: 100%;
    }
    
    .btn {
        padding: 0.75rem 1rem;
        font-size: 1rem;
    }
}

/* Страницы админа */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding: 1rem;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.page-header h2 {
    margin: 0;
    color: var(--primary-color);
}

.admin-page {
    background: white;
    padding: 1rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Скрытие элементов для специалистов/админов */
.specialist-only {
    display: none;
}

.admin-only {
    display: none;
}

/* Утилиты */
.text-center {
    text-align: center;
}

.mt-1 {
    margin-top: 0.5rem;
}

.mt-2 {
    margin-top: 1rem;
}

.mb-1 {
    margin-bottom: 0.5rem;
}

.mb-2 {
    margin-bottom: 1rem;
}

.hidden {
    display: none;
}

.failed-label {
    margin-top: 0.35rem;
    color: var(--danger-color);
    font-weight: 600;
    font-size: 0.9rem;
}

/* Адрес ссылка */
.address-link {
    color: var(--primary-color);
    text-decoration: none;
}

.address-link:hover {
    text-decoration: underline;
}

.phone-link {
    color: var(--primary-color);
    text-decoration: none;
}

.phone-link:hover {
    text-decoration: underline;
}

/* Клиенты */
.clients-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    margin-top: 1rem;
}

.client-card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.client-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.client-summary {
    display: flex;
    gap: 0.75rem;
    font-weight: 600;
    color: var(--text-light);
    font-size: 0.9rem;
}

.client-address {
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.client-phone {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
}

.client-meta {
    font-size: 0.9rem;
    color: var(--text-light);
    margin-bottom: 0.75rem;
}

.client-history {
    background: var(--light-color);
    border-radius: 6px;
    padding: 0.75rem;
}

.client-history-item {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.5rem;
}

.client-history-item:last-child {
    margin-bottom: 0;
}

.history-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
}

.history-label {
    color: var(--text-light);
}

.history-status {
    padding: 0.2rem 0.5rem;
    border-radius: 12px;
    font-size: 0.8rem;
    background: var(--border-color);
}

.history-title {
    font-weight: 600;
    margin: 0.35rem 0;
}

.history-comment {
    color: var(--text-light);
    font-size: 0.9rem;
}

.btn-link {
    background: none;
    border: none;
    color: var(--primary-color);
    cursor: pointer;
    padding: 0.25rem 0;
    font-weight: 600;
}

.history-hidden {
    display: none;
}