/**
 * TBS Custom Auth — Frontend Styles
 * Modern, industry-standard auth forms
 *
 * @package TBS_Custom_Auth
 */

/* ---------------------------------------------------------------
 * Google Font Import
 * ------------------------------------------------------------- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Poppins:wght@400;500;600;700&family=Roboto:wght@400;500;700&display=swap');

/* ---------------------------------------------------------------
 * Design Tokens
 * ------------------------------------------------------------- */
:root {
    --tbs-primary:          #baf734;
    --tbs-primary-hover:    #a8e020;
    --tbs-primary-light:    #f4ffe0;
    --tbs-primary-shadow:   rgba(186, 247, 52, 0.30);
    --tbs-brand-dark:       #070f45;

    --tbs-success:          #10B981;
    --tbs-success-bg:       #ECFDF5;
    --tbs-success-border:   rgba(16, 185, 129, 0.2);
    --tbs-success-text:     #065F46;

    --tbs-error:            #EF4444;
    --tbs-error-bg:         #FEF2F2;
    --tbs-error-border:     rgba(239, 68, 68, 0.2);
    --tbs-error-text:       #991B1B;

    --tbs-warning-bg:       #FFFBEB;
    --tbs-warning-text:     #92400E;
    --tbs-warning-border:   rgba(245, 158, 11, 0.2);

    --tbs-info-bg:          #EFF6FF;
    --tbs-info-text:        #1E40AF;
    --tbs-info-border:      rgba(59, 130, 246, 0.2);

    --tbs-text:             #070f45;
    --tbs-text-secondary:   #1a2460;
    --tbs-text-muted:       #6B7280;
    --tbs-text-placeholder: #9CA3AF;

    --tbs-border:           #E5E7EB;
    --tbs-border-focus:     #baf734;

    --tbs-bg:               #FFFFFF;
    --tbs-bg-light:         #F9FAFB;
    --tbs-bg-muted:         #F3F4F6;
    --tbs-button-bg:        #070f45;
    --tbs-form-width:       440px;

    --tbs-radius-card:      12px;
    --tbs-radius-input:     8px;
    --tbs-radius-btn:       8px;
    --tbs-radius-badge:     6px;

    --tbs-shadow:           0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -1px rgba(0,0,0,0.04);
    --tbs-shadow-lg:        0 10px 25px -3px rgba(7,15,69,0.15), 0 4px 10px -2px rgba(7,15,69,0.08);

    --tbs-transition:       all 0.2s ease;

    --tbs-font:             'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

    --tbs-input-height:     42px;
    --tbs-btn-height:       44px;
}

/* ---------------------------------------------------------------
 * Box-sizing reset
 * ------------------------------------------------------------- */
.tbs-auth-form *,
.tbs-auth-form *::before,
.tbs-auth-form *::after,
.tbs-verification-notice *,
.tbs-verification-notice *::before,
.tbs-verification-notice *::after {
    box-sizing: border-box;
}

/* ---------------------------------------------------------------
 * Card Container
 * ------------------------------------------------------------- */
.tbs-auth-form {
    max-width: var(--tbs-form-width);
    margin: 24px auto;
    padding: 28px 32px 24px;
    background: var(--tbs-bg);
    border-radius: var(--tbs-radius-card);
    box-shadow: var(--tbs-shadow-lg);
    font-family: var(--tbs-font);
    color: var(--tbs-text);
    border: 1px solid var(--tbs-border);
}

.tbs-form-logo {
    margin: 0 0 18px;
    text-align: center;
}

.tbs-form-logo img {
    display: inline-block;
    max-width: min(180px, 70%);
    max-height: 88px;
    width: auto;
    height: auto;
    object-fit: contain;
}

.tbs-template-minimal {
    padding: 22px 0 18px;
    background: transparent;
    border-color: transparent;
    box-shadow: none;
}

