/**
 * Стили для мобильного интерфейса
 */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #667eea;
    --secondary-color: #764ba2;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-600: #4b5563;
    --gray-800: #1f2937;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--gray-100);
    color: var(--gray-800);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* Заголовок */
.app-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    padding: 15px 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.app-header h1 {
    font-size: 20px;
    font-weight: 600;
}

.header-user {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    min-width: 0;
}

.header-username {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-burger {
    background: rgba(255,255,255,0.2);
    color: white;
    border: none;
    border-radius: 6px;
    width: 40px;
    height: 36px;
    font-size: 20px;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.3s;
}

.btn-burger:hover,
.btn-burger[aria-expanded="true"] {
    background: rgba(255,255,255,0.35);
}

.header-menu {
    display: none;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(255,255,255,0.25);
}

.header-menu.open {
    display: flex;
}

.header-menu .btn-push,
.header-menu .btn-admin,
.header-menu .btn-logout,
.header-menu .city-selector {
    display: block;
    width: 100%;
    max-width: none;
    text-align: center;
    padding: 10px 12px;
}

.btn-logout {
    background: rgba(255,255,255,0.2);
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    text-decoration: none;
    font-size: 14px;
    transition: background 0.3s;
}

.btn-logout:hover {
    background: rgba(255,255,255,0.3);
}

.btn-admin {
    background: rgba(255,255,255,0.2);
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    text-decoration: none;
    font-size: 14px;
    transition: background 0.3s;
}

.btn-admin:hover {
    background: rgba(255,255,255,0.3);
}

.btn-push {
    background: rgba(255,255,255,0.2);
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    border: none;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.3s;
}

.btn-push:hover {
    background: rgba(255,255,255,0.3);
}

.btn-push.enabled {
    background: rgba(16, 185, 129, 0.85);
}

.btn-push.disabled {
    background: rgba(239, 68, 68, 0.85);
}

.city-selector {
    background: rgba(255,255,255,0.9);
    color: var(--gray-800);
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.3);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s;
    max-width: 150px;
}

.city-selector:hover {
    background: white;
}

.city-selector:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(255,255,255,0.5);
}

