:root {
    --color-primary: #4CAF50;
    --color-primary-dark: #43A047;
    --color-primary-light: rgba(76, 175, 80, 0.15);
    --color-primary-light-shadow: rgba(76, 175, 80, 0.35);
    --color-danger: #dc3545;
    --color-danger-dark: #c82333;

    --color-bg-primary: #ffffff;
    --color-bg-secondary: #f8f9fa;
    --color-bg-page: #4CAF50;
    --color-bg-info: #e8f8ff;

    --color-border-light: #e0e0e0;
    --color-border-focus: #4CAF50;
    --color-border-info: #8fd3ef;

    --color-text-primary: #333;
    --color-text-secondary: #999;
    --color-text-disabled: #ccc;
    --color-text-info: #245b6b;

    --color-shadow: rgba(0, 0, 0, 0.08);
    --color-shadow-lg: rgba(0, 0, 0, 0.12);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    margin: 0;
    min-height: 100vh;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    position: relative;
    isolation: isolate;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image: url('../img/registre.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    filter: blur(1px);
    z-index: -2;
}

body::after {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: -1;
}

/* ── Form ── */

.form-signin {
    width: 100%;
    max-width: 460px;
    padding: 40px 32px;
    margin: auto;
    background: var(--color-bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 30px var(--color-shadow-lg);
}

.form-signin h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--color-primary);
    margin-bottom: 28px;
    text-align: center;
    margin-top: 0;
    letter-spacing: -0.3px;
}

/* ── Floating Input ── */

.form-floating {
    position: relative;
    display: block;
    margin-bottom: 18px;
}

.form-floating > .form-control {
    height: 62px;
    font-size: 1rem;
    padding: 26px 14px 8px 14px;
    border: 2px solid var(--color-border-light);
    border-radius: var(--radius-md);
    transition: border-color 0.25s ease, box-shadow 0.25s ease;
    line-height: 1.4;
    width: 100%;
    background-color: var(--color-bg-primary);
    font-family: inherit;
    color: var(--color-text-primary);
    box-sizing: border-box;
    -webkit-appearance: none;
    appearance: none;
}

.form-floating > .form-control:focus {
    outline: none;
    border-color: var(--color-border-focus);
    box-shadow: 0 0 0 3px var(--color-primary-light);
}

.form-floating > .form-control::placeholder {
    color: transparent;
    transition: color 0.2s ease;
}

.form-floating > .form-control:focus::placeholder {
    color: var(--color-text-secondary);
    opacity: 0.5;
}

.form-floating > label {
    position: absolute;
    top: 50%;
    left: 14px;
    transform: translateY(-50%);
    pointer-events: none;
    font-size: 1rem;
    font-weight: 400;
    color: var(--color-text-secondary);
    transition: transform 0.2s ease, font-size 0.2s ease, color 0.2s ease, top 0.2s ease;
    line-height: 1;
}

.form-floating > .form-control:focus ~ label,
.form-floating > .form-control:not(:placeholder-shown) ~ label {
    top: 14px;
    transform: translateY(0);
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--color-primary);
}

.form-floating > .form-control:not(:focus):not(:placeholder-shown) ~ label {
    color: var(--color-text-secondary);
}

.required {
    color: #e74c3c;
    font-weight: 700;
    margin-left: 2px;
}

/* ── Toggle Password ── */

.toggle-password {
    position: absolute;
    top: 50%;
    right: 14px;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--color-text-secondary);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    transition: color 0.2s ease;
}

.toggle-password:hover {
    color: var(--color-primary);
}

/* ── Validation Error ── */

.form-floating > .form-control.is-invalid {
    border-color: #e74c3c;
    box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.15);
}

.form-floating > .form-control.is-invalid:focus {
    border-color: #e74c3c;
    box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.2);
}

.field-error {
    display: block;
    font-size: 0.75rem;
    color: #e74c3c;
    margin-top: 4px;
    font-weight: 500;
    padding-left: 2px;
    animation: fieldErrorIn 0.2s ease;
}

@keyframes fieldErrorIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ── Buttons ── */

.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 54px;
    font-size: 1.05rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background-color 0.25s ease, transform 0.2s ease, box-shadow 0.2s ease;
    text-decoration: none;
    text-align: center;
    font-family: inherit;
    box-sizing: border-box;
    letter-spacing: 0.3px;
    border: none;
}

.btn:not(:last-child) {
    margin-bottom: 16px;
}

.btn-success {
    background-color: var(--color-primary);
    color: var(--color-bg-primary);
    margin-top: 28px;
}

.btn-success:hover {
    background-color: #388E3C;
    transform: translateY(-1px);
    box-shadow: 0 4px 14px var(--color-primary-light-shadow);
}

