/* == БАЗОВЫЕ СТИЛИ == */
:root {
    --bg-color: #f3f3f3;
    --card-bg: #ffffff;
    --primary: #0078d4;
    --text: #202020;
    --border: #e0e0e0;
    --danger: #d13438;
    --success: #107c10;
}

body {
    font-family: 'Segoe UI', sans-serif;
    background-color: var(--bg-color);
    color: var(--text);
    margin: 0;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.hidden { display: none !important; }

.screen {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.3s ease;
}

/* == ЭКРАНЫ ВХОДА == */
#page-login, #page-staff-select {
    align-items: center;
    justify-content: center;
}

.login-card {
    background: var(--card-bg);
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    width: 300px;
    text-align: center;
}

/* Общие инпуты */
input, textarea, select {
    width: 100%;
    padding: 10px;
    margin: 5px 0;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
    font-family: inherit;
    font-size: 14px;
    background: white;
    color: #333;
}
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--primary);
}

/* Стиль для заблокированного поля (когда улица выбрана) */
input.locked-input {
    background-color: #e6ffea;
    border-color: #107c10;
    color: #005a00;
    font-weight: 600;
    cursor: default;
}

button.primary-btn {
    width: 100%;
    padding: 10px;
    background-color: var(--primary);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    transition: background 0.2s;
}
button.primary-btn:hover { background-color: #005a9e; }
button.primary-btn:disabled { background-color: #ccc; cursor: not-allowed; }

/* Список сотрудников */
.staff-btn {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 12px;
    margin-bottom: 8px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 6px;
    text-align: left;
    font-size: 15px;
    color: #333;
    cursor: pointer;
    transition: all 0.2s;
}
.staff-btn:hover {
    background: #f0f9ff;
    border-color: var(--primary);
    color: var(--primary);
    transform: translateX(3px);
}
.staff-btn::before { content: '👤'; margin-right: 10px; font-size: 16px; }

/* == ЭКРАН ДАШБОРДА == */
.dashboard-layout {
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: #fff;
}

.dashboard-header {
    padding: 0 20px;
    background: #f9f9f9;
    border-bottom: 1px solid #ddd;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    height: 60px;
}

/* ЛЕВАЯ ЧАСТЬ */
.create-btn {
    background-color: var(--success);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.create-btn:hover { background-color: #0e6d0e; }

/* ПРАВАЯ ЧАСТЬ */
.header-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
    gap: 4px;
}

.dispatcher-info {
    font-size: 13px;
    color: #333;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}
.dispatcher-info::before { content: '👤'; color: #666; font-size: 12px; }

.header-controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

.filter-btn {
    background: white;
    border: 1px solid #ccc;
    color: #333;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 4px;
}
.filter-active {
    background: #e6f2ff;
    border-color: var(--primary);
    color: var(--primary);
    font-weight: 600;
}

.mini-btn {
    background: white;
    border: 1px solid #ddd;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    color: #666;
    font-size: 12px;
}
.mini-btn:hover { background: #f3f3f3; color: #333; }

/* == ТАБЛИЦА == */
.table-wrapper {
    flex: 1;
    overflow: auto;
    position: relative;
}

table {
    border-collapse: collapse;
    font-size: 13px;
    table-layout: fixed;
    width: 100%;
    min-width: 800px;
}

thead th {
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 10;
    padding: 12px 10px;
    text-align: left;
    border-bottom: 2px solid #ddd;
    font-weight: 600;
    color: #555;
    user-select: none;
    cursor: pointer;
}
thead th:hover { background: #f4f4f4; }

thead th.sort-asc::after { content: ' ▲'; font-size: 10px; color: var(--primary); }
thead th.sort-desc::after { content: ' ▼'; font-size: 10px; color: var(--primary); }

.resizer {
    position: absolute; right: 0; top: 0; height: 100%; width: 5px;
    background: transparent; cursor: col-resize; z-index: 20;
}
.resizer:hover, .resizing { background: var(--primary); }

tbody td {
    padding: 10px;
    border-bottom: 1px solid #eee;
    vertical-align: top;
    color: #333;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
tbody tr:nth-child(even) { background-color: #fafafa; }
tbody tr:hover { background-color: #f0f8ff; cursor: pointer; }

.problem-cell { font-weight: 500; color: var(--danger); white-space: normal; }
.address-cell { font-weight: 500; white-space: normal; }

/* == МОДАЛЬНОЕ ОКНО == */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(2px);
}

.modal-window {
    background: #ffffff;
    width: 480px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    padding: 25px;
    animation: fadeIn 0.2s ease;
    color: #333;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}
.modal-header h2 { margin: 0; font-size: 20px; font-weight: 600; }
.close-modal {
    background: none; border: none; font-size: 24px; cursor: pointer; 
    color: #999; line-height: 1; padding: 0;
}
.close-modal:hover { color: #333; }

.form-row {
    display: grid;
    grid-template-columns: 130px 1fr;
    gap: 15px;
    margin-bottom: 15px;
    align-items: center;
}

.form-row label {
    text-align: right;
    font-size: 14px;
    font-weight: 600;
    color: #555;
}

textarea {
    resize: vertical;
    min-height: 80px;
}

/* --- АВТОДОПОЛНЕНИЕ (Dropdown) --- */
.autocomplete-suggestions {
    border: 1px solid #ccc;
    border-top: none;
    background: #fff;
    position: absolute;
    z-index: 1001;
    width: 100%;
    max-height: 150px;
    overflow-y: auto;
    border-radius: 0 0 4px 4px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    display: none;
}

.suggestion-item {
    padding: 10px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
    font-size: 13px;
    color: #333;
}
.suggestion-item:last-child { border-bottom: none; }
.suggestion-item:hover { background-color: #eef7ff; color: var(--primary); }

/* --- СТИЛИ ДЛЯ ВВОДА АДРЕСА --- */
.input-wrapper { position: relative; width: 100%; }

.reset-address-btn {
    background: none; border: none; color: #d13438; cursor: pointer; font-size: 18px; padding: 0 5px;
    display: none;
}

/* --- ТЕГИ ИСПОЛНИТЕЛЕЙ --- */
.performers-container {
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 5px;
    background: white;
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    min-height: 38px;
    box-sizing: border-box;
    position: relative;
}

.performers-container:focus-within {
    border-color: var(--primary);
    outline: none;
}

.performer-tag {
    background-color: #e6f2ff;
    color: var(--primary);
    border: 1px solid #cce4ff;
    border-radius: 3px;
    padding: 2px 6px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: default;
}

.performer-tag span.remove-tag {
    cursor: pointer;
    font-weight: bold;
    color: #999;
}
.performer-tag span.remove-tag:hover { color: #d13438; }

.performers-input {
    border: none;
    outline: none;
    flex: 1;
    min-width: 120px;
    font-size: 14px;
    padding: 4px;
    margin: 0;
    font-family: inherit;
}

.modal-footer {
    margin-top: 25px;
    display: flex;
    justify-content: flex-end;
    border-top: 1px solid #eee;
    padding-top: 15px;
}

.create-ticket-submit {
    background-color: var(--primary);
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}
.create-ticket-submit:hover { background-color: #005a9e; }
.create-ticket-submit:disabled { background-color: #ccc; cursor: not-allowed; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
