/* Main variables */
:root {
    --primary-color: #2c3e50;
    --secondary-color: #3498db;
    --accent-color: #e74c3c;
    --light-bg: #f8f9fa;
    --dark-bg: #343a40;
    --text-color: #333;
    --light-text: #fff;
    --success-color: #27ae60;
    --warning-color: #f39c12;
    --error-color: #c0392b;
    --border-radius: 8px;
    --box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s ease;
    --block-height: 40px;
}

/* Common styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    overflow: auto;
}

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

input[type="checkbox"], input[type="radio"] {
    accent-color: var(--secondary-color);
}

/* Containers */
.container {
    width: 90%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px 0 10px;
}

/* Header */
header {
    background-color: var(--primary-color);
    color: var(--light-text);
    padding: 15px 0;
    margin-bottom: 30px;
    box-shadow: var(--box-shadow);
}

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

.header-title {
    display: flex;
    align-items: center;
}

.header-title h1 {
    font-size: 24px;
    margin-right: 10px;
}

.version-badge {
    background-color: var(--secondary-color);
    color: white;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: bold;
}

.update-label {
    color: var(--success-color);
    font-weight: bold;
    font-size: 0.9em;
    padding: 2px 6px;
}

/* Header Controls */
.header-controls {
    display: flex;
    align-items: center;
    gap: 20px;
}

.header-controls > div {
    height: var(--block-height);
    display: flex;
    align-items: center;
}

/* Language Switch */
.language-switcher {
    display: flex;
    align-items: center;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: var(--border-radius);
    padding: 5px 10px;
}

.lang-link {
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    padding: 3px 8px;
    border-radius: 4px;
    transition: var(--transition);
}

.lang-link:hover {
    color: var(--light-text);
    background-color: rgba(255, 255, 255, 0.1);
}

.lang-link.active {
    color: var(--light-text);
    font-weight: bold;
    background-color: rgba(255, 255, 255, 0.2);
}

.logout-btn {
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    padding: 8px 12px;
    border-radius: var(--border-radius);
    transition: var(--transition);
    background-color: rgba(255, 255, 255, 0.1);
}

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

/* TOR Status */
.tor-status {
    display: flex;
    align-items: center;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: var(--border-radius);
    padding: 5px 10px;
    cursor: pointer;
    transition: var(--transition);
}

.tor-status:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.tor-status i {
    margin-right: 5px;
}

.status-indicator {
    margin-left: 5px;
    font-weight: bold;
}

.status-ok {
    color: var(--success-color);
}

.status-error {
    color: var(--error-color);
}

.status-loading {
    color: var(--warning-color);
}

/* Page Body Content */
.body-content {
    height: calc(100vh - 180px);
    display: flex;
    flex-direction: column;
}

/* Tab navigation */
.tabs {
    display: flex;
    background-color: var(--dark-bg);
    border-radius: var(--border-radius) var(--border-radius) 0 0;
    overflow: visible;
}

.tab-link {
    padding: 15px 20px;
    background-color: transparent;
    color: rgba(255, 255, 255, 0.7);
    border: none;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    transition: var(--transition);
    flex: 1;
    text-align: center;
    position: relative;
}

/* Submenu styles */
.submenu-tabs {
    display: none;
    background-color: rgba(52, 62, 80, 0.9);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.submenu-tabs.active {
    display: flex;
}

.submenu-link {
    padding: 10px 15px;
    background-color: transparent;
    color: rgba(255, 255, 255, 0.6);
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 400;
    transition: var(--transition);
    flex: 1;
    text-align: center;
    position: relative;
}

.submenu-link:hover {
    color: var(--light-text);
    background-color: rgba(255, 255, 255, 0.1);
}

.submenu-link.active {
    color: var(--light-text);
    background-color: rgba(255, 255, 255, 0.15);
}

.submenu-link.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background-color: var(--secondary-color);
}

.submenu-link i {
    margin-right: 6px;
}


.tab-link:hover {
    color: var(--light-text);
    background-color: rgba(255, 255, 255, 0.1);
}

.tab-link.active {
    color: var(--light-text);
    background-color: rgba(255, 255, 255, 0.2);
}

.tab-link.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background-color: var(--secondary-color);
}

.tab-link i {
    margin-right: 8px;
}

/* Tab contents */
.tab-content {
    background-color: white;
    border-radius: 0 0 var(--border-radius) var(--border-radius);
    padding: 20px;
    box-shadow: var(--box-shadow);
    display: none;
    position: relative;
}

