/* ==== THEME VARIABLES ==== */
:root {
    --background-color: #f0f4f8;
    --text-color: #333;
    --container-background-color: #ffffff;
    --container-shadow-color: rgba(0, 0, 0, 0.1);
    --input-border-color: #ccc;
    --accent-color: #3498db; 
    --accent-color-hover: #2980b9;
    --error-color: #e74c3c;
    --success-color: #2ecc71;
    --focus-outline-color: #3498db;
}

body.dark-theme {
    --background-color: #1e1e1e;
    --text-color: #f0f4f8;
    --container-background-color: #2c2c2c;
    --container-shadow-color: rgba(0, 0, 0, 0.2);
    --input-border-color: #555;
    --accent-color: #5fa8e3;
    --accent-color-hover: #3498db;
}

/* ==== BASIC STYLES ==== */
body {
    font-family: 'Roboto', sans-serif;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 100vh;
    margin: 0;
    background-color: var(--background-color);
    color: var(--text-color); 
    transition: background-color 0.3s ease, color 0.3s ease;
}

main {
    flex-grow: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

/* ==== CONTAINER ==== */
.container {
    text-align: center;
    padding: 40px 60px;
    background-color: var(--container-background-color);
    border-radius: 16px; 
    box-shadow: 0 6px 12px var(--container-shadow-color);
    max-width: 480px;
    transition: background-color 0.3s ease;
}

h1 {
    font-family: 'Open Sans', sans-serif;
    font-size: 2.5rem;
    margin-bottom: 20px;
    font-weight: 600;
}

p {
    line-height: 1.8;
    font-size: 1.1rem;
}

/* ==== FORM STYLES ==== */
form {
    margin-top: 30px;
    display: flex;
    flex-direction: column;
}

.form-group {
    margin-bottom: 20px;
}

input, textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--input-border-color);
    border-radius: 8px;
    font-size: 1rem;
    font-family: 'Roboto', sans-serif;
    background-color: var(--container-background-color);
    color: var(--text-color);
    box-sizing: border-box; /* Ensures padding doesn't affect width */
    transition: border-color 0.3s ease, background-color 0.3s ease;
}

textarea {
    resize: vertical;
    min-height: 100px;
}

/* For hiding labels while keeping them accessible */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

/* Accessible Focus Styles */
input:focus-visible, textarea:focus-visible {
    outline: 2px solid var(--focus-outline-color);
    outline-offset: 2px;
    border-color: var(--focus-outline-color);
}

/* ==== BUTTON ==== */
.submit-btn {
    background: linear-gradient(135deg, var(--accent-color), var(--accent-color-hover)); 
    color: #fff;
    border: none;
    padding: 14px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: 500;
    transition: background 0.3s ease;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

.submit-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--accent-color-hover), #1e6a8e); 
}

.submit-btn:disabled {
    background: #999;
    cursor: not-allowed;
    opacity: 0.7;
}

/* Hide button text when loading */
.submit-btn[aria-busy='true'] .button-text {
    visibility: hidden;
}

/* Loading Spinner Styles */
.loading-spinner {
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff; /* Make spinner top color solid white */
    width: 18px;
    height: 18px;
    animation: spin 1s linear infinite;
    position: absolute;
    /* Centering is handled by parent flexbox */
    display: none; /* JS will toggle this */
}

.submit-btn[aria-busy='true'] .loading-spinner {
    display: block;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ==== MESSAGES ==== */
.error {
    color: var(--error-color);
    font-size: 0.9rem;
    text-align: left;
    margin-top: 5px; /* Replaces negative margin for better flow */
    min-height: 1em; /* Prevents layout shift when error appears */
}

.success-message, .error-message {
    font-size: 1.1rem;
    margin-top: 20px;
    display: none;
}

.success-message { color: var(--success-color); }
.error-message { color: var(--error-color); }

/* ==== FOOTER ==== */
footer {
    background-color: var(--container-background-color);
    padding: 20px 0;
    color: var(--text-color);
    font-size: 0.9rem;
    text-align: center;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.footer-icons { margin-top: 10px; }
.footer-icons a {
    color: var(--accent-color);
    margin: 0 10px;
    font-size: 1.5rem;
    text-decoration: none;
}
.footer-icons a:hover { color: var(--accent-color-hover); }

/* ==== THEME TOGGLE ==== */
.theme-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 100;
}
.theme-toggle button {
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 1.5rem;
    cursor: pointer;
}


/* ==== RESPONSIVE ==== */
@media (max-width: 600px) {
    .container {
        padding: 30px;
    }
    h1 {
        font-size: 2rem;
    }
    .submit-btn {
        padding: 12px;
    }
}