.tbs-template-minimal .tbs-form-field input[type="text"],
.tbs-template-minimal .tbs-form-field input[type="email"],
.tbs-template-minimal .tbs-form-field input[type="tel"],
.tbs-template-minimal .tbs-form-field input[type="password"] {
    background: transparent;
    border-left: 0;
    border-right: 0;
    border-top: 0;
    border-radius: 0;
    padding-left: 0;
    padding-right: 0;
}

.tbs-template-glass {
    background: rgba(255,255,255,0.78);
    background: color-mix(in srgb, var(--tbs-bg) 72%, transparent);
    border-color: rgba(255,255,255,0.42);
    box-shadow: 0 24px 70px rgba(7,15,69,0.20);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
}

.tbs-template-modern {
    border: 1px solid var(--tbs-border);
    border-color: color-mix(in srgb, var(--tbs-primary) 26%, var(--tbs-border));
    box-shadow: 0 18px 50px rgba(7,15,69,0.14);
}

.tbs-template-modern .tbs-form-header {
    border-bottom: 1px solid var(--tbs-border);
    padding-bottom: 14px;
}

.tbs-auth-form.tbs-popup-mode {
    max-width: 400px;
    padding: 32px;
    margin: 24px auto;
}

/* ---------------------------------------------------------------
 * Form Header
 * ------------------------------------------------------------- */
.tbs-form-header {
    margin-bottom: 16px;
    text-align: left;
}

.tbs-form-header h2 {
    margin: 0 0 4px;
    font-size: 22px;
    font-weight: 700;
    color: var(--tbs-text);
    letter-spacing: -0.025em;
    line-height: 1.2;
}

.tbs-form-header p {
    margin: 0;
    font-size: 13px;
    color: var(--tbs-text-muted);
    line-height: 1.5;
}

.tbs-form-header a {
    color: var(--tbs-brand-dark);
    text-decoration: none;
    font-weight: 600;
}

.tbs-form-header a:hover {
    text-decoration: underline;
}

/* ---------------------------------------------------------------
 * Google Button
 * ------------------------------------------------------------- */
.tbs-google-section {
    margin-bottom: 12px;
}

.tbs-google-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    height: var(--tbs-btn-height);
    padding: 0 20px;
    background: var(--tbs-bg);
    color: var(--tbs-text-secondary);
    font-family: var(--tbs-font);
    font-size: 15px;
    font-weight: 500;
    border: 1.5px solid var(--tbs-border);
    border-radius: var(--tbs-radius-btn);
    cursor: pointer;
    transition: var(--tbs-transition);
    box-shadow: var(--tbs-shadow);
}

.tbs-google-btn:hover {
    background: var(--tbs-bg-light);
    border-color: #D1D5DB;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.tbs-google-btn:disabled,
.tbs-google-btn.tbs-loading {
    opacity: 0.7;
    cursor: not-allowed;
}

.tbs-google-icon {
    flex-shrink: 0;
}

/* ---------------------------------------------------------------
 * OR Divider
 * ------------------------------------------------------------- */
.tbs-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 12px 0;
    color: var(--tbs-text-muted);
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.05em;
}

.tbs-divider::before,
.tbs-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--tbs-border);
}

/* ---------------------------------------------------------------
 * Form Fields
 * ------------------------------------------------------------- */
.tbs-form-field {
    margin-bottom: 12px;
}