#system_log, #updates_log {
    flex: 1;
}

.tab-content.active {
    display: flex;
    flex-direction: column;
}

/* Log styles */
.log-container {
    position: relative;
    border: 1px solid #ddd;
    border-radius: var(--border-radius);
    background-color: #f5f5f5;
    margin-top: 10px;
    flex: 1;
    min-height: 400px;
    height: calc(100vh - 180px);
    max-height: calc(100vh - 300px);
}

.log-controls {
    position: absolute;
    top: 5px;
    right: 25px;
    z-index: 10;
    background-color: rgba(255, 255, 255, 0.9);
    padding: 8px 12px;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    max-width: 90%;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}

/* Switcher */
.switch {
    position: relative;
    display: inline-block;
    width: 38px;
    height: 20px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}


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

.switch input:focus + .slider {
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.5);
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: var(--transition);
    border-radius: 50%;
}

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

input:checked + .slider:before {
    transform: translateX(18px);
}

.log-content {
    height: 100%;
    overflow: auto;
    padding: 15px;
    font-size: 14px;
    line-height: 1.5;
    font-family: 'Consolas', 'Monaco', monospace;
    white-space: pre-wrap;
    word-break: break-all;
    will-change: transform;
    transform: translateZ(0);
}

.system-log, .updates-log {
    background-color: #f8f8f8;
}

/* Settings Section */
.settings-container {
    padding: 10px;
}

.settings-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

fieldset {
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 12px;
}

legend {
    font-weight: bold;
    color: var(--primary-color);
}

.form-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.nested-option {
    margin-left: 30px;
}

.form-control {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: var(--border-radius);
    font-size: 14px;
}

.btn {
    background-color: var(--secondary-color);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-weight: bold;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn:hover {
    background-color: #2980b9;
}

/* Proxy Settings */
#proxy_settings, #auth_settings {
    padding-top: 8px;
    padding-bottom: 5px;
    padding-left: 20px;
    display: flex;
    flex-wrap: nowrap;
    gap: 12px;
    align-items: center;
}

#proxy_settings .form-group, #auth_settings .form-group {
    margin: 0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

#proxy_settings label, #auth_settings label {
    font-size: 12px;
    color: var(--primary-color);
    font-weight: 500;
    white-space: nowrap;
    margin: 0;
}

#proxy_settings .form-control, #auth_settings .form-control {
    height: 28px;
    padding: 2px 8px;
    border: 1px solid #ddd;
    border-radius: var(--border-radius);
    font-size: 12px;
    transition: var(--transition);
}

#proxy_host {
    width: 200px;
}

#proxy_port {
    width: 70px;
}

#proxy_login, #proxy_password, #auth_username, #auth_password, #auth_password_confirm {
    width: 120px;
}

#proxy_settings .form-control:focus, #auth_settings .form-control:focus {
    border-color: var(--secondary-color);
    outline: none;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.15);
}

/* Alternative mirror operation methods */
.alternative-methods {
    margin-left: 20px;
    padding: 15px;
    border: 1px solid #ddd;
    border-radius: 5px;
    background-color: #f9f9f9;
    display: none;
}

.url-group {
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.url-group label {
    white-space: nowrap;
    font-weight: 500;
    min-width: 280px;
}

.url-input-container {
    position: relative;
    display: flex;
    align-items: center;
    flex: 1;
}

.url-input {
    width: 100%;
    padding: 8px 40px 8px 10px;
    border: 1px solid #ccc;
    border-radius: var(--border-radius);;
    font-size: 14px;
}

.dropdown-arrow {
    position: absolute;
    right: 15px;
    cursor: pointer;
    color: #666;
    pointer-events: none;
}

.url-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ccc;
    border-top: none;
    border-radius: 0 0 4px 4px;
    max-height: 150px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
}

.url-option {
    padding: 8px 10px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
}

.url-option:hover {
    background-color: #f5f5f5;
}

.url-option:last-child {
    border-bottom: none;
}

.radio-group {
    margin: 8px 0 5px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.radio-group input[type="radio"] {
    margin: 0;
}

.radio-group label {
    font-weight: normal;
    cursor: pointer;
    margin: 0;
}

/* Distribution update settings */
#distro_settings .form-group label {
    width: 170px;
}

.form-group.margin-top {
    margin-top: 10px;
}

.distro-methods {
    margin-left: 20px;
    padding: 15px;
    border: 1px solid #ddd;
    border-radius: 5px;
    background-color: #f9f9f9;
    display: none;
}

