/*-----------------------------------------------
 * MODALS AND SETTINGS STYLES
 * 
 * Contents:
 * 1. Modal Backdrops
 * 2. Modal Containers
 * 3. Modal Headers
 * 4. Tab Navigation
 * 5. Settings Content
 * 6. Form Controls
 * 7. Unit Toggle Switch
 * 8. Buttons & Actions
 * 9. Responsive Adjustments
 *-----------------------------------------------*/

/*-----------------------------------------------
 * 1. MODAL BACKDROPS
 *-----------------------------------------------*/
 .modal-backdrop {
    z-index: 999;
    background-color: rgba(0, 0, 0, 0.5);
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/*-----------------------------------------------
 * 2. MODAL CONTAINERS
 *-----------------------------------------------*/
/* Settings modal */
.settings-modal {
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    z-index: 1001;
    
    /* Set proper dimensions */
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    
    /* Ensure proper display */
    display: block;
    overflow-y: auto;
    
    /* Dark theme appearance */
    background-color: #1e2633; 
    color: #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.settings-modal-content {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

/*-----------------------------------------------
 * 3. MODAL HEADERS
 *-----------------------------------------------*/
.settings-modal-header {
    display: flex;
    justify-content: center; /* Center title */
    align-items: center;
    padding: 15px 20px;
    background-color: rgba(0, 0, 0, 0.3);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

/* Make sure the title is properly styled */
.settings-modal-header h3 {
    margin: 0;
    color: white;
    font-weight: 500;
}

/*-----------------------------------------------
 * 4. TAB NAVIGATION
 *-----------------------------------------------*/
/* Tab Navigation */
.settings-tabs {
    display: flex;
    background-color: #121923;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.settings-tab-btn {
    flex: 1;
    padding: 12px 16px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    color: #b0b0b0;
    transition: all 0.2s ease;
}

.settings-tab-btn:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: #ffffff;
}

.settings-tab-btn.active {
    border-bottom-color: var(--primary-color);
    color: var(--primary-color);
    background-color: rgba(30, 136, 229, 0.15);
}

/* Tab Content */
.settings-tab-content {
    display: none;
    padding: 20px;
}

.settings-tab-content.active {
    display: block;
}

/*-----------------------------------------------
 * 5. SETTINGS CONTENT
 *-----------------------------------------------*/
/* Section Styling */
.settings-section {
    margin-bottom: 24px;
}

.settings-section h4 {
    margin-top: 0;
    margin-bottom: 12px;
    font-size: 18px;
    font-weight: 500;
    color: #ffffff;
}

/* Settings label styling */
.settings-label {
    display: block;
    font-size: 1rem;
    font-weight: 500;
    color: #d0d0d0;
    margin-bottom: 6px;
}

/* Enhance the divider */
.settings-divider {
    margin: 16px 0;
    height: 1px;
    background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.1), transparent);
}

/* Make help text a bit more subtle */
.settings-help-text {
    font-size: 0.85rem;
    color: #a0a0a0;
    margin: 4px 0 16px 0;
    line-height: 1.4;
}

/* Back button for settings modal */
.settings-back-button {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    background-color: rgba(255, 255, 255, 0.2);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: none; /* Hidden by default, shown via JS on mobile */
    align-items: center;
    justify-content: center;
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.settings-back-button:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

/* API Key Section Styling */
.api-keys-container {
    margin-bottom: 15px;
}

.api-key-container {
    margin-bottom: 15px;
    padding: 12px;
    background-color: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.api-key-container:last-child {
    margin-bottom: 0;
}

.settings-note {
    font-style: italic;
    color: #909090;
}

.api-status-note {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    background-color: rgba(0, 122, 255, 0.15);
    border-left: 3px solid rgba(0, 122, 255, 0.8);
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 15px;
    font-size: 14px;
}

.api-key-status {
    position: sticky;
    bottom: 0;
    width: 100%;
    padding: 10px 20px;
    text-align: center;
    background-color: rgba(20, 30, 45, 0.95);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    color: #e0e0e0;
}

/* Status Colors */
.status-success {
    color: var(--success-color);
}

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

.status-info {
    color: var(--primary-color);
}

/* Links */
.settings-link {
    color: var(--primary-color);
    text-decoration: none;
}

.settings-link:hover {
    text-decoration: underline;
}

.settings-info-message {
    padding: 12px;
    background-color: rgba(33, 150, 243, 0.15);
    border-radius: 6px;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    color: #64b5f6;
    font-size: 0.9rem;
}

.settings-info-message i {
    margin-right: 8px;
    font-size: 1.1rem;
}

/*-----------------------------------------------
 * 6. FORM CONTROLS
 *-----------------------------------------------*/
/* Form Controls */
.settings-select {
    width: 100%;
    padding: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    font-size: 16px;
    background-color: #2c3748;
    color: #e0e0e0;
    margin-bottom: 8px;
}

.settings-form-group {
    position: relative;
}

.settings-form-group input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    font-size: 15px;
    background-color: #2c3748;
    color: #e0e0e0;
}

.settings-form-group input:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 2px rgba(30, 136, 229, 0.3);
}

