/* Базовые стили для всего приложения */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
}

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

/* Стили для уведомлений */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 20px;
    border-radius: 8px;
    color: white;
    font-weight: 500;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    display: none;
    animation: slideIn 0.3s ease;
}

.notification.success {
    background-color: #4CAF50;
}

.notification.error {
    background-color: #f44336;
}

.notification.warning {
    background-color: #ff9800;
}

.notification.info {
    background-color: #2196F3;
}

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

/* Статус соединения */
.connection-status {
    position: fixed;
    top: 10px;
    left: 10px;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    background-color: #4CAF50;
    color: white;
    z-index: 999;
}

.connection-status.offline {
    background-color: #f44336;
}

/* Стили для форм */
.form-section {
    background-color: white;
    border-radius: 10px;
    padding: 25px;
    margin-bottom: 30px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.form-section h2 {
    color: #2c3e50;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #4CAF50;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-group label {
    margin-bottom: 8px;
    font-weight: 600;
    color: #555;
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 10px 12px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.3s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: #4CAF50;
    outline: none;
}

.form-group input[readonly] {
    background-color: #f5f5f5;
    cursor: not-allowed;
}

.button-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 20px;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
}

.btn:hover {
    opacity: 0.9;
    transform: translateY(-2px);
}

.btn-clear {
    background-color: #f0f0f0;
    color: #333;
}

.btn-load {
    background-color: #2196F3;
    color: white;
}

.btn-admin {
    background-color: #ff9800;
    color: white;
}

.dashboard-btn {
    background-color: #9c27b0;
    color: white;
}

.btn-delete {
    background-color: #f44336;
    color: white;
    padding: 6px 12px;
    font-size: 13px;
}

/* Стили для таблицы */
.table-container {
    overflow-x: auto;
    background-color: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin-top: 20px;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 1200px;
}

thead {
    background-color: #2c3e50;
    color: white;
}

th {
    padding: 15px;
    text-align: left;
    font-weight: 600;
    border-right: 1px solid #34495e;
}

th:last-child {
    border-right: none;
}

td {
    padding: 12px 15px;
    border-bottom: 1px solid #eee;
}

tbody tr:hover {
    background-color: #f9f9f9;
}

.status-pending {
    color: #ff9800;
    font-weight: bold;
}

.status-completed {
    color: #4CAF50;
    font-weight: bold;
}

.actions-cell {
    display: flex;
    gap: 8px;
}

/* Сводная информация */
.summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.summary-item {
    background-color: white;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    text-align: center;
}

/* Поиск и фильтры */
.search-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 20px;
    padding: 15px;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.search-filter input,
.search-filter select {
    padding: 10px 12px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    min-width: 200px;
}

/* Подсказка для скролла */
.scroll-hint {
    background-color: #e3f2fd;
    padding: 10px 15px;
    border-radius: 6px;
    margin: 10px 0;
    font-size: 14px;
    color: #1976d2;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.scroll-icon {
    font-size: 20px;
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(10px); }
}

/* Модальное окно */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    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: 50px auto;
    padding: 30px;
    border-radius: 12px;
    width: 90%;
    max-width: 900px;
    position: relative;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.close {
    position: absolute;
    top: 20px;
    right: 25px;
    font-size: 28px;
    cursor: pointer;
    color: #aaa;
}

.close:hover {
    color: #333;
}

/* Дашборд */
.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background-color: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    border-left: 4px solid #4CAF50;
}

.stat-card h3 {
    color: #555;
    font-size: 16px;
    margin-bottom: 10px;
}

.stat-value {
    font-size: 32px;
    font-weight: bold;
    color: #2c3e50;
    margin: 10px 0;
}

.stat-change {
    font-size: 14px;
    color: #7f8c8d;
}

/* Информация о пользователе */
.user-info {
    background-color: white;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.user-info-content {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

#userName {
    font-weight: bold;
    color: #2c3e50;
}

#userRole {
    color: #7f8c8d;
    font-size: 14px;
}

.logout-btn {
    background-color: #f44336;
    color: white;
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
}

/* Сообщение о запрете доступа */
.access-restricted {
    background-color: #ffebee;
    color: #c62828;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    text-align: center;
    border-left: 4px solid #c62828;
}

/* Анимация загрузки */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Стили для кнопок синхронизации */
.sync-buttons {
    margin-top: 15px;
    padding: 15px;
    background-color: #e3f2fd;
    border-radius: 8px;
    border: 1px solid #bbdefb;
}

.sync-title {
    font-weight: bold;
    color: #1976d2;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sync-description {
    font-size: 12px;
    color: #546e7a;
    margin-bottom: 10px;
}

.sync-button-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.sync-button {
    background-color: #4CAF50;
    color: white;
    padding: 8px 15px;
    font-size: 13px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
}

.sync-button.import {
    background-color: #2196F3;
}

.sync-button:hover {
    opacity: 0.9;
}

.sync-info {
    margin-top: 10px;
    font-size: 11px;
    color: #78909c;
    display: flex;
    justify-content: space-between;
}

