/* style.css - RDC Auth System (Mobile-First) */

/* --- CSS Variables --- */
:root {
    /* Fonts */
    --font-primary: 'Poppins', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-secondary: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; /* System fonts for inputs */

    /* Gradient Colors (Using the first pair: #4b6cb7 to #182848) */
    --gradient-start: #4b6cb7;
    --gradient-end: #182848;
    /* Alternate Gradients:
       --gradient-start: #24c6dc; --gradient-end: #514a9d;
       --gradient-start: #dc2424; --gradient-end: #4a569d;
    */

    /* Core Colors */
    --color-text-on-gradient: #ffffff;
    --color-text-subtitle-on-gradient: #d0d8e8;
    --color-text-dark: #2c3e50;
    --color-text-muted: #6c757d; /* Slightly adjusted muted color */
    --color-background-card: #ffffff;
    --color-border: #dee2e6;
    --color-input-border: #ced4da;
    --color-input-focus-border: #4b6cb7; /* Match gradient */
    --color-input-focus-shadow: rgba(75, 108, 183, 0.2);
    --color-button-bg: var(--gradient-start); /* Use gradient start for button */
    --color-button-hover-bg: #3a5a9a; /* Darker shade of gradient start */
    --color-button-text: #ffffff;
    --color-link: var(--gradient-start);
    --color-error: #e74c3c; /* Adjusted error red */
    --color-error-bg: #fdeded; /* Lighter error bg */
    --color-error-border: #fcc;
    --color-error-text: #a94442;

    /* Sizes & Spacing */
    --spacing-unit: 8px;
    --border-radius: 6px;
    --card-max-width-desktop: 430px; /* Max width on desktop */
    --card-padding-mobile: calc(var(--spacing-unit) * 3);  /* 24px */
    --card-padding-desktop: calc(var(--spacing-unit) * 5); /* 40px */
}

/* --- Base & Reset --- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 100%; /* 16px base */
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    height: 100%;
}

body {
    font-family: var(--font-secondary); /* Base font for inputs etc. */
    color: var(--color-text-on-gradient);
    background-color: var(--gradient-end); /* Fallback */
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end)) no-repeat center center fixed;
    background-size: cover; /* Ensure gradient covers */
    display: flex;
    flex-direction: column;
    justify-content: center; /* Center card vertically */
    align-items: center;
    min-height: 100%;
    padding: var(--card-padding-mobile); /* Base padding for mobile */
}

/* --- Main Container --- */
.main-container {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-grow: 1;
}

/* --- Auth & Error Containers/Cards (Mobile Base) --- */
.auth-container,
.error-container {
    width: 100%;
    /* max-width defined in media query */
}

.auth-card,
.error-card {
    width: 100%; /* Take full width of container */
    background-color: var(--color-background-card);
    color: var(--color-text-dark);
    border-radius: var(--border-radius);
    padding: var(--card-padding-mobile);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    text-align: center;
}

/* --- Headers (Mobile Base) --- */
.auth-header,
.error-header {
    margin-bottom: calc(var(--spacing-unit) * 3);
}

.auth-logo {
    max-width: 130px; /* Slightly smaller logo on mobile */
    margin-bottom: var(--spacing-unit);
    height: auto;
}

.auth-title,
.error-title {
    font-family: var(--font-primary);
    font-size: 1.6rem; /* Adjusted for mobile */
    font-weight: 600;
    color: var(--color-text-dark);
    margin-bottom: calc(var(--spacing-unit) * 0.5);
}

.auth-subtitle {
    font-size: 0.95rem;
    color: var(--color-text-muted);
    margin-bottom: calc(var(--spacing-unit) * 2.5);
}

/* --- Forms (Mobile Base) --- */
.auth-form {
    text-align: left;
}

.form-group {
    margin-bottom: calc(var(--spacing-unit) * 2); /* 16px */
}

.form-label {
    display: block;
    font-family: var(--font-primary);
    font-size: 0.8rem; /* Smaller label */
    font-weight: 600; /* Bolder label */
    margin-bottom: calc(var(--spacing-unit) * 0.5); /* 4px */
    color: var(--color-text-dark);
    text-transform: uppercase; /* Uppercase labels for style */
    letter-spacing: 0.5px;
}