.tbs-form-field label {
    display: block;
    margin-bottom: 4px;
    font-size: 12px;
    font-weight: 600;
    color: var(--tbs-text-secondary);
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.tbs-form-field label .required {
    color: var(--tbs-error);
    margin-left: 2px;
}

.tbs-form-field input[type="text"],
.tbs-form-field input[type="email"],
.tbs-form-field input[type="tel"],
.tbs-form-field input[type="password"] {
    width: 100%;
    height: var(--tbs-input-height);
    padding: 0 16px;
    font-family: var(--tbs-font);
    font-size: 15px;
    color: var(--tbs-text);
    background: var(--tbs-bg);
    border: 1.5px solid var(--tbs-border);
    border-radius: var(--tbs-radius-input);
    transition: var(--tbs-transition);
    appearance: none;
    -webkit-appearance: none;
}

.tbs-form-field input::placeholder {
    color: var(--tbs-text-placeholder);
}

.tbs-form-field input:focus {
    outline: none;
    border-color: #baf734;
    box-shadow: 0 0 0 3px rgba(186,247,52,0.25);
}

.tbs-form-field input.tbs-error {
    border-color: var(--tbs-error);
    background: var(--tbs-error-bg);
}

.tbs-form-field input.tbs-error:focus {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

/* ---------------------------------------------------------------
 * Field Error Text
 * ------------------------------------------------------------- */
.tbs-field-error {
    display: block;
    margin-top: 3px;
    font-size: 11px;
    font-weight: 500;
    color: var(--tbs-error);
    min-height: 0;
}

/* ---------------------------------------------------------------
 * Password wrapper + toggle
 * ------------------------------------------------------------- */
.tbs-password-wrapper {
    position: relative;
}

.tbs-password-wrapper input {
    padding-right: 48px !important;
}

.tbs-toggle-password {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    background: none !important;
    background-color: transparent !important;
    border: none !important;
    box-shadow: none !important;
    cursor: pointer;
    padding: 4px;
    color: var(--tbs-text-muted);
    transition: color 0.15s ease;
    display: flex;
    align-items: center;
}

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

.tbs-eye-icon {
    display: inline-block;
    width: 20px;
    height: 20px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239CA3AF' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z'%3E%3C/path%3E%3Ccircle cx='12' cy='12' r='3'%3E%3C/circle%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

.tbs-eye-icon.tbs-visible {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234F46E5' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24'%3E%3C/path%3E%3Cline x1='1' y1='1' x2='23' y2='23'%3E%3C/line%3E%3C/svg%3E");
}

/* ---------------------------------------------------------------
 * Password Strength Meter
 * ------------------------------------------------------------- */
.tbs-password-strength {
    margin-top: 8px;
    display: none;
}

.tbs-password-strength.visible {
    display: block;
}

.tbs-strength-bar {
    height: 4px;
    background: var(--tbs-bg-muted);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 4px;
}

.tbs-strength-bar-fill {
    height: 100%;
    width: 0;
    border-radius: 2px;
    transition: width 0.3s ease, background-color 0.3s ease;
}

.tbs-strength-bar-fill.weak   { background: var(--tbs-error);   }
.tbs-strength-bar-fill.medium { background: #F59E0B; }
.tbs-strength-bar-fill.strong { background: var(--tbs-success); }

.tbs-strength-label {
    font-size: 12px;
    font-weight: 600;
}

.tbs-strength-label.weak   { color: var(--tbs-error);   }
.tbs-strength-label.medium { color: #D97706; }
.tbs-strength-label.strong { color: var(--tbs-success); }

/* ---------------------------------------------------------------
 * Remember me / Forgot password row
 * ------------------------------------------------------------- */
.tbs-remember-forgot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.tbs-checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 400;
    color: var(--tbs-text-muted);
}

.tbs-checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin: 0;
    cursor: pointer;
    accent-color: var(--tbs-primary);
}

.tbs-forgot-link {
    font-size: 13px;
    color: var(--tbs-brand-dark);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.15s ease;
}

.tbs-forgot-link:hover {
    color: var(--tbs-primary-hover);
    text-decoration: underline;
}

/* ---------------------------------------------------------------
 * Submit Button
 * ------------------------------------------------------------- */
.tbs-form-submit {
    margin-top: 4px;
}

.tbs-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: var(--tbs-btn-height);
    padding: 0 24px;
    font-family: var(--tbs-font);
    font-size: 15px;
    font-weight: 600;
    border: none;
    border-radius: var(--tbs-radius-btn);
    cursor: pointer;
    transition: var(--tbs-transition);
    text-decoration: none;
    letter-spacing: 0.01em;
}

/* Primary (Navy + Lime) — !important to override Eduma theme button styles */
.tbs-button-primary {
    background: var(--tbs-button-bg) !important;
    color: var(--tbs-primary) !important;
    box-shadow: 0 4px 12px rgba(7,15,69,0.25) !important;
}

.tbs-button-primary:hover {
    background: var(--tbs-brand-dark) !important;
    color: var(--tbs-primary) !important;
    box-shadow: 0 6px 16px rgba(7,15,69,0.35) !important;
    transform: translateY(-1px);
}

.tbs-button-primary:active {
    transform: translateY(0);
}

.tbs-button-primary:disabled {
    background: #9CA3AF !important;
    color: #fff !important;
    box-shadow: none !important;
    cursor: not-allowed;
    transform: none;
}

.tbs-popup-trigger {
    width: auto;
}

.screen-reader-text {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Secondary */
.tbs-button-secondary {
    background: var(--tbs-bg);
    color: var(--tbs-text-secondary);
    border: 1.5px solid var(--tbs-border);
    box-shadow: var(--tbs-shadow);
}

.tbs-button-secondary:hover {
    background: var(--tbs-bg-light);
    border-color: #D1D5DB;
}

/* Logout link as button */
.tbs-logout-link {
    display: inline-flex;
    width: auto;
    height: auto;
    padding: 10px 20px;
    font-size: 14px;
}

/* ---------------------------------------------------------------
 * Button Loading State
 * ------------------------------------------------------------- */
.tbs-button-loading {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.tbs-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2.5px solid rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    border-top-color: #FFFFFF;
    animation: tbs-spin 0.65s linear infinite;
    flex-shrink: 0;
}

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

/* ---------------------------------------------------------------
 * Messages
 * ------------------------------------------------------------- */
.tbs-message-container {
    margin-bottom: 20px;
}

.tbs-message-container:empty {
    display: none;
}

.tbs-message {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.55;
    margin-bottom: 16px;
    border: 1px solid transparent;
    animation: tbs-fadeIn 0.3s ease;
}

.tbs-message:empty { display: none; }

.tbs-message-success {
    background: var(--tbs-success-bg);
    color: var(--tbs-success-text);
    border-color: var(--tbs-success-border);
}

.tbs-message-error {
    background: var(--tbs-error-bg);
    color: var(--tbs-error-text);
    border-color: var(--tbs-error-border);
}

.tbs-message-warning {
    background: var(--tbs-warning-bg);
    color: var(--tbs-warning-text);
    border-color: var(--tbs-warning-border);
}

.tbs-message-info {
    background: var(--tbs-info-bg);
    color: var(--tbs-info-text);
    border-color: var(--tbs-info-border);
}

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

/* ---------------------------------------------------------------
 * Form Footer
 * ------------------------------------------------------------- */
.tbs-form-footer {
    margin-top: 16px;
    text-align: center;
    padding-top: 14px;
    border-top: 1px solid var(--tbs-border);
}

.tbs-form-footer p {
    margin: 0;
    font-size: 13px;
    color: var(--tbs-text-muted);
}

.tbs-form-footer a {
    color: var(--tbs-brand-dark);
    font-weight: 600;
    text-decoration: none;
    margin-left: 3px;
}

.tbs-form-footer a:hover {
    text-decoration: underline;
}

/* ---------------------------------------------------------------
 * Resend verification section (inside login form)
 * ------------------------------------------------------------- */
.tbs-resend-section {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--tbs-border);
    text-align: center;
}

.tbs-resend-section p {
    margin: 0 0 8px;
    font-size: 13px;
    color: var(--tbs-text-muted);
}

/* ---------------------------------------------------------------
 * Verification Notice card
 * ------------------------------------------------------------- */
.tbs-verification-notice {
    max-width: 440px;
    margin: 24px auto;
    padding: 28px 32px 24px;
    background: var(--tbs-bg);
    border-radius: var(--tbs-radius-card);
    box-shadow: var(--tbs-shadow-lg);
    font-family: var(--tbs-font);
    border: 1px solid var(--tbs-border);
}

.tbs-resend-form {
    margin-top: 14px;
}

.tbs-resend-form p {
    margin: 0 0 10px;
    font-size: 13px;
    color: var(--tbs-text-muted);
}

.tbs-pending-notice {
    margin-bottom: 0;
    line-height: 1.6;
}

/* ---------------------------------------------------------------
 * Responsive
 * ------------------------------------------------------------- */
@media (max-width: 520px) {
    .tbs-auth-form,
    .tbs-verification-notice {
        margin: 16px 12px;
        padding: 20px 18px;
    }

    .tbs-form-header h2 {
        font-size: 20px;
    }

    .tbs-remember-forgot {
        flex-direction: column;
        align-items: flex-start;
    }

    .tbs-button {
        font-size: 14px;
    }
}

/* ---------------------------------------------------------------
 * Popup Modal Overlay
 * ------------------------------------------------------------- */
.tbs-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(7, 15, 69, 0.72);
    z-index: 999999;
    align-items: center;
    justify-content: center;
    padding: 16px;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity 0.18s ease;
}

.tbs-modal-overlay.tbs-modal-is-open {
    display: flex;
    opacity: 1;
}

.tbs-modal-container {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 25px 60px rgba(7, 15, 69, 0.30);
    width: 100%;
    max-width: var(--tbs-form-width);
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    transform: translateY(-14px) scale(0.97);
    transition: transform 0.18s ease, opacity 0.18s ease;
    opacity: 0;
}

.tbs-modal-overlay.tbs-modal-is-open .tbs-modal-container {
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* Close button */
.tbs-modal-close {
    position: absolute;
    top: 12px;
    right: 14px;
    background: none;
    border: none;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    color: var(--tbs-text-muted);
    padding: 4px 8px;
    border-radius: 6px;
    transition: var(--tbs-transition);
    z-index: 2;
    font-family: var(--tbs-font);
}

.tbs-modal-close:hover {
    color: var(--tbs-brand-dark);
    background: var(--tbs-bg-muted);
}

/* Modal views — only active one is visible */
.tbs-modal-view {
    display: none;
}

.tbs-modal-view.tbs-view-active {
    display: block;
}

/* Strip card styles for forms inside the modal */
#tbs-auth-modal .tbs-auth-form {
    max-width: none;
    margin: 0;
    padding: 28px 32px;
    box-shadow: none;
    border: none;
    border-radius: 0;
}

/* Force correct button colors inside modal (overrides theme CSS) */
#tbs-auth-modal .tbs-button {
    background: #070f45 !important;
    color: #baf734 !important;
    border-color: #070f45 !important;
    box-shadow: none !important;
}

