/**
 * Rekonise-style Authentication Pages
 * File: webroot/css/auth-rekonise.css
 */

/* ========================================
   CSS VARIABLES
   ======================================== */
:root {
    --auth-bg: #ffffff;
    --card-bg: #ffffff;
    --card-shadow: 0 4px 20px rgba(0, 0, 0, 0.08), 0 1px 4px rgba(0, 0, 0, 0.04);
    --card-radius: 16px;

    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;

    --border-color: #e5e7eb;
    --border-color-dark: #d1d5db;

    --accent-red: #e21e1e;
    --accent-red-hover: #b91c1c;
    --accent-blue: #3b82f6;

    --error-red: #ef4444;
    --success-green: #10b981;

    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}

/* ========================================
   RESET & BASE
   ======================================== */
*, *::before, *::after {
    box-sizing: border-box;
}

body.auth-body {
    font-family: var(--font-family);
    background-color: var(--auth-bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    margin: 0;
}

/* ========================================
   LOGO SECTION
   ======================================== */
.auth-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 32px;
}

.auth-logo img {
    max-height: 48px;
    height: 48px;
    width: auto;
}

.auth-logo-text {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.5px;
    margin: 0;
}

/* ========================================
   AUTH CARD
   ======================================== */
.auth-card {
    background: var(--card-bg);
    border: 1px solid #e0e0e0;
    border-radius: var(--card-radius);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08), 0 1px 4px rgba(0, 0, 0, 0.04);
    padding: 32px 40px;
    width: 100%;
    max-width: 420px;
    margin-bottom: 24px;
}

.auth-title {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
    text-align: center;
    margin: 0 0 24px 0;
    letter-spacing: -0.3px;
    width: 100%;
    max-width: 420px;
}

/* ========================================
   SOCIAL LOGIN BUTTONS
   ======================================== */
.social-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 0;
}

.btn-social {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    height: 48px;
    padding: 0 16px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 50px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: var(--font-family);
    -webkit-appearance: none;
    appearance: none;
}

.btn-social:hover {
    background: #f9fafb;
    border-color: var(--border-color-dark);
    color: var(--text-primary);
    text-decoration: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.btn-social:active {
    transform: scale(0.98);
}

.btn-social img,
.btn-social svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    object-fit: contain;
}

/* postLink wraps each button in a form - fix the form layout */
.social-buttons form {
    display: block;
    width: 100%;
    margin: 0;
    padding: 0;
}

/* ========================================
   DIVIDER
   ======================================== */
.auth-divider {
    display: flex;
    align-items: center;
    margin: 24px 0;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-color);
}

.auth-divider span {
    padding: 0 16px;
    font-size: 14px;
    color: var(--text-secondary);
    white-space: nowrap;
}

/* ========================================
   FORM STYLES
   ======================================== */
.auth-form {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.auth-form .form-group {
    margin-bottom: 16px;
    position: relative;
}

/* Override CakePHP's generated .input wrapper */
.auth-form .input {
    display: block;
    margin: 0;
    padding: 0;
}

.auth-form .form-control {
    width: 100%;
    height: 52px;
    padding: 14px 24px;
    padding-right: 52px;
    font-size: 15px;
    font-family: var(--font-family);
    color: var(--text-primary);
    background: #ffffff;
    border: 1px solid var(--border-color-dark);
    border-radius: 10px;
    outline: none;
    transition: border-color 0.15s ease;
    box-sizing: border-box;
    display: block;
}

.auth-form .form-control::placeholder {
    color: var(--text-muted);
}

.auth-form .form-control:focus {
    border-color: #6b7280;
    box-shadow: none;
}

/* Error State */
.auth-form .input.error .form-control,
.auth-form .form-control.is-invalid {
    border-color: var(--error-red);
}

.auth-form .input.error .form-control:focus {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.auth-form .error-message,
.auth-form .invalid-feedback {
    color: var(--error-red);
    font-size: 13px;
    margin-top: 6px;
    display: block;
}

/* ========================================
   INPUT WITH ICON (password wrapper)
   ======================================== */
.input-with-icon {
    position: relative;
}

.input-with-icon .input {
    position: static;
}

.input-with-icon .form-control {
    padding-right: 48px;
}

/* ========================================
   PASSWORD TOGGLE
   ======================================== */
.input-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    cursor: pointer;
    background: none;
    border: none;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    line-height: 1;
    transition: color 0.2s ease;
}

.input-icon:hover {
    color: var(--text-primary);
}

.input-icon svg {
    display: block;
}

/* ========================================
   FORM ACTIONS ROW (Forgot + Submit)
   ======================================== */
.auth-form-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 16px;
    margin-bottom: 0;
}

.auth-forgot {
    font-size: 14px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s ease;
    white-space: nowrap;
}

.auth-forgot:hover {
    color: var(--text-primary);
    text-decoration: underline;
}

/* ========================================
   SUBMIT BUTTON
   ======================================== */
.btn-primary-auth {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 44px;
    padding: 0 32px;
    background: var(--accent-red);
    color: #ffffff;
    font-size: 14px;
    font-weight: 600;
    font-family: var(--font-family);
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    letter-spacing: 0.2px;
    white-space: nowrap;
}

.btn-primary-auth:hover {
    background: var(--accent-red-hover);
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.25);
    color: #ffffff;
    text-decoration: none;
}

.btn-primary-auth:active {
    transform: scale(0.98);
    box-shadow: none;
}

.btn-primary-auth:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.3);
}

.btn-primary-auth:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Full width variant */
.btn-primary-auth.btn-block {
    width: 100%;
}

/* ========================================
   TERMS & CONDITIONS
   ======================================== */
.auth-terms {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 14px;
    color: #374151;
    margin-bottom: 16px;
}

.auth-terms input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent-red);
    cursor: pointer;
    flex-shrink: 0;
    margin-top: 2px;
}

.auth-terms label {
    cursor: pointer;
    user-select: none;
    line-height: 1.5;
    color: var(--text-secondary);
}

.auth-terms label a {
    color: var(--accent-red);
    text-decoration: none;
    font-weight: 500;
}

.auth-terms label a:hover {
    text-decoration: underline;
}

/* ========================================
   FOOTER LINK
   ======================================== */
.auth-footer {
    text-align: center;
    font-size: 14px;
    color: var(--text-secondary);
    margin: 0;
}

.auth-footer a {
    color: var(--accent-red);
    font-weight: 500;
    text-decoration: none;
    transition: color 0.2s ease;
}

.auth-footer a:hover {
    color: var(--accent-red-hover);
    text-decoration: underline;
}

/* ========================================
   FLASH / ALERT MESSAGES
   ======================================== */
.message,
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 16px;
}

.message.error,
.alert-danger {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.message.success,
.alert-success {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.message.warning,
.alert-warning {
    background: #fffbeb;
    color: #92400e;
    border: 1px solid #fde68a;
}

/* ========================================
   CAPTCHA
   ======================================== */
.captcha-container {
    margin-bottom: 16px;
    text-align: center;
}

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 480px) {
    body.auth-body {
        justify-content: flex-start;
        padding-top: 40px;
        align-items: stretch;
    }

    .auth-card {
        padding: 32px 24px;
    }

    .auth-title {
        font-size: 22px;
    }

    .auth-form-actions {
        flex-direction: column-reverse;
        gap: 12px;
    }

    .btn-primary-auth {
        width: 100%;
    }

    .auth-forgot {
        text-align: center;
        width: 100%;
    }
}
