/* ===== CSS Variables (Theme Colors) ===== */
:root {
    --primary-color: #3390ec;
    --primary-color-hover: #4ea4f6;
    --surface-color: #ffffff;
    --background-color: #f4f4f5;
    --text-color: #000000;
    --secondary-text-color: #707579;
    --border-color: #dadce0;
    --error-color: #e53935;
    --success-color: #4caf50;
    --input-border: #c8c9cc;
    --input-focus: #4ea4f6;
    --shadow: 0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);
}

/* ===== Base Styles ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--background-color);
    color: var(--text-color);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ===== Container & Layout ===== */
.page {
    display: none;
    min-height: 100vh;
    padding: 24px;
    animation: fadeIn 0.3s ease;
}

.page.active {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* ===== Auth Image / Logo ===== */
.auth-image {
    width: 160px;
    height: 160px;
    margin: 0 auto 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sign-logo {
    display: block;
    fill: var(--primary-color);
}

/* ===== Typography ===== */
h4 {
    font-size: 32px;
    font-weight: 500;
    text-align: center;
    margin-bottom: 12px;
    color: var(--text-color);
}

.subtitle {
    font-size: 14px;
    color: var(--secondary-text-color);
    text-align: center;
    margin-bottom: 28px;
    max-width: 360px;
}

/* ===== Input Wrapper ===== */
.input-wrapper {
    width: 100%;
    max-width: 360px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ===== Input Fields ===== */
.input-field {
    position: relative;
    width: 100%;
}

.input-field label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--primary-color);
    margin-bottom: 8px;
    transition: color 0.2s;
}

.input-field input,
.input-field select {
    width: 100%;
    padding: 12px 16px;
    font-size: 16px;
    border: 2px solid var(--input-border);
    border-radius: 12px;
    background: var(--surface-color);
    color: var(--text-color);
    transition: all 0.2s;
    outline: none;
}

.input-field input:focus,
.input-field select:focus {
    border-color: var(--input-focus);
}

.input-field input::placeholder {
    color: var(--secondary-text-color);
}

.input-field input.error {
    border-color: var(--error-color);
}

.error-label {
    color: var(--error-color);
    font-size: 13px;
    margin-top: 6px;
    min-height: 18px;
}

/* ===== Buttons ===== */
.btn-primary {
    width: 100%;
    padding: 14px 24px;
    font-size: 15px;
    font-weight: 500;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-block;
    text-align: center;
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-color-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: transparent;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
}

.btn-secondary:hover {
    background: var(--primary-color);
    color: white;
}

/* ===== Code Input (OTP Style) ===== */
.code-input {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin: 24px 0;
}

.code-input input {
    width: 48px;
    height: 56px;
    text-align: center;
    font-size: 24px;
    font-weight: 600;
    border: 2px solid var(--input-border);
    border-radius: 12px;
    background: var(--surface-color);
    outline: none;
    transition: all 0.2s;
    
    /* Explicit color (fix black text) */
    color: #000000;
    
    /* Prevent auto-zoom on mobile */
    font-size: 16px;
}

.code-input input:focus {
    border-color: var(--input-focus);
    box-shadow: 0 0 0 3px rgba(62, 144, 236, 0.1);
    font-size: 24px; /* Larger when focused */
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
    .code-input input {
        color: #ffffff;
        background: #2a2a2a;
    }
}

/* ===== QR Code ===== */
.qr-placeholder {
    width: 240px;
    height: 240px;
    margin: 0 auto 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-color);
    border-radius: 16px;
    box-shadow: var(--shadow);
}

.qr-description {
    list-style-position: inside;
    color: var(--secondary-text-color);
    font-size: 14px;
    margin: 20px 0;
    padding: 0 20px;
}

.qr-description li {
    margin-bottom: 8px;
}

/* ===== Toast Notifications ===== */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 16px 24px;
    border-radius: 12px;
    color: white;
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow);
    animation: slideIn 0.3s ease;
    z-index: 1000;
    max-width: 320px;
}

.toast.error {
    background: var(--error-color);
}

.toast.success {
    background: var(--success-color);
}

/* ===== Animations ===== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ===== Responsive Design ===== */
@media (max-width: 480px) {
    .page {
        padding: 16px;
    }
    
    h4 {
        font-size: 24px;
    }
    
    .auth-image {
        width: 120px;
        height: 120px;
        margin-bottom: 24px;
    }
    
    .input-wrapper {
        max-width: 100%;
    }
    
    .code-input input {
        width: 40px;
        height: 48px;
        font-size: 20px;
    }
}

/* ===== Dark Mode Support (Optional) ===== */
@media (prefers-color-scheme: dark) {
    :root {
        --surface-color: #212121;
        --background-color: #0e0e0e;
        --text-color: #ffffff;
        --secondary-text-color: #aaaaaa;
        --border-color: #3a3a3a;
        --input-border: #4a4a4a;
        --shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.5), 0 1px 3px 1px rgba(0, 0, 0, 0.4);
    }
}

select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
}

select::-ms-expand {
    display: none; /* IE fix */
}

.input-field select {
    padding-right: 40px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%233390ec' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
}