.api-key-info {
    margin-top: 6px;
    font-size: 0.85rem;
    color: #b0b0b0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/*-----------------------------------------------
 * 7. UNIT TOGGLE SWITCH
 *-----------------------------------------------*/
.unit-toggle-container {
    position: relative;
    width: 140px;
    height: 40px;
    background-color: #2c3748;
    border-radius: 30px;
    margin-top: 10px;
    display: flex;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3);
}

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

.unit-toggle-label {
    flex: 1;
    text-align: center;
    z-index: 1;
    line-height: 40px;
    cursor: pointer;
    color: #a0a0a0;
    font-weight: 600;
    transition: all 0.3s ease;
}

.unit-toggle-slider {
    position: absolute;
    top: 4px;
    left: 4px;
    width: 70px;
    height: 32px;
    background-color: var(--primary-color);
    border-radius: 20px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.unit-toggle-input:focus~.unit-toggle-slider {
    box-shadow: 0 0 0 3px rgba(30, 136, 229, 0.3);
}

/* Active toggle label styles */
#imperial-units:checked~.unit-toggle-label:nth-of-type(1),
#metric-units:checked~.unit-toggle-label:nth-of-type(2) {
    color: white;
}

/* Move slider based on selection */
#imperial-units:checked~.unit-toggle-slider {
    left: 4px;
}

#metric-units:checked~.unit-toggle-slider {
    left: calc(50% - 4px);
}

/* Hover effects */
.unit-toggle-container:hover .unit-toggle-slider {
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
}

/* Focus style for accessibility */
.unit-toggle-input:focus~.unit-toggle-slider {
    box-shadow: 0 0 0 3px rgba(30, 136, 229, 0.3);
}

/*-----------------------------------------------
 * 8. BUTTONS & ACTIONS
 *-----------------------------------------------*/
/* Settings button */
.settings-button-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 100;
}

#open-settings {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.8);
    color: var(--primary-color);
    border: none;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 18px;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

#open-settings:hover {
    background-color: rgba(255, 255, 255, 0.9);
    transform: rotate(30deg);
}

.settings-btn {
    padding: 10px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.settings-btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.settings-btn-primary:hover {
    background-color: #1565c0;
}

.settings-btn-danger {
    background-color: var(--error-color);
    color: white;
}

.settings-btn-danger:hover {
    background-color: #d32f2f;
}

.api-key-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

/* Styles for the install button */
#install-container {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    display: none;
}

#install-button {
    background-color: #1e88e5;
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 50px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    transition: all 0.3s;
}

#install-button:hover {
    background-color: #1565c0;
    transform: translateY(-2px);
}

/* Mobile adjustments for install button */
@media (max-width: 768px) {
    #install-button {
        padding: 10px 16px;
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    #install-container {
        bottom: 70px; /* Position above the floating action buttons */
    }
    
    #install-button {
        padding: 8px 14px;
        font-size: 13px;
        box-shadow: 0 3px 6px rgba(0, 0, 0, 0.3);
    }
}

/*-----------------------------------------------
 * 9. RESPONSIVE ADJUSTMENTS
 *-----------------------------------------------*/
@media (max-width: 768px) {
    .settings-modal {
        width: 95%;
        max-width: none;
    }
    
    .settings-tab-btn {
        padding: 10px;
        font-size: 15px;
    }
    
    .settings-tab-content {
        padding: 15px;
    }
    
    .settings-section h4 {
        font-size: 16px;
    }
    
    .api-key-actions {
        flex-direction: column;
    }
    
    .api-key-actions button {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .settings-modal {
        width: 100%;
        height: 100%;
        max-height: none;
        border-radius: 0;
        top: 0;
        left: 0;
        transform: none;
    }

    /* Center the header text */
    .settings-modal-header {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        position: relative !important;
    }
    
    /* Make sure the title is centered */
    .settings-modal-header h3 {
        text-align: center !important;
        width: 100% !important; 
        margin: 0 !important;
    }
    
    /* Show back button on mobile */
    .settings-back-button {
        display: flex !important;
        left: 10px !important;
        width: 40px !important;
        height: 40px !important;
        background-color: rgba(255, 255, 255, 0.0) !important;
        z-index: 1010 !important;
    }
    
    /* Your remaining existing styles */
    .settings-tab-btn {
        padding: 8px;
        font-size: 14px;
    }
    
    .settings-tab-btn {
        padding: 8px;
        font-size: 14px;
    }
    
    .settings-section {
        margin-bottom: 20px;
    }

    .api-key-container {
        padding: 10px;
    }
    
    .settings-form-group input {
        padding: 8px 10px;
        font-size: 14px;
    }
    
    .api-key-info {
        font-size: 0.8rem;
    }
    
    .settings-info-message {
        padding: 10px;
        font-size: 0.85rem;
    }
}