/* Базовые стили */
* {
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 20px;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #333;
}

h1 {
    color: #fff;
    font-size: 2rem;
    text-align: center;
    margin: 0 0 20px 0;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* ==================== Страница авторизации ==================== */
#auth-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 70vh;
}

.auth-card {
    background-color: #fff;
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.25);
    width: 100%;
    max-width: 420px;
}

#login-form h3,
#register-form h3 {
    color: #2c3e50;
    margin-bottom: 25px;
    font-size: 1.8rem;
    text-align: center;
}

#login-form input,
#register-form input {
    width: 100%;
    padding: 14px;
    margin-bottom: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 15px;
    transition: border-color 0.3s;
}

#login-form input:focus,
#register-form input:focus {
    outline: none;
    border-color: #667eea;
}

#login-btn,
#register-btn {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    margin-top: 10px;
}

#login-btn:hover,
#register-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102,126,234,0.4);
}

#login-form p,
#register-form p {
    margin-top: 20px;
    text-align: center;
    color: #666;
    font-size: 14px;
}

#login-form a,
#register-form a {
    color: #667eea;
    text-decoration: none;
    font-weight: 600;
}

#login-form a:hover,
#register-form a:hover {
    text-decoration: underline;
}

/* ==================== Верхняя панель ==================== */
#user-bar-container {
    max-width: 900px;
    margin: 0 auto 15px auto;
    padding: 0;
}

#user-bar {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    padding: 15px 20px;
    border-radius: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
}

#welcome-message {
    font-size: 16px;
    color: #fff;
    font-weight: 500;
    margin-right: 10px;
}

.user-bar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

#logout-btn,
.nav-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 25px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

#logout-btn:hover,
.nav-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

.nav-btn.active {
    background: #fff;
    color: #667eea;
}

/* ==================== Контент страниц ==================== */
.page-content {
    max-width: 900px;
    margin: 0 auto;
}

#config-manager,
#database-container,
#query-buttons-container,
#add-query-form,
#results,
#users-manager {
    background-color: #fff;
    padding: 25px 30px;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    margin-bottom: 15px;
}

#config-manager h3,
#query-buttons-container h3,
#add-query-form h3,
#results h3,
#users-manager h3 {
    color: #2c3e50;
    margin-bottom: 20px;
    font-size: 1.3rem;
    text-align: center;
    font-weight: 600;
}

/* Select и input */
#config-manager select,
#database-select,
#add-query-form input,
#add-query-form textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e8e8e8;
    border-radius: 10px;
    font-size: 15px;
    margin-bottom: 15px;
    transition: border-color 0.3s;
    background-color: #fafafa;
}

#config-manager select:focus,
#database-select:focus,
#add-query-form input:focus,
#add-query-form textarea:focus {
    outline: none;
    border-color: #667eea;
    background-color: #fff;
}

#database-container label {
    display: block;
    margin-bottom: 8px;
    color: #555;
    font-weight: 500;
}

#add-query-form textarea {
    resize: vertical;
    min-height: 70px;
    font-family: 'Courier New', monospace;
}

/* Кнопки */
.button-row {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
}

#config-manager button,
#add-query-form button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: 25px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
}

#add-config-btn {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
}

#add-config-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(245,87,108,0.4);
}

#list-config-btn {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
}

#list-config-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(79,172,254,0.4);
}

#add-query-btn {
    background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
    color: white;
}

#add-query-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(67,233,123,0.4);
}

#execute-query-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

#execute-query-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102,126,234,0.4);
}

/* Кнопки запросов */
#query-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-bottom: 15px;
}

.query-button-item {
    display: inline-flex;
    align-items: center;
    background: linear-gradient(135deg, #e0e7ff 0%, #f0e6ff 100%);
    border-radius: 25px;
    padding: 3px;
    box-shadow: 0 3px 12px rgba(0,0,0,0.1);
    transition: all 0.2s ease;
}

.query-button-item:hover {
    box-shadow: 0 5px 18px rgba(0,0,0,0.15);
    transform: translateY(-1px);
}

.query-button-item button {
    margin: 0;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 13px;
    padding: 8px 14px;
    border-radius: 25px;
    font-weight: 500;
    color: #2c3e50;
    transition: all 0.2s;
}

.query-button-item button:first-child {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(102,126,234,0.3);
}

.query-button-item button:first-child:hover {
    background: linear-gradient(135deg, #5a6fd6 0%, #6a4190 100%);
}

.query-button-item .delete-btn {
    color: #fff;
    background-color: #e74c3c;
    font-weight: bold;
    padding: 8px 12px;
    border-radius: 25px;
    margin-left: 2px;
}

.query-button-item .delete-btn:hover {
    background-color: #c0392b;
}

/* Результаты */
#results {
    text-align: center;
}

.timing-info {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-bottom: 15px;
    font-size: 14px;
}

.timing-info span {
    color: #666;
}

#timer, #db-execution-time {
    font-weight: bold;
    color: #3498db;
}

