:root {
    --primary-color: #2293f5;
    --glass-bg-dark: rgba(36, 36, 36, 0.7);
    --glass-bg-light: rgba(255, 255, 255, 0.7);
    --text-dark: #fff;
    --text-light: #1a1b1e;
    --success-color: #10b981;
    --error-color: #ef4444;
    --border-radius: 16px;
    --transition-speed: 0.3s;
    --button-bg: #1E90FF;
    --button-bg-hover: #1877cc;
    --button-radius: 12px;
    --surface: #222428;
    --surface-elev: #2a2b2f;
    --surface-elev-2: #1e2024;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    transition: all var(--transition-speed) ease;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
        Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
    line-height: 1.6;
    color: var(--text-dark);
}

body.light-theme {
    background: linear-gradient(135deg, #f0f2f5, #e5e7eb);
    color: var(--text-light);
}

body.light-theme .glass-card {
    background: var(--glass-bg-light);
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

body.light-theme .avatar-container {
    background: rgba(255, 255, 255, 0.4);
}

body.light-theme .form-section {
    background: rgba(0, 0, 0, 0.05);
}

body.light-theme .form-input {
    border: 1px solid rgba(0, 0, 0, 0.18);
    color: var(--text-light);
}

body.light-theme .form-input::placeholder {
    color: rgba(0, 0, 0, 0.5);
}

body.light-theme .selectify-toggle {
    border: 1px solid rgba(0, 0, 0, 0.18);
    color: var(--text-light);
}

body.light-theme .selectify-caret {
    background: #666;
}

body.light-theme .selectify-list {
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.12);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.15);
}

body.light-theme .selectify-item:hover,
body.light-theme .selectify-item[aria-selected="true"] {
    background: rgba(30, 144, 255, 0.12);
}

body.light-theme .theme-toggle {
    background: rgba(0, 0, 0, 0.1);
    color: #333;
}

body.light-theme input[type="checkbox"] {
    color: rgba(0, 0, 0, 0.6);
}