/* Классы для колонок таблицы */
.col-datetime {
    min-width: 150px;
}

.col-location {
    min-width: 80px;
}

.col-inv {
    min-width: 100px;
}

.col-machine {
    min-width: 120px;
}

.col-status {
    min-width: 100px;
}

.col-count {
    min-width: 80px;
    text-align: center;
}

.col-hours {
    min-width: 100px;
    text-align: center;
}

.col-actions {
    min-width: 150px;
}

/* Адаптивность */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .form-grid {
        grid-template-columns: 1fr;
    }
    
    .button-group {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
    }
    
    .search-filter {
        flex-direction: column;
    }
    
    .search-filter input,
    .search-filter select {
        min-width: auto;
        width: 100%;
    }
    
    .modal-content {
        margin: 20px auto;
        padding: 20px;
        width: 95%;
    }
    
    .user-info {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
    
    .summary {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .sync-button-group {
        flex-direction: column;
    }
    
    .sync-button {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .summary {
        grid-template-columns: 1fr;
    }
    
    .form-section {
        padding: 15px;
    }
    
    .form-group input,
    .form-group select,
    .form-group textarea {
        padding: 8px 10px;
    }
}

/* Анимация появления строк */
.fade-in {
    animation: fadeIn 0.5s ease;
}

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

/* Стиль для селекта с поиском */
.form-group {
    position: relative;
}

.form-group select {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 16px;
    padding-right: 35px;
}

/* Стили для поля поиска в селекте */
#invNumberSearch {
    margin-bottom: 8px;
    width: 100%;
}

/* Информация о синхронизации */
.sync-info {
    margin-top: 15px;
    padding: 12px;
    background-color: #e3f2fd;
    border-radius: 6px;
    border: 1px solid #bbdefb;
}

.sync-status {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#syncInfo {
    font-size: 13px;
    color: #1976d2;
}

.sync-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}

.sync-indicator.online {
    background-color: #4CAF50;
    box-shadow: 0 0 5px #4CAF50;
}

.sync-indicator.offline {
    background-color: #f44336;
}

/* Убираем лишние отступы */
.button-group {
    margin-bottom: 0;
}