.form-control {
    display: block;
    width: 100%; /* Full width on mobile */
    padding: calc(var(--spacing-unit) * 1.25) calc(var(--spacing-unit) * 1.5); /* 10px 12px */
    font-size: 1rem;
    font-family: var(--font-secondary);
    font-weight: 400;
    line-height: 1.5;
    color: var(--color-text-dark);
    background-color: var(--color-background-card);
    background-clip: padding-box;
    border: 1px solid var(--color-input-border);
    appearance: none;
    border-radius: var(--border-radius);
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.form-control:focus {
    color: var(--color-text-dark);
    background-color: var(--color-background-card);
    border-color: var(--color-input-focus-border);
    outline: 0;
    box-shadow: 0 0 0 0.2rem var(--color-input-focus-shadow);
}

/* --- Buttons (Mobile Base) --- */
.btn {
    display: inline-block;
    font-family: var(--font-primary);
    font-weight: 600; /* Bolder buttons */
    line-height: 1.5;
    color: var(--color-button-text);
    text-align: center;
    text-decoration: none;
    vertical-align: middle;
    cursor: pointer;
    user-select: none;
    background-color: var(--color-button-bg);
    border: 1px solid transparent;
    padding: calc(var(--spacing-unit) * 1.35) calc(var(--spacing-unit) * 2); /* Slightly larger padding */
    font-size: 0.95rem; /* Slightly smaller button text */
    letter-spacing: 0.5px;
    border-radius: var(--border-radius);
    transition: all 0.2s ease-in-out; /* Smooth transition for all properties */
    text-transform: uppercase;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.btn-primary {
    color: var(--color-button-text);
    background-color: var(--color-button-bg);
    border-color: var(--color-button-bg);
}

.btn-primary:hover {
    color: var(--color-button-text);
    background-color: var(--color-button-hover-bg);
    border-color: var(--color-button-hover-bg);
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
    transform: translateY(-1px); /* Slight lift on hover */
}

.btn-block {
    display: block;
    width: 100%; /* Full width is default for buttons now */
}

.form-submit-group {
    margin-top: calc(var(--spacing-unit) * 3); /* 24px */
}

/* --- Button Loading State (Universal) --- */
.btn-submit {
    position: relative;
    overflow: hidden;
}
.btn-submit .btn-text {
    transition: opacity 0.2s ease-in-out;
}
.btn-submit .spinner-border {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%); /* Keep centered */
    opacity: 0;
    width: 1.1rem; /* Adjusted spinner size */
    height: 1.1rem;
    border-width: 0.18em; /* Thinner border */
    transition: opacity 0.2s ease-in-out;
    pointer-events: none;
}
.btn-submit.is-loading .btn-text {
    opacity: 0;
    pointer-events: none;
}
.btn-submit.is-loading .spinner-border {
    opacity: 1;
}
.spinner-border {
    display: inline-block;
    vertical-align: -0.125em;
    border: 0.2em solid currentColor; /* Use button text color */
    border-right-color: transparent;
    border-radius: 50%;
    animation: spinner-border .75s linear infinite;
}
@keyframes spinner-border {
    to { transform: translate(-50%, -50%) rotate(360deg); } /* Ensure transform persists */
}
.btn-submit .spinner-border {
    transform-origin: center center;
}


/* --- Validation & Alerts (Universal Styling) --- */
.form-control.is-invalid {
    border-color: var(--color-error);
    padding-right: calc(1.5em + 0.75rem);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' width='12' height='12' fill='none' stroke='%23e74c3c'%3e%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath stroke-linejoin='round' d='M5.8 3.6h.4L6 6.5z'/%3e%3ccircle cx='6' cy='8.2' r='.6' fill='%23e74c3c' stroke='none'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right calc(0.375em + 0.1875rem) center;
    background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
}
.form-control.is-invalid:focus {
    border-color: var(--color-error);
    box-shadow: 0 0 0 0.2rem rgba(231, 76, 60, 0.25); /* Match error color */
}
.invalid-feedback {
    display: none;
    width: 100%;
    margin-top: 0.25rem;
    font-size: 0.8em; /* Smaller error text */
    color: var(--color-error);
}
.form-control.is-invalid ~ .invalid-feedback {
    display: block;
}
.alert {
    position: relative;
    padding: calc(var(--spacing-unit) * 1) calc(var(--spacing-unit) * 1.5);
    margin-bottom: calc(var(--spacing-unit) * 2);
    border: 1px solid transparent;
    border-radius: var(--border-radius);
    font-size: 0.9rem;
    text-align: left;
}
.alert-danger {
    color: var(--color-error-text);
    background-color: var(--color-error-bg);
    border-color: var(--color-error-border);
}

/* --- Links & Footer (Mobile Base) --- */
.form-links {
    margin-top: calc(var(--spacing-unit) * 2);
    text-align: center;
}
.form-link {
    color: var(--color-link);
    text-decoration: none;
    font-size: 0.8rem; /* Smaller link text */
    transition: color 0.15s ease-in-out;
}
.form-link:hover {
    color: var(--color-button-hover-bg);
    text-decoration: underline;
}
.auth-footer {
    margin-top: calc(var(--spacing-unit) * 3);
    font-size: 0.75rem; /* Smaller footer text */
    color: var(--color-text-muted);
    text-align: center;
}

/* --- Error Page Specific Styles (Mobile Base) --- */
.error-card { text-align: center; }
.error-code-box {
    display: inline-block;
    background-color: rgba(231, 76, 60, 0.08); /* Subtle error bg */
    padding: calc(var(--spacing-unit)*0.5) calc(var(--spacing-unit)*2);
    border-radius: 50px;
    margin-bottom: calc(var(--spacing-unit)*1.5);
}
.error-code {
    font-family: var(--font-primary);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--color-error);
    line-height: 1;
}
.error-title { font-size: 1.6rem; margin-top: 0; }
.error-message {
    font-size: 0.95rem;
    color: var(--color-text-muted);
    margin-bottom: calc(var(--spacing-unit) * 3);
    line-height: 1.7;
}
.error-actions { margin-top: calc(var(--spacing-unit) * 2.5); }
.error-details {
    margin-top: calc(var(--spacing-unit) * 2.5);
    padding: var(--spacing-unit);
    background-color: #f8f9fa;
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    text-align: left;
    font-size: 0.8rem;
    max-height: 150px; /* Limit height on mobile */
    overflow-y: auto;
    color: #333;
}
.error-details strong { display: block; margin-bottom: var(--spacing-unit); }
.error-details pre {
    white-space: pre-wrap;
    word-wrap: break-word;
    margin-top: 0;
    padding: var(--spacing-unit);
    background-color: #e9ecef;
    border-radius: 4px;
    font-size: 0.9em; /* Slightly larger pre text */
}