body.dark-theme {
    background: linear-gradient(135deg, #1a1b1e, #25262b);
    color: var(--text-dark);
}

.mantine-Container-root {
    padding-left: 1rem;
    padding-right: 1rem;
}

.glass-card {
    border-radius: var(--border-radius);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 2rem;
    position: relative;
    background: var(--glass-bg-dark);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    border-top: 5px solid var(--button-bg);
}

.theme-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    padding: 12px;
    border-radius: 50%;
    cursor: pointer;
    transition: all var(--transition-speed) ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    font-size: 1.2rem;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.theme-toggle:hover {
    transform: rotate(30deg);
}

.top-links {
    position: fixed;
    top: 20px;
    left: 20px;
    display: flex;
    gap: 10px;
    z-index: 1000;
}

.top-links a {
    background: var(--button-bg);
    color: #fff;
    text-decoration: none;
    font-weight: 600;
    padding: 10px 14px;
    border-radius: var(--button-radius);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
}

.top-links a:hover,
.top-links a:focus {
    background: var(--button-bg-hover);
}

.mantine-button-filled {
    background: var(--button-bg) !important;
    color: #fff;
    padding: 12px 20px;
    border-radius: var(--button-radius);
    border: none;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease,
        background-color 0.15s ease;
    font-weight: 600;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.mantine-button-filled:hover,
.mantine-button-filled:focus {
    background: var(--button-bg-hover) !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(30, 144, 255, 0.25);
}

.mantine-button-filled:disabled {
    background: rgba(30, 144, 255, 0.3) !important;
    cursor: not-allowed;
    transform: none;
    opacity: 0.6;
}

.mantine-button-filled:disabled:hover {
    transform: none;
    box-shadow: none;
}

.submit-btn {
    width: 100%;
    justify-content: center;
    font-size: 1.05rem;
    padding: 14px 20px;
}

.submit-btn::after {
    display: none;
}

.page-header {
    text-align: center;
    margin-bottom: 1.25rem;
}

.page-header h1 {
    margin: 0 0 0.6rem;
    font-size: 2rem;
    font-weight: 800;
    color: var(--button-bg) !important;
    background: none !important;
}

.page-header p {
    opacity: 0.9;
    max-width: 760px;
    margin: 0 auto 1rem;
    line-height: 1.5;
}

.avatar-container {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    border-radius: var(--border-radius);
    background: rgba(0, 0, 0, 0.2);
    margin-bottom: 1.25rem;
}

.avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 2px solid var(--primary-color);
    object-fit: cover;
}

.auth-status {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 50px;
    font-size: 0.9rem;
    font-weight: 500;
}

.auth-status.authenticated {
    background: rgba(16, 185, 129, 0.2);
    color: #10b981;
}

.auth-status.not-authenticated {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

form {
    margin-top: 0.5rem;
}

.form-section {
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: 14px;
    background: rgba(0, 0, 0, 0.1);
}

.form-section-title {
    font-size: 1.05rem;
    margin: 0 0 0.6rem;
    font-weight: 700;
}

.form-group {
    margin: 0 0 0.9rem;
}

.form-label {
    display: block;
    margin: 0 0 0.45rem;
    font-weight: 700;
}

.form-input {
    width: 100%;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: transparent;
    color: inherit;
    font-size: 1rem;
}

.form-input:focus {
    outline: none;
    border-color: var(--button-bg);
    box-shadow: 0 0 0 3px rgba(30, 144, 255, 0.25);
}

.choice-stack {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.choice-stack label {
    display: flex;
    align-items: center;
    gap: 0.55rem;
}

input[type="radio"] {
    accent-color: var(--button-bg);
    width: 18px;
    height: 18px;
    cursor: pointer;
}

input[type="checkbox"] {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border: 2px solid currentColor;
    color: rgba(255, 255, 255, 0.6);
    border-radius: 6px;
    display: inline-grid;
    place-content: center;
    background: transparent;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}

input[type="checkbox"]::after {
    content: "";
    width: 10px;
    height: 10px;
    transform: scale(0);
    transition: transform 0.12s;
    background: var(--button-bg);
    border-radius: 3px;
}

input[type="checkbox"]:checked {
    border-color: var(--button-bg);
    color: var(--button-bg);
}

input[type="checkbox"]:checked::after {
    transform: scale(1);
}

input[type="checkbox"]:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(30, 144, 255, 0.3);
}

/* Hide native select (kept for form submission & required attr) */
select.form-input.enhanced {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0 0 0 0) !important;
    border: 0 !important;
}

/* Custom dropdown (Selectify) */
.selectify {
    position: relative;
}

.selectify-toggle {
    width: 100%;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: transparent;
    color: inherit;
    padding: 12px 42px 12px 14px;
    border-radius: 10px;
    font-size: 1rem;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.selectify-toggle:focus {
    outline: none;
    border-color: var(--button-bg);
    box-shadow: 0 0 0 3px rgba(30, 144, 255, 0.25);
}

.selectify-toggle .placeholder {
    opacity: 0.7;
}

.selectify-caret {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    width: 18px;
    height: 18px;
    mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>")
        center/contain no-repeat;
    -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>")
        center/contain no-repeat;
    background: #bbb;
}

.selectify-list {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 6px);
    background: var(--surface-elev);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    max-height: 260px;
    overflow: auto;
    padding: 6px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
    z-index: 40;
    display: none;
}

.selectify.flip-up .selectify-list {
    top: auto;
    bottom: calc(100% + 6px);
}

.selectify.open .selectify-list {
    display: block;
}

.selectify-item {
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    user-select: none;
    line-height: 1.2;
    outline: none;
}

.selectify-item:hover,
.selectify-item[aria-selected="true"] {
    background: rgba(30, 144, 255, 0.18);
}

.selectify-item:focus {
    box-shadow: 0 0 0 3px rgba(30, 144, 255, 0.25);
}

.selectify-empty {
    padding: 10px 12px;
    opacity: 0.7;
}

.selectify-toggle:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.form-input:disabled,
select.form-input:disabled,
textarea.form-input:disabled,
input[type="radio"]:disabled,
input[type="checkbox"]:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.loading-spinner {
    display: none;
    margin-left: 10px;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s linear infinite;
}

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

.error-message {
    color: var(--error-color);
    font-size: 0.9rem;
    margin-top: 0.4rem;
    display: none;
}

@media (max-width: 768px) {
    .glass-card {
        padding: 1.25rem;
        margin-top: 1rem;
    }

    .page-header h1 {
        font-size: 1.5rem;
    }

    .page-header p {
        font-size: 0.95rem;
    }

    .avatar-container {
        flex-direction: column;
        text-align: center;
        align-items: center;
    }

    .avatar-container > div {
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    .avatar-container .mantine-button-filled {
        margin-left: 0 !important;
        margin-top: 0.75rem;
        width: 100%;
    }

    .top-links {
        left: 12px;
        top: 12px;
        gap: 6px;
        flex-wrap: wrap;
        max-width: calc(100% - 80px);
    }

    .top-links a {
        font-size: 0.85rem;
        padding: 8px 12px;
    }

    .theme-toggle {
        right: 12px;
        top: 12px;
        width: 44px;
        height: 44px;
        font-size: 1.1rem;
    }

    .mantine-Container-root {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
        margin: 1rem auto !important;
    }

    .form-section {
        padding: 0.85rem;
        margin-bottom: 0.85rem;
    }

    .form-section-title {
        font-size: 1rem;
    }

    .form-group {
        margin: 0 0 0.75rem;
    }

    .form-label {
        font-size: 0.95rem;
        margin: 0 0 0.4rem;
    }

    .form-input,
    .selectify-toggle {
        font-size: 0.95rem;
        padding: 11px 13px;
    }

    .selectify-toggle {
        padding-right: 40px;
    }

    .submit-btn {
        font-size: 1rem;
        padding: 13px 18px;
    }

    .selectify-list {
        max-height: 220px;
        font-size: 0.95rem;
    }

    .auth-status {
        font-size: 0.85rem;
    }

    .avatar-container > span:not(.auth-status) {
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .glass-card {
        padding: 1rem;
        border-radius: 12px;
    }

    .page-header h1 {
        font-size: 1.35rem;
    }

    .page-header p {
        font-size: 0.9rem;
        line-height: 1.4;
    }

    .top-links {
        position: static;
        margin-bottom: 0.75rem;
        padding: 0 1rem;
        justify-content: center;
    }

    .theme-toggle {
        top: 8px;
        right: 8px;
    }

    .mantine-Container-root {
        max-width: 100% !important;
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }

    .form-input,
    .selectify-toggle,
    textarea.form-input {
        font-size: 16px; /* Prevents iOS zoom on focus */
    }

    input[type="date"].form-input {
        font-size: 16px;
    }
}