.btn-success:active {
    transform: translateY(0);
}

.btn-microsoft {
    color: var(--color-primary);
    background-color: var(--color-bg-primary);
    border: 2px solid var(--color-primary);
}

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

.btn-danger-outline {
    color: var(--color-danger);
    background-color: var(--color-bg-primary);
    border: 2px solid var(--color-danger);
}

.btn-danger-outline:hover {
    background-color: var(--color-danger);
    color: var(--color-bg-primary);
}

/* ── Info Tooltip ── */

.info-tooltip-container {
    position: relative;
    display: block;
}

.info-tooltip {
    display: none;
    position: absolute;
    top: 50%;
    right: -210px;
    transform: translateY(-50%);
    background-color: var(--color-bg-info);
    border: 1px solid var(--color-border-info);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    width: 200px;
    font-size: 0.82rem;
    line-height: 1.45;
    color: var(--color-text-info);
    box-shadow: 0 4px 14px var(--color-shadow);
    z-index: 10;
    text-align: left;
}

.info-tooltip::before {
    content: '';
    position: absolute;
    left: -8px;
    top: 50%;
    transform: translateY(-50%);
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
    border-right: 8px solid var(--color-border-info);
}

.info-tooltip::after {
    content: '';
    position: absolute;
    left: -6px;
    top: 50%;
    transform: translateY(-50%);
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    border-right: 6px solid var(--color-bg-info);
}

.info-tooltip-container:hover .info-tooltip {
    display: block;
}

/* ── Alerts ── */

.alert {
    margin-bottom: 20px;
    border-radius: var(--radius-md);
    font-size: 0.88rem;
    padding: 14px 16px;
    border: 1px solid;
    line-height: 1.5;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.alert::before {
    content: '';
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    margin-top: 1px;
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
}

.alert-primary {
    background-color: #e7f3ff;
    border-color: #b3d9ff;
    border-left: 4px solid #2196F3;
    color: #004085;
}

.alert-primary::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%232196F3' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cline x1='12' y1='16' x2='12' y2='12'/%3E%3Cline x1='12' y1='8' x2='12.01' y2='8'/%3E%3C/svg%3E");
}

.alert-danger {
    background-color: #fdecea;
    border-color: #f5c6cb;
    border-left: 4px solid #e74c3c;
    color: #721c24;
}

.alert-danger::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23e74c3c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cline x1='15' y1='9' x2='9' y2='15'/%3E%3Cline x1='9' y1='9' x2='15' y2='15'/%3E%3C/svg%3E");
}

.alert-success {
    background-color: #eafaf1;
    border-color: #a9dfbf;
    border-left: 4px solid #4CAF50;
    color: #1e7e34;
}

.alert-success::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%234CAF50' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M22 11.08V12a10 10 0 1 1-5.93-9.14'/%3E%3Cpolyline points='22 4 12 14.01 9 11.01'/%3E%3C/svg%3E");
}

.alert-dismissible {
    position: relative;
    padding-right: 40px;
}

.btn-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    color: var(--color-text-secondary);
    line-height: 1;
    padding: 0;
}

.btn-close:hover {
    color: var(--color-text-primary);
}

/* ── Logo ── */

.logo-container {
    text-align: center;
    margin-bottom: 28px;
}

.logo-container img {
    max-width: 180px;
    height: auto;
}

/* ── Helpers ── */

.mt-2 {
    margin-top: 16px;
}

.mb-4 {
    margin-bottom: 20px;
}

/* ── Responsive ── */

@media (max-width: 480px) {
    body {
        padding: 16px 12px;
        align-items: center;
    }

    .form-signin {
        padding: 32px 20px;
        border-radius: var(--radius-md);
        max-width: 100%;
    }

    .form-signin h1 {
        font-size: 1.4rem;
        margin-bottom: 22px;
    }

    .form-floating > .form-control {
        height: 56px;
        padding: 22px 12px 6px 12px;
        font-size: 0.95rem;
    }

    .form-floating > label {
        left: 12px;
        font-size: 0.95rem;
    }

    .form-floating > .form-control:focus ~ label,
    .form-floating > .form-control:not(:placeholder-shown) ~ label {
        top: 10px;
        font-size: 0.65rem;
    }

    .btn {
        height: 48px;
        font-size: 0.95rem;
    }

    .btn-success {
        margin-top: 24px;
    }

    .info-tooltip {
        display: none !important;
    }
}

@media (min-width: 481px) and (max-width: 600px) {
    body {
        padding: 32px 20px;
        align-items: center;
    }

    .form-signin {
        padding: 36px 28px;
    }
}

@media (min-width: 601px) {
    body {
        align-items: center;
    }
}
