/**
 * Auth Modal & Header Auth Styles with Password Support
 */

/* Header Trigger Button & User Pill */
.auth-header-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, #2e7d32 0%, #1b5e20 100%);
    color: #ffffff !important;
    font-size: 14px;
    font-weight: 600;
    padding: 8px 18px;
    border-radius: 50px;
    border: none;
    cursor: pointer;
    text-decoration: none !important;
    transition: all 0.25s ease;
    box-shadow: 0 3px 10px rgba(46, 125, 50, 0.25);
}

.auth-header-btn:hover {
    background: linear-gradient(135deg, #388e3c 0%, #2e7d32 100%);
    transform: translateY(-1px);
    box-shadow: 0 5px 14px rgba(46, 125, 50, 0.35);
    color: #ffffff !important;
}

.auth-header-btn svg {
    flex-shrink: 0;
}

/* User pill when logged in */
.auth-user-pill {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: #f4fbf6;
    border: 1px solid #c8e6c9;
    padding: 5px 14px 5px 8px;
    border-radius: 50px;
    font-size: 13px;
    color: #2e7d32;
    font-weight: 600;
}

.auth-user-pill .user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid #81c784;
}

.auth-user-pill .dashboard-link {
    color: #1b5e20;
    text-decoration: none;
    font-weight: 700;
    background: #e8f5e9;
    padding: 3px 10px;
    border-radius: 20px;
    transition: all 0.2s;
}

.auth-user-pill .dashboard-link:hover {
    background: #c8e6c9;
    color: #003300;
}

.auth-user-pill .auth-logout-link {
    color: #d32f2f;
    text-decoration: none;
    font-size: 12px;
    font-weight: 500;
    margin-right: 4px;
    padding-right: 8px;
    border-right: 1px solid #c8e6c9;
    transition: color 0.2s;
}

.auth-user-pill .auth-logout-link:hover {
    color: #b71c1c;
    text-decoration: underline;
}

/* Modal Overlay & Container */
.auth-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.3s;
    direction: rtl;
    font-family: inherit;
}

.auth-modal.is-open {
    opacity: 1;
    visibility: visible;
}

.auth-modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.auth-modal-dialog {
    position: relative;
    width: 100%;
    max-width: 460px;
    background: #ffffff;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2), 0 1px 3px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    transform: scale(0.95) translateY(10px);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 2;
}

.auth-modal.is-open .auth-modal-dialog {
    transform: scale(1) translateY(0);
}

/* Close Button */
.auth-modal-close {
    position: absolute;
    top: 16px;
    left: 16px;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #f1f5f9;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #64748b;
    transition: all 0.2s;
    z-index: 10;
}

.auth-modal-close:hover {
    background: #e2e8f0;
    color: #0f172a;
    transform: rotate(90deg);
}

/* Header & Tabs */
.auth-modal-header {
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    padding: 16px 20px 0;
}

.auth-modal-tabs {
    display: flex;
    gap: 8px;
}

.auth-tab-btn {
    flex: 1;
    background: none;
    border: none;
    padding: 12px 16px;
    font-size: 15px;
    font-weight: 600;
    color: #64748b;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
}

.auth-tab-btn:hover {
    color: #2e7d32;
}

.auth-tab-btn.active {
    color: #2e7d32;
    border-bottom-color: #2e7d32;
}

/* Body & Intro */
.auth-modal-body {
    padding: 24px 28px 28px;
    max-height: 85vh;
    overflow-y: auto;
}

.auth-intro {
    text-align: center;
    margin-bottom: 20px;
}

.auth-intro h3 {
    font-size: 20px;
    font-weight: 700;
    color: #1e293b;
    margin: 0 0 6px;
}

.auth-intro p {
    font-size: 13.5px;
    color: #64748b;
    margin: 0;
    line-height: 1.4;
}

/* Panels */
.auth-panel {
    display: none;
}

