/* Reset и базовые стили */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #5F9EA0;
    --primary-dark: #4A7B7D;
    --secondary-color: #2F4F4F;
    --accent-color: #e74c3c;
    --success-color: #27ae60;
    --warning-color: #f39c12;
    --background-color: #f8f9fa;
    --surface-color: #ffffff;
    --text-primary: #2c3e50;
    --text-secondary: #7f8c8d;
    --border-color: #e1e8ed;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.15);
    --border-radius: 12px;
    --border-radius-sm: 8px;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--background-color);
}

.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Layout */
.header-container,
.footer-container,
.main-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
}

.main-content {
    flex: 1;
    padding: 1.5rem 2rem;
    width: 100%;
}

/* Header */
.header {
    background: linear-gradient(135deg, var(--secondary-color), #3a5f5f);
    color: white;
    padding: 1rem 0;
    box-shadow: var(--shadow);
}

.header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.logo span {
    font-size: 0.875rem;
    opacity: 0.8;
}

.main-nav {
    display: flex;
    gap: 2rem;
}

.nav-link {
    color: white;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius-sm);
    transition: background-color 0.3s ease;
}

.nav-link:hover,
.nav-link.active {
    background-color: rgba(255, 255, 255, 0.1);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-details {
    text-align: right;
}

.user-name {
    display: block;
    font-weight: 600;
}

.user-role {
    display: block;
    font-size: 0.875rem;
    opacity: 0.8;
}

.logout-btn {
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
}

.logout-btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

/* Footer */
.footer {
    background-color: var(--secondary-color);
    color: white;
    padding: 1.5rem 0;
    margin-top: auto;
}

.footer-container {
    text-align: center;
}

.footer p {
    margin-bottom: 0.5rem;
    opacity: 0.8;
}

/* Common Components */
.btn {
    border: none;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 500;
}

.btn-primary {
    background: var(--primary-color); /* Убрали градиент */
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 10px; /* Увеличили скругление углов */
    border: none;
    transition: all 0.3s ease;
}

.btn-primary:hover {
    background: var(--primary-dark); /* Цвет при наведении */
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.btn-sm {
    padding: 0.375rem 0.625rem;
    font-size: 0.75rem;
    min-width: auto;
    white-space: nowrap;
    border-radius: 10px; /* Добавить скругление углов */
    transition: all 0.3s ease;
}

.btn-edit { background: var(--primary-color); color: white; }
.btn-modules { background: var(--primary-color); color: white; }
.btn-reset { background: var(--warning-color); color: white; }
.btn-danger {
    background: var(--accent-color);
    color: white;
    border: none !important; /* Убираем любую границу */
    outline: none !important; /* Убираем outline */
}
.btn-warning { background: var(--warning-color); color: white; }
.btn-secondary { background: var(--text-secondary); color: white; }

.btn-sm:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.btn-secondary:hover {
    background: var(--text-primary);
}

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

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.form-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    font-size: 1rem;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    background: var(--surface-color); /* Убрать градиентный фон */
    color: var(--text-primary);
    appearance: none; /* Убираем стандартный вид браузера */
    -webkit-appearance: none;
    -moz-appearance: none;
}

/* Специфичные стили для select */
.form-input[type="email"],
.form-input[type="text"],
.form-input[type="tel"],
.form-input select {
    background: var(--surface-color); /* Однотонный фон */
}

/* Стили для select элементов */
select.form-input {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%235F9EA0' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 12px;
    padding-right: 2.5rem;
}

/* Убираем стандартную стрелку в IE */
select.form-input::-ms-expand {
    display: none;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(95, 158, 160, 0.1);
    background: var(--surface-color); /* Обеспечиваем однотонный фон при фокусе */
}

/* Стили для всех полей формы - делаем одинаковую высоту */
.form-input,
select.form-input {
    min-height: 48px; /* Одинаковая высота для всех полей */
    box-sizing: border-box;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-help {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}

/* Cards & Sections */
.admin-section,
.login-card {
    background: var(--surface-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}

.admin-section {
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.admin-section h2 {
    margin-bottom: 1rem;
    color: var(--text-primary);
    font-size: 1.1rem;
}

/* Login Page */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #5F9EA0 0%, #2F4F4F 100%);
    padding: 2rem;
}

.login-container {
    width: 100%;
    max-width: 400px;
}

.login-card {
    padding: 2.5rem;
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.logo-large h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--secondary-color);
    margin-bottom: 0.5rem;
}

.logo-large p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.login-header h2 {
    color: var(--text-primary);
    font-size: 1.5rem;
}

.error-message {
    background-color: #fee;
    border: 1px solid #f5c6cb;
    color: #721c24;
    padding: 1rem;
    border-radius: var(--border-radius-sm);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.error-icon {
    font-size: 1.2rem;
}

.login-form {
    margin-bottom: 1.5rem;
}

.login-btn {
    width: 100%;
    padding: 1rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
}

.login-footer {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Dashboard */
.dashboard-page {
    animation: fadeIn 0.5s ease-in;
}

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

.dashboard-header {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 2rem;
    margin-bottom: 3rem;
}

.welcome-section h1 {
    font-size: 2rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.user-info-text {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
}

.info-item {
    background: var(--surface-color);
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius-sm);
    box-shadow: var(--shadow);
}

.stats-section {
    display: flex;
    justify-content: flex-end;
}

.stat-card {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    padding: 1.5rem;
    border-radius: var(--border-radius);
    text-align: center;
    box-shadow: var(--shadow);
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.stat-label {
    font-size: 0.875rem;
    opacity: 0.9;
}

/* Modules */
.modules-section {
    margin-bottom: 3rem;
}

.modules-section h2 {
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
    color: var(--text-primary);
}

.modules-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.module-card {
    background: var(--surface-color);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    text-decoration: none;
    color: inherit;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.module-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-color);
}

.module-icon {
    font-size: 2rem;
    flex-shrink: 0;
}

.module-content {
    flex: 1;
}

.module-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.module-description {
    color: var(--text-secondary);
    font-size: 0.875rem;
    line-height: 1.4;
}

.module-arrow {
    color: var(--primary-color);
    font-size: 1.25rem;
    font-weight: 700;
}

.no-modules {
    text-align: center;
    padding: 3rem;
    background: var(--surface-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}

.no-modules-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

/* Quick Actions */
.quick-actions h2 {
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
    color: var(--text-primary);
}

.actions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.action-btn {
    background: var(--surface-color);
    border: 2px solid var(--border-color);
    padding: 1rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: all 0.3s ease;
    text-align: left;
}

.action-btn:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.action-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

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

/* Admin Panel */
.admin-page {
    animation: fadeIn 0.5s ease-in;
    width: 100%;
}

.admin-header {
    margin-bottom: 2rem;
}

.admin-header h1 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.admin-subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.user-form {
    max-width: 800px;
}

/* Tables */
.users-table-container {
    overflow-x: auto;
    max-width: 100%;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    background: var(--surface-color);
}

.users-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0;
    table-layout: fixed;
}

.compact-table {
    font-size: 0.85rem;
}

.users-table th,
.users-table td {
    padding: 0.75rem 0.5rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
    height: 60px;
    box-sizing: border-box;
    overflow: hidden;
}

.users-table th {
    background: var(--background-color);
    font-weight: 600;
    color: var(--text-primary);
    position: sticky;
    top: 0;
    z-index: 10;
}

.compact-table th {
    font-size: 0.8rem;
}

.users-table tr:hover {
    background: var(--background-color);
}

/* Table Columns - фиксированные высоты и выравнивание */
.col-login { 
    width: 140px; 
    min-width: 140px; 
    white-space: nowrap; 
    overflow: hidden; 
    text-overflow: ellipsis; 
}
.col-name { 
    width: 220px; 
    min-width: 220px; 
    white-space: normal;
    line-height: 1.4;
    word-wrap: break-word;
}
.col-role { 
    width: 120px; 
    min-width: 120px; 
    white-space: normal;
    line-height: 1.4;
}
.col-branch { 
    width: 110px; 
    min-width: 110px; 
    white-space: normal;
    line-height: 1.4;
}
.col-email { 
    width: 240px; 
    min-width: 240px;
    white-space: normal;
    line-height: 1.4;
    word-wrap: break-word;
}
.col-phone { 
    width: 150px; 
    min-width: 150px; 
    white-space: nowrap; 
    overflow: hidden; 
    text-overflow: ellipsis; 
}
.col-status { 
    width: 70px; 
    min-width: 70px; 
    text-align: center; 
}
.col-date { 
    width: 100px; 
    min-width: 100px; 
    white-space: nowrap;
}
.col-actions { 
    width: 90px; 
    min-width: 90px; 
    text-align: center; 
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 0.375rem;
    justify-content: center;
    flex-wrap: nowrap;
}

/* Badges */
.badge-you {
    background: var(--success-color);
    color: white;
    padding: 0.125rem 0.375rem;
    border-radius: 8px;
    font-size: 0.625rem;
    margin-left: 0.25rem;
    display: inline-block;
}

/* Toggle Switch */
.toggle {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 20px;
    margin: 0 auto;
}

.toggle-input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 20px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

.toggle-input:checked + .toggle-slider {
    background-color: var(--success-color);
}

.toggle-input:checked + .toggle-slider:before {
    transform: translateX(20px);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}

.modal-content {
    background-color: var(--surface-color);
    margin: 5% auto;
    padding: 0;
    border-radius: var(--border-radius);
    width: 90%;
    max-width: 500px;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    color: var(--text-primary);
}

.close {
    color: var(--text-secondary);
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
}

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

.modal-body {
    padding: 1.5rem;
}

/* Modules List */
.modules-list {
    max-height: 400px;
    overflow-y: auto;
}

.module-item {
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    margin-bottom: 0.5rem;
    transition: all 0.3s ease;
}

.module-item:hover {
    border-color: var(--primary-color);
}

.module-checkbox {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    cursor: pointer;
}

.module-checkbox input {
    margin-top: 0.25rem;
}

.module-info {
    flex: 1;
}

.module-name {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.module-desc {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Special Zones */
.danger-zone {
    border: 2px solid var(--accent-color);
    background: #fff5f5;
    border-radius: var(--border-radius);
}

.danger-zone h2 {
    color: var(--accent-color);
    margin-bottom: 1rem;
}

.danger-actions {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.btn-back {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    margin-bottom: 1rem;
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    background: var(--surface-color);
}

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

/* Responsive Design */
@media (max-width: 1400px) {
    .col-email { width: 200px; min-width: 200px; }
    .col-name { width: 180px; min-width: 180px; }
}

@media (max-width: 1200px) {
    .compact-table {
        font-size: 0.8rem;
    }
    
    .col-login { width: 120px; min-width: 120px; }
    .col-name { width: 160px; min-width: 160px; }
    .col-role { width: 100px; min-width: 100px; }
    .col-branch { width: 100px; min-width: 100px; }
    .col-email { width: 180px; min-width: 180px; }
    .col-phone { width: 130px; min-width: 130px; }
}

@media (max-width: 992px) {
    .col-phone { display: table-cell; }
    .col-branch { display: table-cell; }
    .col-date { width: 90px; min-width: 90px; }
}

@media (max-width: 768px) {
    .header-container {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .main-content {
        padding: 1rem;
    }
    
    .dashboard-header {
        grid-template-columns: 1fr;
    }
    
    .user-info-text {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .modules-grid {
        grid-template-columns: 1fr;
    }
    
    .login-card {
        padding: 2rem 1.5rem;
    }
    
    .compact-table {
        font-size: 0.78rem;
    }
    
    .users-table th,
    .users-table td {
        height: 50px;
        padding: 0.5rem 0.375rem;
    }
    
    .col-email { display: none; }
    .col-phone { display: none; }
    
    .col-name { width: 140px; min-width: 140px; }
    .col-login { width: 100px; min-width: 100px; }
    
    .form-row {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    .action-buttons {
        flex-direction: column;
        gap: 0.25rem;
    }
    
    .admin-section {
        padding: 1rem;
    }
}

@media (max-width: 576px) {
    .col-branch { display: none; }
    .col-date { display: none; }
    
    .col-login { width: 80px; min-width: 80px; }
    .col-name { width: 120px; min-width: 120px; }
    .col-role { width: 80px; min-width: 80px; }
    .col-actions { width: 70px; min-width: 70px; }
    
    .compact-table th,
    .compact-table td {
        padding: 0.5rem 0.375rem;
    }
    
    .btn-sm {
        padding: 0.25rem 0.5rem;
        font-size: 0.7rem;
    }
}

/* Адаптивная таблица для очень маленьких экранов */
@media (max-width: 480px) {
    .users-table-container {
        overflow-x: visible;
    }
    
    .compact-table {
        table-layout: auto;
    }
    
    .compact-table thead {
        display: none;
    }
    
    .compact-table tr {
        display: block;
        margin-bottom: 1rem;
        border: 1px solid var(--border-color);
        border-radius: var(--border-radius-sm);
        padding: 1rem;
        background: var(--surface-color);
    }
    
    .compact-table td {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        padding: 0.5rem 0;
        border: none;
        width: 100% !important;
        white-space: normal;
        text-overflow: unset;
        overflow: visible;
        height: auto !important;
    }
    
    .compact-table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-primary);
        min-width: 100px;
        margin-right: 1rem;
    }
    
    .compact-table td.col-actions {
        justify-content: center;
        border-top: 1px solid var(--border-color);
        margin-top: 0.5rem;
        padding-top: 1rem;
    }
    
    .compact-table td.col-actions::before {
        display: none;
    }
}