/**
 * Sakari Passwordless Login - Form Styles
 * Mobile-first, clean, and user-friendly design
 */

/* ============================================
   Wrapper & Form Container
   ============================================ */
.sms-login-wrapper {
    max-width: 420px;
    margin: 0 auto;
    padding: 20px;
}

.sms-login-form {
    background: #ffffff;
    border: 1px solid #e1e1e1;
    border-radius: 8px;
    padding: 30px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

/* ============================================
   Steps & Visibility
   ============================================ */
.sms-step {
    display: none;
}

.sms-step.active {
    display: block;
    animation: fadeIn 0.3s ease-in;
}

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

/* ============================================
   Typography
   ============================================ */
.sms-login-form h3 {
    margin: 0 0 10px;
    font-size: 24px;
    font-weight: 600;
    color: #333;
    text-align: center;
}

.sms-description {
    margin: 0 0 24px;
    font-size: 14px;
    color: #666;
    text-align: center;
    line-height: 1.5;
}

#sms-phone-display {
    font-weight: 600;
    color: #333;
}

/* ============================================
   Form Groups & Labels
   ============================================ */
.sms-form-group {
    margin-bottom: 20px;
}

.sms-form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
    color: #333;
}

/* ============================================
   Input Fields
   ============================================ */
.sms-input {
    width: 100%;
    padding: 14px 16px;
    font-size: 16px;
    line-height: 1.5;
    color: #333;
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.sms-input:focus {
    outline: none;
    border-color: #4a90e2;
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

.sms-input::placeholder {
    color: #999;
}

/* Phone Number Input with Country Code */
.sms-phone-input-wrapper {
    display: flex;
    gap: 10px;
}

.sms-country-code {
    flex: 0 0 auto;
    width: 110px;
    padding: 14px 12px;
    font-size: 16px;
    color: #333;
    background-color: #f8f8f8;
    border: 1px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
}

.sms-country-code:focus {
    outline: none;
    border-color: #4a90e2;
}

.sms-phone-input-wrapper .sms-input {
    flex: 1;
}

/* OTP Input Styling */
.sms-otp-input {
    text-align: center;
    letter-spacing: 8px;
    font-size: 24px;
    font-weight: 600;
    padding: 16px;
}

/* ============================================
   Buttons
   ============================================ */
.sms-button {
    width: 100%;
    padding: 16px 24px;
    font-size: 16px;
    font-weight: 600;
    text-align: center;
    color: #fff;
    background-color: #4a90e2;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.sms-button:hover:not(:disabled) {
    background-color: #3a7bc8;
}

.sms-button:active:not(:disabled) {
    transform: scale(0.98);
}

.sms-button:disabled {
    background-color: #ccc;
    cursor: not-allowed;
    opacity: 0.6;
}

.sms-button.loading {
    position: relative;
    color: transparent;
    pointer-events: none;
}

.sms-button.loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spinner 0.6s linear infinite;
}

@keyframes spinner {
    to {
        transform: rotate(360deg);
    }
}

/* Link Buttons */
.sms-button-link {
    display: inline-block;
    padding: 8px 0;
    font-size: 14px;
    color: #4a90e2;
    background: none;
    border: none;
    cursor: pointer;
    text-decoration: underline;
}

.sms-button-link:hover:not(:disabled) {
    color: #3a7bc8;
}

.sms-button-link:disabled {
    color: #999;
    cursor: not-allowed;
    text-decoration: none;
}

/* Back Button */
#sms-back-btn {
    margin-top: 16px;
    text-align: center;
    width: 100%;
}

/* ============================================
   Resend Code Section
   ============================================ */
.sms-resend-wrapper {
    margin: 16px 0;
    text-align: center;
}

#sms-resend-btn {
    display: inline-block;
}

/* ============================================
   Error Messages
   ============================================ */
.sms-error {
    margin-top: 16px;
    padding: 12px 16px;
    font-size: 14px;
    color: #d32f2f;
    background-color: #ffebee;
    border: 1px solid #ffcdd2;
    border-radius: 6px;
    line-height: 1.5;
}

/* ============================================
   Success State
   ============================================ */
#sms-success-step {
    text-align: center;
    padding: 40px 0;
}

.sms-success-icon {
    display: inline-block;
    width: 80px;
    height: 80px;
    line-height: 80px;
    font-size: 48px;
    color: #4caf50;
    background-color: #e8f5e9;
    border-radius: 50%;
    margin-bottom: 20px;
    animation: scaleIn 0.4s ease;
}

@keyframes scaleIn {
    from {
        transform: scale(0);
    }
    to {
        transform: scale(1);
    }
}

#sms-success-step h3 {
    color: #4caf50;
    margin-bottom: 8px;
}

#sms-success-step p {
    color: #666;
    font-size: 14px;
}

/* ============================================
   Mobile Optimization (< 480px)
   ============================================ */
@media (max-width: 480px) {
    .sms-login-wrapper {
        padding: 10px;
    }

    .sms-login-form {
        padding: 24px 20px;
        border-radius: 6px;
    }

    .sms-login-form h3 {
        font-size: 22px;
    }

    .sms-description {
        font-size: 13px;
    }

    .sms-input {
        padding: 16px 14px;
        font-size: 16px; /* Prevent iOS zoom */
    }

    .sms-country-code {
        width: 100px;
        font-size: 16px;
    }

    .sms-otp-input {
        font-size: 20px;
        letter-spacing: 6px;
    }

    .sms-button {
        padding: 18px 20px;
        font-size: 16px;
    }
}

/* ============================================
   Tablet (481px - 768px)
   ============================================ */
@media (min-width: 481px) and (max-width: 768px) {
    .sms-login-wrapper {
        padding: 20px;
    }

    .sms-login-form {
        padding: 32px 28px;
    }
}

/* ============================================
   Touch Device Optimizations
   ============================================ */
@media (hover: none) and (pointer: coarse) {
    /* Increase tap target sizes for touch devices */
    .sms-button {
        min-height: 48px;
        padding: 16px 24px;
    }

    .sms-button-link {
        min-height: 44px;
        padding: 12px 8px;
    }

    .sms-input,
    .sms-country-code {
        min-height: 48px;
    }
}

/* ============================================
   Accessibility
   ============================================ */
.sms-input:focus-visible,
.sms-button:focus-visible,
.sms-country-code:focus-visible {
    outline: 3px solid #4a90e2;
    outline-offset: 2px;
}

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

/* ============================================
   Dark Mode Support (Optional)
   ============================================ */
@media (prefers-color-scheme: dark) {
    .sms-login-form {
        background: #1e1e1e;
        border-color: #333;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    }

    .sms-login-form h3,
    .sms-form-group label,
    #sms-phone-display {
        color: #e1e1e1;
    }

    .sms-description,
    #sms-success-step p {
        color: #aaa;
    }

    .sms-input,
    .sms-country-code {
        background-color: #2a2a2a;
        border-color: #444;
        color: #e1e1e1;
    }

    .sms-input::placeholder {
        color: #666;
    }

    .sms-input:focus {
        border-color: #4a90e2;
        box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.2);
    }

    .sms-country-code {
        background-color: #333;
    }

    .sms-error {
        background-color: #3d1f1f;
        border-color: #5c2929;
        color: #ff8a80;
    }
}

/* ============================================
   Print Styles
   ============================================ */
@media print {
    .sms-login-wrapper {
        display: none;
    }
}