/* File upload styles */
.file-input {
    display: none;
}

.file-name-display {
    color: var(--primary-color);
    font-size: 14px;
    font-style: italic;
}

/* Upload notifications */
.upload-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 20px;
    border-radius: 5px;
    color: white;
    font-weight: 500;
    z-index: 1000;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    animation: slideIn 0.3s ease-out;
}

.upload-notification.success {
    background-color: #27ae60;
}

.upload-notification.error {
    background-color: #e74c3c;
}

.upload-notification i {
    margin-right: 8px;
}

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

/* Loading state for upload button */
.file-upload-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.file-upload-btn .fa-spinner {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Select dropdown styling */
select.form-control {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right center;
    background-repeat: no-repeat;
    background-size: 40px 30px;
    appearance: none;
    cursor: pointer;
}

select.form-control:focus {
    border-color: var(--secondary-color);
    outline: none;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.15);
}

/* Priority download order styles */
details.no-margin {
    margin-bottom: 0;
    margin-left: 20px;
}

summary.not-bold {
    font-weight: normal;
}

.priority-container {
    margin-top: 10px;
    padding: 15px;
    border: 1px solid #ddd;
    border-radius: var(--border-radius);
    background-color: #f9f9f9;
}

.priority-methods {
    display: flex;
    flex-direction: row;
    gap: 15px;
    flex-wrap: wrap;
}

.priority-item {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    background-color: white;
    border: 1px solid #ddd;
    border-radius: var(--border-radius);
    transition: var(--transition);
    cursor: move;
    flex: 1;
    min-width: 250px;
}

.priority-item:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border-color: var(--secondary-color);
}

.priority-item.dragging {
    opacity: 0.5;
    transform: rotate(2deg);
}

.priority-item * {
    pointer-events: none;
}

.priority-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background-color: var(--secondary-color);
    color: white;
    border-radius: 50%;
    font-weight: bold;
    font-size: 12px;
    margin-right: 12px;
    flex-shrink: 0;
}

.priority-info {
    display: flex;
    align-items: center;
    flex: 1;
    gap: 8px;
}

.priority-info i {
    color: var(--primary-color);
    width: 16px;
}

.priority-info span {
    font-weight: 500;
}

.priority-controls {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.priority-btn {
    background: none;
    border: 1px solid #ccc;
    border-radius: 3px;
    width: 24px;
    height: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    color: #666;
}

.priority-btn:hover {
    background-color: var(--secondary-color);
    color: white;
    border-color: var(--secondary-color);
}

.priority-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.priority-btn:disabled:hover {
    background: none;
    color: #666;
    border-color: #ccc;
}

.priority-btn i {
    font-size: 10px;
}

/* Restricted access methods */
.restricted-methods {
    margin-left: 20px;
    padding: 15px;
    border: 1px solid #ddd;
    border-radius: 5px;
    background-color: #f9f9f9;
    display: none;
}

.restricted-header {
    font-weight: 500;
    color: var(--primary-color);
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 1px solid #ddd;
}

.restricted-option {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.restricted-option label {
    font-weight: normal;
    margin: 0;
    width: 50px;
    flex-shrink: 0;
}

/* Information Section */
.info-container {
    padding: 20px;
}

details {
    margin-bottom: 16px;
}

summary {
    font-weight: bold;
    cursor: pointer;
}

.info-section {
    margin-bottom: 20px;
}

.host-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(200px, 1fr));
    gap: 10px;
    margin-top: 8px;
}

.update-link {
    background: none;
    font: inherit;
    padding: 8px 16px;
    margin-top: 8px;
    display: inline-block;
    color: var(--secondary-color);
    text-decoration: none;
    font-weight: bold;
    border: 2px solid var(--secondary-color);
    border-radius: var(--border-radius);
    transition: var(--transition);
}

.update-link:hover {
    background-color: var(--secondary-color);
    color: white;
}

/* Force Update */
.update-link.force-update {
    background-color: var(--warning-color);
    border-color: var(--warning-color);
}

.update-link.force-update:hover {
    background-color: #e67e22;
}

.force-update-warning {
    color: var(--warning-color);
    font-weight: 500;
}

.update-link i {
    margin-right: 8px;
}

.footer {
    margin-top: 20px;
    text-align: right;
}

