/* ============================================
   Tutor Custom Enroll — Frontend Modal
   ============================================ */

/* Overlay */
.tce-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0);
    backdrop-filter: blur(0px);
    transition: background 0.3s ease, backdrop-filter 0.3s ease;
    padding: 20px;
}

.tce-modal-overlay.tce-active {
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

/* Window */
.tce-modal-window {
    position: relative;
    width: 100%;
    max-width: 420px;
    background: #ffffff;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.04);
    padding: 40px 36px 36px;
    opacity: 0;
    transform: translateY(20px) scale(0.97);
    transition: opacity 0.35s ease, transform 0.35s ease;
    overflow-y: auto;
    max-height: 95vh;
}

.tce-modal-overlay.tce-active .tce-modal-window {
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* Close button */
.tce-modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 36px;
    height: 36px;
    border: none;
    background: #f5f5f5;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    transition: all 0.2s;
    padding: 0;
    line-height: 1;
}

.tce-modal-close:hover {
    background: #e8e8e8;
    color: #333;
    transform: rotate(90deg);
}

/* Icon circle */
.tce-modal-icon {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
}

/* Title */
.tce-modal-title {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 22px;
    font-weight: 700;
    color: #1a1a2e;
    text-align: center;
    margin: 0 0 6px;
    line-height: 1.3;
}

.tce-modal-subtitle {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    color: #6b7280;
    text-align: center;
    margin: 0 0 28px;
    line-height: 1.5;
}

/* Form */
.tce-login-form {
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* Error */
.tce-login-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 10px;
    padding: 12px 16px;
    margin-bottom: 16px;
    font-size: 13px;
    color: #991b1b;
    display: flex;
    align-items: center;
    gap: 8px;
    line-height: 1.4;
}

.tce-login-error::before {
    content: '';
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23dc2626' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cline x1='12' y1='8' x2='12' y2='12'/%3E%3Cline x1='12' y1='16' x2='12.01' y2='16'/%3E%3C/svg%3E") no-repeat center;
}

/* Success */
.tce-login-success {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 10px;
    padding: 12px 16px;
    margin-bottom: 16px;
    font-size: 13px;
    color: #166534;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tce-login-success::before {
    content: '';
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%2316a34a' 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") no-repeat center;
}

/* Form groups */
.tce-form-group {
    margin-bottom: 16px;
}

.tce-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 6px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.tce-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.tce-input-icon {
    position: absolute;
    left: 14px;
    color: #9ca3af;
    pointer-events: none;
    flex-shrink: 0;
}

.tce-input-wrap input {
    width: 100%;
    height: 48px;
    padding: 0 14px 0 44px;
    border: 1.5px solid #e5e7eb;
    border-radius: 10px;
    font-size: 15px;
    color: #1f2937;
    background: #fafafa;
    transition: all 0.2s;
    outline: none;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    box-sizing: border-box;
    -webkit-appearance: none;
}

.tce-input-wrap input:focus {
    border-color: var(--tce-primary, #ff7617);
    background: #fff;
    box-shadow: 0 0 0 3px var(--tce-primary-light, rgba(255, 118, 23, 0.08));
}

.tce-input-wrap input::placeholder {
    color: #b0b4bb;
}

/* Toggle password */
.tce-toggle-pass {
    position: absolute;
    right: 10px;
    width: 34px;
    height: 34px;
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9ca3af;
    border-radius: 6px;
    padding: 0;
    transition: color 0.2s;
}

.tce-toggle-pass:hover {
    color: #6b7280;
}

/* Row (remember + forgot) */
.tce-form-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 8px;
}

/* Custom checkbox */
.tce-checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #6b7280;
    cursor: pointer;
    user-select: none;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.tce-checkbox-label input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.tce-checkmark {
    width: 18px;
    height: 18px;
    border: 2px solid #d1d5db;
    border-radius: 4px;
    flex-shrink: 0;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tce-checkbox-label input:checked + .tce-checkmark {
    background: var(--tce-color, #ff7617);
    border-color: var(--tce-color, #ff7617);
}

.tce-checkbox-label input:checked + .tce-checkmark::after {
    content: '';
    width: 5px;
    height: 9px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    margin-top: -2px;
}

/* Forgot link */
.tce-forgot-link {
    font-size: 13px;
    text-decoration: none;
    font-weight: 500;
    transition: opacity 0.2s;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.tce-forgot-link:hover {
    opacity: 0.8;
    text-decoration: underline;
}

/* Primary button */
.tce-btn-primary {
    width: 100%;
    height: 50px;
    border: none;
    color: #ffffff;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.25s;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    letter-spacing: 0.02em;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.tce-btn-primary:hover {
    filter: brightness(0.9);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    transform: translateY(-1px);
}

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

.tce-btn-primary:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

/* Spinner */
@keyframes tce-spin {
    to { transform: rotate(360deg); }
}

.tce-spinner {
    animation: tce-spin 0.8s linear infinite;
}

/* Register row */
.tce-register-row {
    text-align: center;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid #f3f4f6;
    font-size: 14px;
    color: #6b7280;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.tce-register-link {
    text-decoration: none;
    font-weight: 600;
    margin-left: 4px;
    transition: opacity 0.2s;
}

.tce-register-link:hover {
    opacity: 0.8;
    text-decoration: underline;
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 480px) {
    .tce-modal-window {
        padding: 32px 24px 28px;
        max-width: 100%;
        border-radius: 16px 16px 0 0 !important;
        position: fixed;
        bottom: 0;
        transform: translateY(100%);
        max-height: 92vh;
    }

    .tce-modal-overlay.tce-active .tce-modal-window {
        transform: translateY(0);
    }

    .tce-modal-overlay {
        align-items: flex-end;
        padding: 0;
    }

    .tce-modal-title {
        font-size: 20px;
    }

    .tce-modal-icon {
        width: 48px;
        height: 48px;
        margin-bottom: 16px;
    }
}

/* ============================================
   Register Panel (slide transition)
   ============================================ */

/* Login panel wrapper — used for show/hide animation */
.tce-login-panel {
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.tce-login-panel.tce-panel-hidden {
    display: none;
}

/* Register panel */
.tce-register-panel {
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.tce-register-panel.tce-panel-entering {
    animation: tce-slide-in 0.3s ease forwards;
}

@keyframes tce-slide-in {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes tce-slide-in-reverse {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.tce-login-panel.tce-panel-entering {
    animation: tce-slide-in-reverse 0.3s ease forwards;
}

/* Password strength indicator */
.tce-password-strength {
    display: block;
    font-size: 12px;
    margin-top: 6px;
    font-weight: 500;
    min-height: 16px;
    transition: color 0.2s;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.tce-password-strength.strength-weak {
    color: #dc2626;
}

.tce-password-strength.strength-medium {
    color: #f59e0b;
}

.tce-password-strength.strength-strong {
    color: #16a34a;
}

/* Strength bar */
.tce-strength-bar {
    height: 3px;
    border-radius: 3px;
    background: #e5e7eb;
    margin-top: 6px;
    overflow: hidden;
}

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

/* Back to login link styling */
.tce-back-to-login {
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: opacity 0.2s;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.tce-back-to-login:hover {
    opacity: 0.8;
    text-decoration: underline;
}

/* ============================================
   Button Override on Course Page
   ============================================ */
.tce-enroll-btn-replaced {
    cursor: pointer !important;
    transition: all 0.25s !important;
}

.tce-enroll-btn-replaced:hover {
    filter: brightness(0.92) !important;
    transform: translateY(-1px) !important;
}

/* Hide Tutor's default login modal when our plugin is active */
body.tce-modal-active .tutor-modal.tutor-login-modal {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
}

body.tce-modal-active .tutor-modal-overlay {
    display: none !important;
}