.auth-panel.active {
    display: block;
    animation: authFadeIn 0.3s ease;
}

@keyframes authFadeIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Form & Inputs */
.auth-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.auth-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.auth-field label {
    font-size: 13px;
    font-weight: 600;
    color: #334155;
}

.auth-field .required {
    color: #ef4444;
}

.input-with-icon {
    position: relative;
    display: flex;
    align-items: center;
}

.input-with-icon .field-icon {
    position: absolute;
    right: 14px;
    color: #94a3b8;
    pointer-events: none;
    transition: color 0.2s;
}

.input-with-icon input {
    width: 100%;
    padding: 10px 42px 10px 14px;
    font-size: 14px;
    background: #f8fafc;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    color: #1e293b;
    outline: none;
    transition: all 0.2s;
    box-sizing: border-box;
}

.password-field-wrapper input {
    padding-left: 40px;
}

.toggle-password-btn {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.toggle-password-btn:hover {
    color: #2e7d32;
}

.input-with-icon input:focus {
    background: #ffffff;
    border-color: #2e7d32;
    box-shadow: 0 0 0 3px rgba(46, 125, 50, 0.12);
}

.input-with-icon input:focus + .field-icon,
.input-with-icon:focus-within .field-icon {
    color: #2e7d32;
}

/* Checkbox */
.auth-checkbox-field {
    margin-top: 2px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12.5px;
    color: #475569;
    cursor: pointer;
    user-select: none;
}

.checkbox-label input[type="checkbox"] {
    display: none;
}

.custom-checkbox {
    width: 18px;
    height: 18px;
    border: 2px solid #cbd5e1;
    border-radius: 5px;
    background: #ffffff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
}

.checkbox-label input[type="checkbox"]:checked + .custom-checkbox {
    background: #2e7d32;
    border-color: #2e7d32;
}

.checkbox-label input[type="checkbox"]:checked + .custom-checkbox::after {
    content: "";
    width: 4px;
    height: 8px;
    border: solid #ffffff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg) translate(-1px, -1px);
}

.checkbox-label a {
    color: #2e7d32;
    text-decoration: underline;
}

/* Alerts */
.auth-alert {
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.4;
    text-align: right;
}

.auth-alert.auth-alert-error {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.auth-alert.auth-alert-success {
    background: #f0fdf4;
    color: #15803d;
    border: 1px solid #bbf7d0;
}

/* Submit Button */
.auth-submit-btn {
    width: 100%;
    padding: 13px;
    background: linear-gradient(135deg, #2e7d32 0%, #1b5e20 100%);
    color: #ffffff;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.25s;
    box-shadow: 0 4px 12px rgba(46, 125, 50, 0.25);
    margin-top: 4px;
}

.auth-submit-btn:hover {
    background: linear-gradient(135deg, #388e3c 0%, #2e7d32 100%);
    box-shadow: 0 6px 16px rgba(46, 125, 50, 0.35);
    transform: translateY(-1px);
}

.auth-submit-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

/* Spinner */
.spinner-icon {
    animation: rotateSpinner 1.5s linear infinite;
    width: 20px;
    height: 20px;
}

.spinner-icon .path {
    stroke: #ffffff;
    stroke-linecap: round;
    animation: dashSpinner 1.5s ease-in-out infinite;
}

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

@keyframes dashSpinner {
    0% {
        stroke-dasharray: 1, 150;
        stroke-dashoffset: 0;
    }
    50% {
        stroke-dasharray: 90, 150;
        stroke-dashoffset: -35;
    }
    100% {
        stroke-dasharray: 90, 150;
        stroke-dashoffset: -124;
    }
}

/* Responsive */
@media (max-width: 480px) {
    .auth-modal {
        padding: 12px;
    }
    .auth-modal-dialog {
        border-radius: 16px;
    }
    .auth-modal-body {
        padding: 20px 18px 24px;
    }
}