#tbs-auth-modal .tbs-button:hover {
    background: #0d1a6b !important;
    color: #baf734 !important;
}

#tbs-auth-modal .tbs-google-btn {
    background: #fff !important;
    color: #070f45 !important;
    border: 1px solid #E5E7EB !important;
    box-shadow: none !important;
}

/* Fix close button — override theme button styles */
#tbs-auth-modal .tbs-modal-close {
    background: none !important;
    background-color: transparent !important;
    border: none !important;
    box-shadow: none !important;
    color: var(--tbs-text-muted) !important;
}

#tbs-auth-modal .tbs-modal-close:hover {
    background: var(--tbs-bg-muted) !important;
    color: var(--tbs-brand-dark) !important;
}

/* Fix eye icon toggle button — override theme button styles */
#tbs-auth-modal .tbs-toggle-password {
    background: none !important;
    background-color: transparent !important;
    border: none !important;
    box-shadow: none !important;
    color: var(--tbs-text-muted) !important;
}

/* Prevent body scroll when modal is open */
body.tbs-modal-open {
    overflow: hidden;
}

/* Responsive modal */
@media (max-width: 520px) {
    .tbs-modal-container {
        border-radius: 12px;
        max-height: 95vh;
    }

    .tbs-modal-pane .tbs-auth-form {
        padding: 16px 18px 24px;
    }

    .tbs-modal-tabs-nav {
        padding: 16px 18px 0;
    }
}
