/* =====================================================================
     1. THEME & BOOTSTRAP OVERRIDES
   ====================================================================== */
/*
   Color variables are now set dynamically by static/script.js
   This file defines the structure and non-color related properties.
*/
 :root {
    /* Override Bootstrap variables */
    --bs-body-bg: var(--bg-color); /* Set by JS */
    --bs-body-color: var(--text-color); /* Set by JS */
    --bs-body-font-family: 'Comic Neue', sans-serif;
    --bs-primary: var(--primary-color); /* Set by JS */
    --bs-link-color: #ffffff; /* White links for high contrast */
    --bs-link-hover-color: #c9d1d9; /* Use main text color for hover */
}

body {
    display: flex;
    align-items: center;
    font-size: 16px; /* Use a slightly larger base font size for readability */
    min-height: 100vh;
    background-image: radial-gradient(var(--border-color) 1px, transparent 1px);
    background-size: 20px 20px;
}

/* =====================================================================
     2. BACKGROUND & LAYOUT
   ====================================================================== */

.container {
    position: relative; /* Needed for absolute positioning of the child switcher */
    background-color: var(--panel-bg);
    border-radius: 4px;
    border: 3px solid var(--border-color);
    box-shadow: 6px 6px 0 var(--border-color); /* Comic book panel effect */
    padding: 1.5rem; /* Reduce container padding */
    padding-top: 3.5rem; /* Adjust top padding for the language bar */
}

/* =====================================================================
     3. CUSTOM STYLES & COMPONENTS
   ====================================================================== */

.display-5 {
    font-family: 'Bangers', cursive;
    font-size: 3.5rem; /* Larger, more impactful heading */
    color: var(--primary-color); /* Use the theme's primary color for the title */
    text-shadow: 0 2px 4px var(--shadow-color);
}

.lead {
    color: var(--text-color);
}

.form-control, .form-select {
    background-color: var(--input-bg);
    border-color: var(--border-color) !important;
    color: var(--text-color); /* Dark text for light input background */
}

.form-control:focus, .form-select:focus {
    background-color: #2d3748; /* Invert background to dark on focus */
    border-color: var(--primary-color) !important; /* Use !important to override Bootstrap specificity */
    box-shadow: 0 0 0 0.25rem rgba(var(--bs-primary-rgb), 0.25);
    color: #e2e8f0; /* Invert text to light on focus */
}

/* Style for the placeholder text */
.form-control::placeholder {
    color: #6c757d; /* Muted dark grey for placeholder on light background */
    transition: color 0.2s ease-in-out;
}

.form-control:focus::placeholder {
    color: #a0aec0; /* Invert placeholder to a muted light grey on focus */
}

.btn-primary {
    --bs-btn-color: #ffffff; /* White text on the button */
    --bs-btn-bg: var(--primary-color); /* Use the theme's primary color */
    --bs-btn-border-color: var(--primary-color);
    --bs-btn-hover-color: #ffffff;
    --bs-btn-hover-bg: var(--primary-color-hover);
    --bs-btn-hover-border-color: var(--primary-color-hover);
    --bs-btn-active-bg: var(--primary-color-hover);
    --bs-btn-active-border-color: var(--primary-color-hover);
    --bs-btn-disabled-bg: var(--primary-color);
    --bs-btn-disabled-border-color: var(--primary-color);
}

.spinner {
    width: 1em;
    height: 1em;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #ffffff;
    animation: spin 1s ease-in-out infinite;
}

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

.alert-success {
    background-color: #fffde7; /* A punchy, caption-box yellow */
    border: 3px solid var(--border-color);
    --bs-alert-color: var(--text-color);
    border-radius: 4px;
    box-shadow: 4px 4px 0 var(--border-color);
}

.alert-success .alert-heading {
    color: var(--text-color);
    opacity: 0.9;
}

.copy-button {
    font-size: 1.25rem;
    color: var(--text-color);
    opacity: 0.7;
    transition: all 0.2s ease-in-out;
}

.copy-button:hover {
    color: var(--primary-color);
    opacity: 1;
    transform: scale(1.1);
}

.short-url-display {
    display: block;
    font-family: 'Bangers', cursive;
    font-size: 2.5rem;
    text-align: center;
    padding: 0.5rem;
    margin-top: 0.5rem;
    border-radius: 4px;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.2s ease-out, background-color 0.2s ease-in-out;
}

.short-url-display:hover {
    transform: scale(1.02); /* Keep the subtle grow effect */
    text-decoration: underline; /* Underline the whole link on hover */
}

.short-url-domain {
    color: var(--primary-color); /* Use the same primary color */
    opacity: 0.8; /* Make it slightly less prominent than the code */
}

.short-url-code {
    color: var(--primary-color);
    text-decoration: none; /* Remove the default underline from just this part */
}

.short-url-display.copied .short-url-code {
    color: #34A853; /* A satisfying green to confirm copy */
    text-decoration: none;
}

.ttl-control-label {
    color: var(--primary-color) !important; /* Use !important to override Bootstrap's .text-muted */
    font-weight: 500;
    opacity: 0.9;
}

/* =====================================================================
     4. FOOTER
   ====================================================================== */
 
.footer-links a {
    color: var(--text-color); /* Use the main text color for high contrast against the light background */
    transition: color 0.2s ease-in-out;
}

/* Add the pipe separator using CSS for a clean separation of content and presentation */
.footer-links a + a::before {
    content: "|";
    margin: 0 0.5rem;
    color: var(--text-color);
}

/* =====================================================================
     5. PAGE-SPECIFIC STYLES
   ====================================================================== */

/* --- Preview Page --- */
.preview-card {
    width: 100%;
    max-width: 600px;
    padding: 2rem;
    background-color: var(--panel-bg);
    border-radius: 0.75rem;
    border: 1px solid var(--border-color);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

.preview-card .h4 {
    color: var(--primary-color);
}

.destination-url {
    font-family: monospace;
    word-break: break-all;
    background-color: var(--input-bg);
    padding: 0.75rem;
    border-radius: 0.25rem;
    color: var(--text-color);
    border: 1px solid var(--border-color);
}

.btn-proceed {
    background-color: var(--primary-color);
    color: #0a0f1e; /* Dark text on bright button */
    border: none;
}

.btn-proceed:hover {
    background-color: var(--primary-color-hover);
    color: #0a0f1e;
}

/* --- Health Check Page --- */
.health-status .ok {
    color: #4caf50; /* A consistent, healthy green */
    font-weight: bold;
}

.health-status .error {
    color: #f44336; /* A consistent, clear red for errors */
    font-weight: bold;
}

.table {
    --bs-table-bg: var(--panel-bg);
    --bs-table-border-color: var(--border-color);
    --bs-table-striped-bg: rgba(var(--bs-primary-rgb), 0.05);
    --bs-table-color: var(--text-color);
}

/* =====================================================================
     Right-to-Left (RTL) Language Support
   ====================================================================== */
[dir="rtl"] {
    text-align: right;
    direction: rtl;
}

/* =====================================================================
     Animations & Dynamic UI
   ====================================================================== */

.alert.fade-in-up {
    animation: fadeInUp 0.5s ease-out forwards;
}

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

/* =====================================================================
     6. RESPONSIVE DESIGN (for Mobile)
   ====================================================================== */

@media (max-width: 576px) {
    .display-5 {
        font-size: 2.5rem; /* Slightly smaller heading on mobile */
    }

    .short-url-display {
        font-size: 2rem; /* Smaller font for the result link */
    }

    .short-url-domain {
        display: none; /* Hide the domain on small screens to focus on the code */
    }
}