/* Стили для кнопок действий в таблице */
.actions-cell {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

.btn-complete {
    background-color: #4CAF50;
    color: white;
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: background-color 0.3s;
    min-width: 100px;
    text-align: center;
}

.btn-complete:hover:not(:disabled) {
    background-color: #45a049;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.btn-complete:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
    opacity: 0.7;
}

.btn-delete {
    background-color: #f44336;
    color: white;
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: background-color 0.3s;
    min-width: 70px;
    text-align: center;
}

.btn-delete:hover {
    background-color: #d32f2f;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* Стили для модального окна дашборда */
.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background-color: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    border-left: 4px solid #4CAF50;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    transition: transform 0.3s;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.stat-card h3 {
    color: #555;
    font-size: 16px;
    margin-bottom: 10px;
    font-weight: 600;
}

.stat-value {
    font-size: 32px;
    font-weight: bold;
    color: #2c3e50;
    margin: 10px 0;
}

.stat-change {
    font-size: 14px;
    color: #7f8c8d;
}

/* Адаптивность для кнопок действий */
@media (max-width: 768px) {
    .actions-cell {
        flex-direction: column;
        align-items: stretch;
    }
    
    .btn-complete,
    .btn-delete {
        width: 100%;
        margin-bottom: 5px;
    }
}

/* Стили для кнопки синхронизации */
.sync-btn {
    background-color: #9C27B0;
    color: white;
    margin-left: 10px;
}

.sync-btn:hover {
    background-color: #7B1FA2;
}

/* Стили для уведомления о синхронизации */
.sync-notification {
    background-color: #2196F3;
    color: white;
    padding: 10px 15px;
    border-radius: 6px;
    margin: 10px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sync-notification.warning {
    background-color: #FF9800;
}

.sync-notification.error {
    background-color: #F44336;
}

.sync-notification.success {
    background-color: #4CAF50;
}

/* Стили для кнопки синхронизации */
.sync-btn {
    background-color: #9C27B0;
    color: white;
}

.sync-btn:hover {
    background-color: #7B1FA2;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

/* Стили для мобильных устройств */
@media (max-width: 768px) {
    .button-group {
        flex-direction: column;
    }
    
    .button-group .btn {
        width: 100%;
        margin-bottom: 10px;
    }
    
    .sync-btn {
        background-color: #9C27B0;
        order: 3; /* Позиционирование кнопки */
    }
}

/* Индикатор синхронизации */
.sync-indicator {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 5px;
}

.sync-indicator.syncing {
    background-color: #FF9800;
    animation: pulse 1s infinite;
}

.sync-indicator.success {
    background-color: #4CAF50;
}

.sync-indicator.error {
    background-color: #F44336;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

/* Сообщение о синхронизации */
.sync-message {
    background-color: #e3f2fd;
    padding: 10px;
    border-radius: 6px;
    margin: 10px 0;
    border-left: 4px solid #2196F3;
    font-size: 14px;
}

.sync-message.success {
    background-color: #e8f5e9;
    border-left-color: #4CAF50;
}

.sync-message.error {
    background-color: #ffebee;
    border-left-color: #F44336;
}

.sync-message.warning {
    background-color: #fff3e0;
    border-left-color: #FF9800;
}

/* Стили для поиска в селекте */
.searchable-select-container {
    position: relative;
}

#invNumberSearch {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-bottom: 5px;
    font-size: 14px;
}

#invNumberSearch:focus {
    border-color: #4CAF50;
    outline: none;
}

.clear-search-btn {
    position: absolute;
    right: 10px;
    top: 8px;
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #999;
    padding: 0;
    line-height: 1;
}

.clear-search-btn:hover {
    color: #333;
}

/* Стили для сообщения о синхронизации */
.sync-status-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.sync-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.sync-dot.pending {
    background-color: #FF9800;
    animation: pulse 1s infinite;
}

.sync-dot.success {
    background-color: #4CAF50;
}

.sync-dot.error {
    background-color: #F44336;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

/* Улучшение для мобильных устройств */
@media (max-width: 768px) {
    #invNumberSearch {
        font-size: 16px;
        padding: 10px;
    }
    
    .clear-search-btn {
        top: 10px;
        right: 12px;
        font-size: 24px;
    }
}

/* ===== СТИЛИ ДЛЯ ТАБЛИЦЫ ЗАЯВОК ===== */

/* Стили для строк в ремонте */
.repair-in-progress {
    background-color: #fff3cd !important;
    border-left: 4px solid #ffc107;
    font-weight: 600;
}

.repair-in-progress:hover {
    background-color: #ffeaa7 !important;
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(0,0,0,0.1);
}

/* Стили для статусов */
.status-cell {
    font-weight: bold;
    text-align: center;
}

.status-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85em;
    display: inline-block;
    min-width: 100px;
    text-align: center;
    font-weight: 500;
    letter-spacing: 0.3px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.status-in-repair {
    background: linear-gradient(135deg, #ffc107 0%, #ff9800 100%);
    color: #856404;
    border: none;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(255, 193, 7, 0.4); }
    70% { box-shadow: 0 0 0 6px rgba(255, 193, 7, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 193, 7, 0); }
}

.status-new {
    background: linear-gradient(135deg, #17a2b8 0%, #138496 100%);
    color: white;
    border: none;
}

.status-completed {
    background: linear-gradient(135deg, #28a745 0%, #1e7e34 100%);
    color: white;
    border: none;
}

.status-cancelled {
    background: linear-gradient(135deg, #6c757d 0%, #545b62 100%);
    color: white;
    border: none;
}

.status-on-hold {
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
    color: white;
    border: none;
}

/* Иконки действий в таблице */
.btn-edit, .btn-delete {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2em;
    padding: 6px 8px;
    margin: 0 2px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.btn-edit {
    color: #007bff;
    background-color: rgba(0, 123, 255, 0.1);
}

.btn-edit:hover {
    background-color: #007bff;
    color: white;
    transform: scale(1.1);
    box-shadow: 0 3px 6px rgba(0, 123, 255, 0.2);
}

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

.btn-delete:hover {
    background-color: #dc3545;
    color: white;
    transform: scale(1.1);
    box-shadow: 0 3px 6px rgba(220, 53, 69, 0.2);
}

/* Панель фильтров */
.filters-panel {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 10px;
    padding: 15px 20px;
    margin: 20px 0;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    border: 1px solid #dee2e6;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.filter-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: 500;
    color: #495057;
}

.filter-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #007bff;
}

.filter-select {
    padding: 8px 15px;
    border: 2px solid #ced4da;
    border-radius: 6px;
    background-color: white;
    font-size: 14px;
    color: #495057;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 180px;
}

.filter-select:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.25);
    outline: none;
}

/* Панель статистики */
.stats-panel {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border-radius: 10px;
    padding: 15px 20px;
    margin: 20px 0;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    border: 1px solid #dee2e6;
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 20px;
    border-radius: 8px;
    min-width: 120px;
}

.stat-value {
    font-size: 24px;
    font-weight: bold;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 12px;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-in-repair {
    background: rgba(255, 193, 7, 0.1);
    border: 2px solid #ffc107;
}

.stat-total {
    background: rgba(0, 123, 255, 0.1);
    border: 2px solid #007bff;
}

.stat-completed {
    background: rgba(40, 167, 69, 0.1);
    border: 2px solid #28a745;
}

/* Заголовок таблицы */
.table-header {
    background: linear-gradient(135deg, #6c757d 0%, #495057 100%);
    color: white;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.5px;
}

.table-header th {
    padding: 12px 15px;
    border: none;
}

/* Эффект загрузки */
.loading-row {
    animation: loading 1.5s infinite;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Адаптивность */
@media (max-width: 768px) {
    .filter-group {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .filter-select {
        width: 100%;
    }
    
    .stats-panel {
        flex-direction: column;
        gap: 10px;
    }
    
    .stat-item {
        width: 100%;
    }
}