/* =========================================== */
/* --- Tablet and Up Overrides (min-width) --- */
/* =========================================== */
@media (min-width: 768px) {
    body {
        padding: calc(var(--spacing-unit) * 4); /* Increase body padding */
    }

    .auth-container,
    .error-container {
        max-width: var(--card-max-width-desktop); /* Apply max-width */
    }

    .auth-card,
    .error-card {
        padding: var(--card-padding-desktop); /* Increase card padding */
        box-shadow: 0 12px 35px rgba(0, 0, 0, 0.1); /* Enhance shadow */
    }

    .auth-logo {
        max-width: 150px; /* Larger logo */
    }

    .auth-title,
    .error-title {
        font-size: 1.8rem; /* Increase title size */
    }

    .auth-subtitle,
    .error-message {
        font-size: 1rem; /* Increase subtitle size */
    }

    .form-label {
        font-size: 0.875rem; /* Increase label size */
    }

    .btn {
        font-size: 1rem; /* Restore button font size */
    }

    .auth-footer {
        font-size: 0.8rem; /* Increase footer text size */
    }

    .error-details {
        max-height: 200px; /* Allow more height for details */
    }
}


/* =============================================== */
/* --- Larger Desktop Adjustments (Optional) --- */
/* =============================================== */
@media (min-width: 1200px) {
    /* Example: Further increase max-width if needed */
    /* :root { --card-max-width-desktop: 480px; } */

    /* Example: Slightly larger base font size on very large screens */
    /* html { font-size: 105%; } */
}