#result {
    background: linear-gradient(135deg, #2c3e50 0%, #1a252f 100%);
    color: #ecf0f1;
    padding: 15px;
    border-radius: 10px;
    overflow-x: auto;
    max-height: 350px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    min-height: 80px;
    text-align: left;
}

/* ==================== Пользователи ==================== */
#users-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.user-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 12px;
    transition: transform 0.2s;
}

.user-item:hover {
    transform: translateX(5px);
}

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

.user-name {
    font-size: 16px;
    font-weight: 600;
    color: #2c3e50;
}

.user-created {
    font-size: 13px;
    color: #666;
}

.user-actions {
    display: flex;
    gap: 10px;
}

.user-actions button {
    padding: 8px 18px;
    border: none;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.delete-user-btn {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    color: white;
}

.delete-user-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(231,76,60,0.4);
}

.change-password-btn {
    background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%);
    color: white;
}

.change-password-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(243,156,18,0.4);
}

/* ==================== Модальные окна ==================== */
.modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(3px);
}

.modal-content {
    background-color: white;
    padding: 30px;
    border-radius: 18px;
    min-width: 350px;
    max-width: 550px;
    width: 90%;
    max-height: 75vh;
    overflow-y: auto;
    box-shadow: 0 20px 50px rgba(0,0,0,0.3);
    animation: modalFadeIn 0.3s;
}

.modal-content h3 {
    color: #2c3e50;
    margin-bottom: 20px;
    text-align: center;
    font-size: 1.4rem;
    font-weight: 600;
}

@keyframes modalFadeIn {
    from { opacity: 0; transform: translateY(-25px); }
    to { opacity: 1; transform: translateY(0); }
}

.modal-content label {
    display: block;
    margin-bottom: 12px;
    font-weight: 500;
    color: #555;
    font-size: 14px;
}

.modal-content input {
    width: 100%;
    padding: 11px 14px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 14px;
    transition: border-color 0.3s;
    background-color: #fafafa;
}

.modal-content input:focus {
    outline: none;
    border-color: #667eea;
    background-color: #fff;
}

.modal-content p {
    text-align: center;
    font-size: 15px;
    color: #555;
    margin-bottom: 15px;
}

.result-details {
    text-align: left;
    margin-bottom: 15px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 8px;
}

.result-details div {
    margin-bottom: 8px;
}

.modal-buttons {
    margin-top: 20px;
    text-align: center;
}

.modal-buttons button {
    padding: 11px 28px;
    border: none;
    border-radius: 25px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    margin: 5px;
    transition: all 0.2s;
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
}

.modal-buttons button:first-child {
    background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
    color: white;
}

.modal-buttons button:first-child:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 22px rgba(67,233,123,0.4);
}

.modal-buttons button:last-child {
    background: linear-gradient(135deg, #bdc3c7 0%, #95a5a6 100%);
    color: white;
}

.modal-buttons button:last-child:hover {
    background: linear-gradient(135deg, #95a5a6 0%, #7f8c8d 100%);
}

/* Список конфигураций */
#config-list-container {
    max-height: 280px;
    overflow-y: auto;
}

.config-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 12px;
    border-bottom: 2px solid #f0f0f0;
    transition: background-color 0.2s;
}

.config-list-item:hover {
    background-color: #f8f9fa;
}

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

.config-list-item button {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    color: white;
    border: none;
    border-radius: 25px;
    padding: 7px 16px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

.config-list-item button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(231,76,60,0.4);
}

#modal-result {
    background: linear-gradient(135deg, #2c3e50 0%, #1a252f 100%);
    color: #ecf0f1;
    padding: 15px;
    border-radius: 10px;
    overflow-x: auto;
    max-height: 300px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    text-align: left;
}

/* Медиа-запросы */
@media (max-width: 600px) {
    body {
        padding: 12px;
    }

    h1 {
        font-size: 1.5rem;
    }

    .auth-card {
        padding: 25px 20px;
    }

    #top-bar {
        flex-direction: column;
        align-items: stretch;
    }

    #user-info {
        justify-content: center;
    }

    #main-nav {
        justify-content: center;
    }

    #config-manager,
    #add-query-form,
    #results,
    #users-manager {
        padding: 20px;
    }

    #user-bar {
        flex-direction: column;
        gap: 12px;
    }

    .user-bar-actions {
        flex-direction: column;
        width: 100%;
        justify-content: center;
    }

    #query-buttons {
        flex-direction: column;
        align-items: stretch;
    }

    .query-button-item {
        width: 100%;
        justify-content: space-between;
    }

    .user-item {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }

    .user-actions {
        width: 100%;
        justify-content: center;
    }

    .modal-content {
        padding: 25px 18px;
        min-width: auto;
    }

    .modal-buttons {
        display: flex;
        flex-direction: column;
    }

    .modal-buttons button {
        width: 100%;
        margin: 5px 0;
    }
}