.github-link, .telegram-link, .license-link {
    background: none;
    font: inherit;
    padding: 0;
    border: none;
    color: var(--secondary-color);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.telegram-link {
    margin-left: 10px;
}

.github-link:hover, .telegram-link:hover, .license-link:hover {
    text-decoration: underline;
}

/* Styles for the update status section */
.update-status-info p {
    margin: 0;
    flex: 1;
    min-width: 200px;
    display: flex;
    align-items: center;
    font-size: 14px;
}

.update-status-info span {
    margin-left: 8px;
    font-weight: 500;
    color: var(--primary-color);
}

.update-available {
    background-color: rgba(52, 152, 219, 0.1);
    border-left: 4px solid var(--secondary-color);
    padding: 12px 15px;
    margin: 15px 0;
    border-radius: 0 var(--border-radius) var(--border-radius) 0;
}

.update-available h4 {
    margin-top: 0;
    margin-bottom: 10px;
    color: var(--secondary-color);
    font-size: 16px;
    display: flex;
    align-items: center;
}

.update-changes {
    font-size: 14px;
    line-height: 1.5;
    max-height: 150px;
    overflow-y: auto;
    padding-right: 5px;
    margin-bottom: 10px;
}

.update-changes ul {
    margin: 0;
    padding-left: 20px;
}

.update-changes li {
    margin-bottom: 5px;
}

#check-updates-btn {
    margin-top: 12px;
    display: inline-block;
}

/* =================================
   LOGIN PAGE STYLES
   ================================= */

/* Login page body override */
body.login-page {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    height: 100vh;
    margin: 0;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Login container */
.login-container {
    background: white;
    padding: 40px;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    width: 100%;
    max-width: 400px;
}

.login-title {
    text-align: center;
    color: var(--primary-color);
    margin-bottom: 30px;
    font-size: 24px;
}

/* Login form overrides */
.login-container .form-group {
    margin-bottom: 20px;
}

.login-container .form-group label {
    font-weight: 500;
    min-width: 80px;
    text-align: right;
}

.login-container .form-group input {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: var(--border-radius);
    font-size: 16px;
}

.login-container .form-group input:focus {
    outline: none;
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

.login-btn {
    width: 100%;
    padding: 12px;
    background-color: var(--secondary-color);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-size: 16px;
    cursor: pointer;
    transition: var(--transition);
}

.login-btn:hover {
    background-color: #2980b9;
}

.login-container .error {
    color: var(--error-color);
    margin-top: 15px;
    text-align: center;
    padding: 10px;
    background-color: #fdf2f2;
    border: 1px solid var(--error-color);
    border-radius: var(--border-radius);
}

/* Adaptability */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 15px;
    }

    .header-controls {
        width: 100%;
        justify-content: center;
    }

    .tabs {
        flex-wrap: wrap;
    }

    .tab-link {
        padding: 10px;
        font-size: 14px;
    }

    .host-list {
        grid-template-columns: 1fr;
    }

    .log-controls {
        gap: 8px;
        padding: 6px;
        max-width: 95%;
    }

    .log-content {
        padding: 10px;
        font-size: 12px;
    }

    .control-group label {
        font-size: 12px;
    }

    .switch {
        width: 30px;
        height: 16px;
    }

    .slider:before {
        height: 12px;
        width: 12px;
    }

    input:checked + .slider:before {
        transform: translateX(14px);
    }

    /* Distribution update settings */
    .file-upload-btn {
        width: 100%;
        justify-content: center;
    }

    .file-name-display {
        text-align: center;
        margin-top: 5px;
    }

    .upload-notification {
        top: 10px;
        right: 10px;
        left: 10px;
        text-align: center;
    }

    /* Proxy and auth Settings */
    #proxy_settings, #auth_settings {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    #proxy_settings .form-group, #auth_settings .form-group {
        width: 100%;
        justify-content: space-between;
    }

    #proxy_settings label, #auth_settings label {
        width: 95px;
        text-align: right;
    }

    #proxy_settings .form-control, #auth_settings .form-control {
        flex-grow: 1;
        width: calc(100% - 90px) !important;
    }

    /* Priority download order */
    .priority-methods {
        flex-direction: column;
        gap: 8px;
    }

    .priority-item {
        padding: 8px 10px;
        min-width: auto;
        flex: none;
    }

    .priority-number {
        width: 20px;
        height: 20px;
        font-size: 11px;
        margin-right: 10px;
    }

    .priority-info span {
        font-size: 14px;
    }

    .priority-btn {
        width: 20px;
        height: 18px;
    }
}