/* --- GLOBAL STYLES & VARIABLES --- */
:root {
    /* Light Mode (Default) */
    --bg-color: #f4f7fa;
    --surface-color: #ffffff;
    --primary-color: #3b82f6; /* A modern blue */
    --primary-hover-color: #2563eb;
    --secondary-color: #10b981; /* A friendly green */
    --secondary-hover-color: #059669;
    --accent-color: #ef4444; /* For alerts and destructive actions */
    --text-color: #1f2937;
    --text-muted-color: #6b7280;
    --border-color: #e5e7eb;
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --border-radius: 0.5rem;
}

/*
 * FIX: The .dark-mode class is now applied to the <html> element by a
 * blocking script to prevent a "flash of unstyled content".
 * The body styles are now applied when the html element has the class.
 */
html.dark-mode {
    /* Dark Mode Overrides */
    --bg-color: #111827; /* Very dark blue-gray */
    --surface-color: #1f2937; /* Dark blue-gray */
    --text-color: #f9fafb; /* Almost white */
    --text-muted-color: #9ca3af; /* Lighter gray */
    --border-color: #374151; /* Mid gray */
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.2), 0 2px 4px -2px rgb(0 0 0 / 0.2);
}


/* --- Basic Resets & Typography --- */
*, *::before, *::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-color);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color 0.3s ease, color 0.3s ease;
}

h1, h2, h3, h4, h5, h6 {
    margin: 0;
    font-weight: 600;
}

p {
    margin: 0 0 1rem;
    line-height: 1.6;
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: var(--primary-hover-color);
}

/* --- COMMON COMPONENTS --- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1.25rem;
    border-radius: var(--border-radius);
    font-weight: 500;
    font-size: 0.875rem;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
    white-space: nowrap;
}

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

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

.btn-outline {
    background-color: transparent;
    border-color: var(--border-color);
    color: var(--text-muted-color);
}
.btn-outline:hover {
    background-color: var(--bg-color);
    border-color: var(--text-muted-color);
    color: var(--text-color);
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--text-color);
    margin-bottom: 0.5rem;
}

.form-control {
    width: 100%;
    padding: 0.625rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background-color: var(--surface-color);
    color: var(--text-color);
    font-size: 0.875rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

/* --- NEW: Style for read-only and disabled form controls --- */
.form-control[readonly],
.form-control:disabled {
    background-color: var(--bg-color);
    color: var(--text-muted-color);
    cursor: default;
}
/* Prevent focus styles on these inputs */
.form-control[readonly]:focus,
.form-control:disabled:focus {
    box-shadow: none;
    border-color: var(--border-color);
}


/*
 * FIX: This rule explicitly forces a light background and dark text on
 * <select> elements when in dark mode. This is a pragmatic fix to ensure
 * readability in browsers like Firefox that can be resistant to styling
 * native form controls.
 */
html.dark-mode select.form-control {
    background-color: #FFFFFF;
    color: #1f2937; /* Use the default light-mode text color */
    border-color: var(--border-color);
}


.card {
    background-color: var(--surface-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    padding: 1.5rem;
    transition: background-color 0.3s ease;
}

/* --- Theme Toggle Switch --- */
.theme-toggle-container {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 10;
}

.theme-toggle {
    cursor: pointer;
    display: inline-block;
}

/* Visually hide the checkbox but keep it accessible */
#theme-toggle-input {
    border: 0;
    clip: rect(0 0 0 0);
    height: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute;
    width: 1px;
}

.theme-toggle-slider {
    position: relative;
    display: flex;
    align-items: center;
    width: 50px;
    height: 28px;
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    transition: background-color 0.3s ease;
}

.theme-toggle-slider::before {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 22px;
    height: 22px;
    background-color: var(--primary-color); /* Changed to primary color for visibility */
    border-radius: 50%;
    transition: transform 0.3s ease;
}

#theme-toggle-input:checked + .theme-toggle-slider::before {
    transform: translateX(22px);
}

.theme-toggle-slider .icon {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted-color);
    transition: opacity 0.3s ease;
}

.theme-toggle-slider .sun-icon {
    left: 6px;
    opacity: 1;
}

.theme-toggle-slider .moon-icon {
    right: 6px;
    opacity: 0;
}

#theme-toggle-input:checked + .theme-toggle-slider .sun-icon {
    opacity: 0;
}

#theme-toggle-input:checked + .theme-toggle-slider .moon-icon {
    opacity: 1;
}
