/* 
 * Auth Glassmorphism Design System (Pure CSS - Gold Theme)
 * Application: HSE Work Permit System
 */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    color: #f8fafc;
    padding: 32px 16px;
    overflow-y: auto;
    line-height: 1.5;
}

/* Page Background Overlay to ensure contrast under the safety picture */
body::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.55); /* darken the background picture */
    z-index: -1;
}

/* Card Container */
.auth-container {
    width: 100%;
    max-width: 460px;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(212, 175, 55, 0.3);
    border-radius: 20px;
    box-shadow: 0 16px 48px 0 rgba(0, 0, 0, 0.5), 0 0 30px rgba(212, 175, 55, 0.15);
    overflow: hidden;
    z-index: 1;
}

.auth-container.wide {
    max-width: 640px;
}

/* Header */
.auth-header {
    padding: 24px 32px;
    background: linear-gradient(135deg, #0b1329 0%, #1e293b 100%);
    border-bottom: 1px solid rgba(212, 175, 55, 0.3);
    display: flex;
    align-items: center;
    gap: 16px;
}

.auth-header img {
    height: 42px;
    width: auto;
    background: #ffffff;
    border-radius: 8px;
    padding: 4px;
    object-fit: contain;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.auth-header-title {
    flex-grow: 1;
}

.auth-header-title h2 {
    font-size: 20px;
    font-weight: 700;
    color: #ffffff;
    line-height: 1.2;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.auth-header-title p {
    font-size: 12px;
    color: #fef08a;
    opacity: 0.95;
    margin-top: 2px;
}

.auth-badge {
    font-family: monospace;
    font-size: 10px;
    background: rgba(202, 138, 4, 0.35);
    border: 1px solid rgba(250, 204, 21, 0.4);
    color: #fef08a;
    padding: 4px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

/* Form Panel */
.auth-form {
    padding: 32px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.auth-subtitle {
    margin-bottom: 8px;
}

.auth-subtitle h3 {
    font-size: 22px;
    font-weight: 700;
    color: #ffffff;
}

.auth-subtitle p {
    font-size: 14px;
    color: #cbd5e1;
    margin-top: 4px;
}

/* Grid Layout */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

@media (max-width: 600px) {
    .grid-2 {
        grid-template-columns: 1fr;
        gap: 20px;
    }
}

/* Form Elements */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 14px;
    font-weight: 600;
    color: #e2e8f0;
}

.form-group label span.required {
    color: #f87171;
    margin-left: 2px;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.form-input,
.auth-form input[type="text"],
.auth-form input[type="email"],
.auth-form input[type="password"],
.auth-form input[type="number"],
.auth-form select,
.auth-form textarea {
    width: 100%;
    padding: 12px 16px;
    background-color: #374151 !important; /* bg-grey */
    background: #374151 !important;
    border: 1px solid #4b5563 !important;
    border-radius: 8px;
    color: #ffffff !important; /* text white */
    font-size: 14px;
    font-family: inherit;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.form-input::placeholder,
.auth-form input::placeholder,
.auth-form textarea::placeholder {
    color: #9ca3af !important;
    opacity: 1;
}

.form-input:focus,
.auth-form input[type="text"]:focus,
.auth-form input[type="email"]:focus,
.auth-form input[type="password"]:focus,
.auth-form input[type="number"]:focus,
.auth-form select:focus,
.auth-form textarea:focus {
    outline: none !important;
    border-color: #facc15 !important;
    background-color: #4b5563 !important;
    background: #4b5563 !important;
    color: #ffffff !important;
    box-shadow: 0 0 0 3px rgba(234, 179, 8, 0.35) !important;
}

/* Autofill Overrides to keep bg grey and text white */
.form-input:-webkit-autofill,
.form-input:-webkit-autofill:hover,
.form-input:-webkit-autofill:focus,
.form-input:-webkit-autofill:active,
.auth-form input:-webkit-autofill,
.auth-form input:-webkit-autofill:hover,
.auth-form input:-webkit-autofill:focus,
.auth-form input:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 100px #374151 inset !important;
    -webkit-text-fill-color: #ffffff !important;
    caret-color: #ffffff !important;
    transition: background-color 5000s ease-in-out 0s;
}

/* Error States */
.form-input.has-error,
.auth-form input.has-error {
    border-color: #f87171 !important;
    box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.3) !important;
}

.error-text {
    font-size: 12px;
    color: #f87171;
    font-weight: 500;
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Section Header (In Register Form) */
.section-divider {
    border-bottom: 1px solid rgba(212, 175, 55, 0.2);
    padding-bottom: 6px;
    margin-top: 8px;
    margin-bottom: 4px;
}

.section-title {
    font-size: 14px;
    font-weight: 700;
    color: #facc15;
    display: flex;
    align-items: center;
    gap: 8px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.section-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    background: rgba(250, 204, 21, 0.15);
    border: 1px solid rgba(250, 204, 21, 0.4);
    border-radius: 50%;
    font-size: 11px;
    color: #facc15;
}

/* Password Visibility Toggle */
.password-toggle-btn {
    position: absolute;
    right: 12px;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

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

/* Password Match Indicator */
.password-status {
    font-size: 12px;
    font-weight: 600;
    margin-top: 4px;
    display: none;
    align-items: center;
    gap: 6px;
}

.password-status.match {
    color: #4ade80;
    display: flex;
}

.password-status.mismatch {
    color: #f87171;
    display: flex;
}

/* Remember Me & Actions Flex Row */
.flex-row-justify {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

@media (max-width: 400px) {
    .flex-row-justify {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
}

/* Custom Checkbox Group */
.checkbox-group {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}

.checkbox-group input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    outline: none;
    background: rgba(255, 255, 255, 0.05);
    cursor: pointer;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
    margin-top: 2px;
}

.checkbox-group input[type="checkbox"]:checked {
    background: #ca8a04;
    border-color: #eab308;
}

.checkbox-group input[type="checkbox"]:checked::before {
    content: "✓";
    color: #ffffff;
    font-size: 11px;
    font-weight: bold;
}

.checkbox-group input[type="checkbox"]:focus {
    box-shadow: 0 0 0 3px rgba(234, 179, 8, 0.35);
}

.checkbox-group input[type="checkbox"]:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.checkbox-label {
    font-size: 14px;
    color: #cbd5e1;
    line-height: 1.4;
    cursor: pointer;
}

/* Agreement Badge / Status Info */
.agreement-status-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.agreement-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12.5px;
    font-weight: 600;
    width: fit-content;
}

.agreement-badge.error {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}

.agreement-badge.success {
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #a7f3d0;
}

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    padding: 16px;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* Modal Content Box */
.modal-content {
    background: rgba(30, 41, 59, 0.95);
    border: 1px solid rgba(212, 175, 55, 0.3);
    border-radius: 16px;
    width: 100%;
    max-width: 580px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 10px 10px -5px rgba(0, 0, 0, 0.5), 0 0 20px rgba(212, 175, 55, 0.15);
    display: flex;
    flex-direction: column;
    max-height: 90vh;
    animation: modalSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalSlideUp {
    from {
        transform: translateY(20px);
    }
    to {
        transform: translateY(0);
    }
}

.modal-header {
    padding: 16px 24px;
    border-bottom: 1px solid rgba(212, 175, 55, 0.2);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    font-size: 16px;
    font-weight: 700;
    color: #facc15;
    margin: 0;
}

.modal-close-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    font-size: 24px;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.modal-close-btn:hover {
    color: #ffffff;
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid rgba(212, 175, 55, 0.2);
    display: flex;
    justify-content: flex-end;
    background: rgba(15, 23, 42, 0.25);
}

/* Agreement Policy Box */
.policy-box {
    max-height: 250px;
    overflow-y: auto;
    padding: 16px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    font-size: 12px;
    line-height: 1.6;
    color: #cbd5e1;
}

.policy-box h4 {
    margin-top: 0;
    margin-bottom: 8px;
    font-size: 13px;
    color: #facc15;
    font-weight: 700;
    text-transform: uppercase;
}

.policy-box h5 {
    margin-top: 14px;
    margin-bottom: 6px;
    font-size: 12.5px;
    color: #f1f5f9;
    font-weight: 600;
}

.policy-box ol, .policy-box ul {
    margin: 0;
    padding-left: 20px;
}

.policy-box li {
    margin-bottom: 6px;
    text-align: justify;
}

.policy-box::-webkit-scrollbar {
    width: 6px;
}

.policy-box::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
}

.policy-box::-webkit-scrollbar-thumb {
    background: rgba(212, 175, 55, 0.3);
    border-radius: 4px;
}

.policy-box::-webkit-scrollbar-thumb:hover {
    background: rgba(212, 175, 55, 0.5);
}

/* Actions block */
.auth-actions {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 20px;
}

/* Button styling */
.auth-btn {
    width: 100%;
    padding: 12px 24px;
    background: linear-gradient(135deg, #d4af37 0%, #ca8a04 50%, #a16207 100%);
    color: #ffffff;
    border: 1px solid rgba(254, 240, 138, 0.3);
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.auth-btn:hover {
    background: linear-gradient(135deg, #facc15 0%, #d97706 50%, #b45309 100%);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(212, 175, 55, 0.4);
}

.auth-btn:active {
    transform: translateY(0);
    box-shadow: none;
}

.auth-btn:disabled {
    background: rgba(255, 255, 255, 0.15) !important;
    color: rgba(255, 255, 255, 0.35) !important;
    border-color: transparent !important;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.auth-btn.secondary {
    background: rgba(212, 175, 55, 0.1);
    border: 1px solid rgba(212, 175, 55, 0.3);
    color: #fef08a;
    text-shadow: none;
}

.auth-btn.secondary:hover {
    background: rgba(212, 175, 55, 0.2);
    border-color: rgba(250, 204, 21, 0.5);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(212, 175, 55, 0.15);
}

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid #ffffff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: inline-block;
}

/* Hidden utility class to hide spinner & elements by default */
.hidden {
    display: none !important;
}

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

/* Alerts and Helper text */
.alert-error {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 13.5px;
    color: #fca5a5;
    margin-bottom: 20px;
}

.alert-success {
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 13.5px;
    color: #a7f3d0;
    margin-bottom: 20px;
}

.help-text {
    font-size: 12px;
    color: #cbd5e1;
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.help-text.warning {
    color: #fdba74;
}

.text-center {
    text-align: center;
}

.link-primary {
    color: #facc15;
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s;
}

.link-primary:hover {
    color: #fde047;
    text-decoration: underline;
}

/* Utility spacers */
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.space-y-4 > * + * { margin-top: 16px; }

/* Responsive adjustments */
@media (max-width: 480px) {
    body {
        padding: 16px 8px;
    }
    .auth-container {
        border-radius: 12px;
    }
    .auth-header {
        padding: 16px 20px;
    }
    .auth-form {
        padding: 20px;
    }
}