/* Выбор даты */
.date-selector {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 15px 20px;
    background: white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.date-selector input[type="date"] {
    padding: 10px 15px;
    border: 2px solid var(--gray-200);
    border-radius: 8px;
    font-size: 16px;
    flex: 1;
    max-width: 200px;
}

.btn-date {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 8px;
    font-size: 18px;
    cursor: pointer;
    transition: transform 0.2s;
}

.btn-date:active {
    transform: scale(0.95);
}

/* Кнопка показать все выезды */
.show-all-container {
    display: flex;
    justify-content: center;
    padding: 10px 20px;
    background: white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.btn-show-all {
    background: var(--warning-color);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
    margin: 5px;
    display: inline-block;
}

.btn-show-all:hover {
    background: #d97706;
}

/* Контейнер визитов */
.visits-container {
    padding: 15px;
}

.visit-card {
    background: white;
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.visit-card:active {
    transform: scale(0.98);
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

.visit-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 10px;
}

.visit-header h3 {
    font-size: 18px;
    color: var(--gray-800);
    flex: 1;
}

.visit-status {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.status-pending { background: #fef3c7; color: #92400e; }
.status-in_progress { background: #dbeafe; color: #1e40af; }
.status-completed { background: #d1fae5; color: #065f46; }
.status-cancelled { background: #fee2e2; color: #991b1b; }

.visit-info p {
    font-size: 14px;
    color: var(--gray-600);
    margin: 5px 0;
}

.visit-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.btn-link {
    background: var(--gray-100);
    border: none;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    color: var(--primary-color);
    cursor: pointer;
    transition: background 0.2s;
}

.btn-link:active {
    background: var(--gray-200);
}

/* Модальные окна */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    align-items: flex-start;
    padding: 20px 0;
}

.modal-content {
    background: white;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}

.modal-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 20px;
    font-weight: 600;
}

.btn-close {
    background: rgba(255,255,255,0.2);
    color: white;
    border: none;
    font-size: 28px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.modal-body {
    padding: 20px;
    max-height: 70vh;
    overflow-y: auto;
}

/* Информация о клиенте */
.client-info {
    background: var(--gray-100);
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 20px;
}

.client-detail {
    margin-bottom: 8px;
    font-size: 14px;
}

.client-detail:last-child {
    margin-bottom: 0;
}

.btn-link-full {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 8px;
    width: 100%;
    margin-top: 10px;
    cursor: pointer;
    font-size: 14px;
}

/* Форма */
.form-section {
    margin-bottom: 25px;
}

.form-section h3 {
    font-size: 18px;
    margin-bottom: 12px;
    color: var(--gray-800);
}

/* Категории материалов */
.material-category {
    margin-bottom: 15px;
    border: 1px solid var(--gray-200);
    border-radius: 10px;
    overflow: hidden;
}

.material-search {
    margin-bottom: 15px;
}

.search-input-container {
    position: relative;
    margin-bottom: 10px;
}

.material-search input {
    width: 100%;
    padding: 12px 40px 12px 15px;
    border: 2px solid var(--gray-200);
    border-radius: 10px;
    font-size: 16px;
    background: white;
}

.material-search input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.btn-clear {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--gray-600);
    font-size: 18px;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    transition: background 0.3s;
}

.btn-clear:hover {
    background: var(--gray-200);
    color: var(--gray-800);
}

.search-actions {
    display: flex;
    gap: 10px;
}

.btn-secondary {
    background: var(--gray-200);
    color: var(--gray-800);
    border: none;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.3s;
}

.btn-secondary:hover {
    background: var(--gray-300);
}

.category-header {
    background: var(--gray-100);
    padding: 12px 15px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
}

.category-name {
    font-weight: 600;
    font-size: 16px;
}

.material-count {
    font-weight: 400;
    color: var(--gray-600);
    font-size: 14px;
}

.toggle-icon {
    transition: transform 0.3s;
    font-size: 14px;
}

.material-category.collapsed .toggle-icon {
    transform: rotate(0deg);
}

.material-category:not(.collapsed) .toggle-icon {
    transform: rotate(90deg);
}

.category-materials {
    max-height: 0;
    transition: max-height 0.3s ease-out;
    overflow: hidden;
}

.material-category:not(.collapsed) .category-materials {
    max-height: 2000px;
}

.material-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    border-bottom: 1px solid var(--gray-200);
}

.material-item:last-child {
    border-bottom: none;
}

.material-info {
    flex: 1;
}

.material-name {
    font-size: 15px;
    font-weight: 500;
    margin-bottom: 4px;
}

.material-price {
    font-size: 13px;
    color: var(--gray-600);
}

.material-quantity {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-qty {
    background: var(--primary-color);
    color: white;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.material-quantity input {
    width: 60px;
    text-align: center;
    padding: 6px;
    border: 2px solid var(--gray-200);
    border-radius: 6px;
    font-size: 15px;
}

/* Выбранные материалы */
.selected-materials {
    background: var(--gray-100);
    padding: 15px;
    border-radius: 10px;
    min-height: 60px;
}

.empty-message {
    text-align: center;
    color: var(--gray-600);
    font-size: 14px;
}

.selected-item {
    background: white;
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 8px;
}

.selected-item:last-child {
    margin-bottom: 0;
}

.selected-item-name {
    font-weight: 500;
    margin-bottom: 4px;
}

.selected-item-details {
    font-size: 13px;
    color: var(--gray-600);
}

.selected-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.btn-remove {
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.btn-remove:hover {
    background: #dc2626;
}

.selected-item-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}

.btn-qty-small {
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    width: 28px;
    height: 28px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-qty-small:hover {
    background: #5a67d8;
}

.selected-quantity {
    font-weight: 500;
    min-width: 60px;
    text-align: center;
}

.selected-item-total {
    font-size: 13px;
    color: var(--gray-600);
    text-align: right;
}

.total-amount {
    background: var(--primary-color);
    color: white;
    padding: 12px 15px;
    border-radius: 10px;
    margin-top: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 16px;
}

/* Текстовое поле */
textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--gray-200);
    border-radius: 8px;
    font-size: 15px;
    font-family: inherit;
    resize: vertical;
}

textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Загрузка файлов */
.file-upload {
    margin-bottom: 10px;
}

.file-upload input[type="file"] {
    display: none;
}

.btn-upload {
    display: inline-block;
    background: var(--gray-200);
    padding: 12px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 15px;
    transition: background 0.2s;
}

.btn-upload:active {
    background: var(--gray-300);
}

.file-preview {
    margin-top: 10px;
}

.selected-files-list {
    margin-top: 10px;
}

.selected-files-list .file-item {
    display: flex;
    align-items: center;
    background: var(--gray-100);
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 8px;
    position: relative;
}

.selected-files-list .file-icon {
    font-size: 24px;
    margin-right: 10px;
}

.selected-files-list .file-info {
    flex: 1;
}

.selected-files-list .file-name {
    font-size: 14px;
    font-weight: 500;
}

.selected-files-list .file-size {
    font-size: 12px;
    color: var(--gray-600);
}

.selected-files-list .file-remove {
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    margin-left: 10px;
}

.selected-files-list .file-remove:hover {
    background: #dc2626;
}

.existing-files {
    margin-top: 10px;
}

.existing-files .file-item {
    display: flex;
    align-items: center;
    background: var(--gray-50);
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 8px;
    border: 1px solid var(--gray-200);
}

.existing-files .file-icon {
    font-size: 20px;
    margin-right: 10px;
}

.existing-files .file-info {
    flex: 1;
}

.existing-files .file-name {
    font-size: 14px;
    font-weight: 500;
}

.existing-files .file-size {
    font-size: 12px;
    color: var(--gray-600);
}

.file-actions {
    margin-top: 15px;
    text-align: center;
}

.file-item {
    display: flex;
    align-items: center;
    background: var(--gray-100);
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 8px;
}

/* Кнопка отправки */
.form-actions {
    margin-top: 25px;
}

.btn-submit {
    width: 100%;
    background: linear-gradient(135deg, var(--success-color) 0%, #059669 100%);
    color: white;
    border: none;
    padding: 15px;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s;
    margin: 5px;
}

.btn-submit:active {
    transform: scale(0.98);
}

.btn-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Состояния */
.loading, .error, .empty-state {
    text-align: center;
    padding: 40px 20px;
    font-size: 16px;
    color: var(--gray-600);
}

.error {
    color: var(--danger-color);
}

/* Адаптация для маленьких экранов */
@media (max-width: 480px) {
    .app-header h1 {
        font-size: 18px;
    }
    
    .header-user {
        font-size: 12px;
    }
    
    .modal {
        padding: 0;
    }
    
    .modal-content {
        border-radius: 0;
        min-height: 100vh;
    }
    
    .modal-body {
        max-height: none;
    }
}

/* Анимации */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.visit-card {
    animation: fadeIn 0.3s ease-out;
}
