/* IDPS Auth - Apple-style Design */
:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f5f5f7;
    /* --bg-input: #f5f5f7; */
    --bg-input: #fff;
    /* --bg-input-phone: #f5f5f7; */
    --bg-card: #ffffff;
    --text-primary: #1d1d1f;
    --text-secondary: #86868b;
    --text-tertiary: #aeaeb2;
    /* --accent: #007AFF; */
    --accent: #303030;
    --accent-hover: #000000;
    /* --accent-hover: #0056CC; */
    /* --accent-light: rgba(0, 122, 255, 0.08); */
    --accent-light: rgb(255, 255, 255);
    --danger: #FF3B30;
    --danger-light: rgba(255, 59, 48, 0.08);
    --success: #34C759;
    --success-light: rgba(52, 199, 89, 0.08);
    --warning: #FF9500;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.04);
    --shadow: 0 2px 20px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 40px rgba(0,0,0,0.12);
    --divider: #e5e5ea;
    --radius: 0px;
    --radius-input: 0px;
    --font: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Helvetica Neue', 'Segoe UI', Roboto, sans-serif;
    --transition: 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    --transition-fast: 0.15s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    --transition-spring: 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-primary: #000000;
        --bg-secondary: #1c1c1e;
        --bg-input: #2c2c2e;
        --bg-card: #1c1c1e;
        --text-primary: #ffffff;
        --text-secondary: #8e8e93;
        --text-tertiary: #636366;
        --accent: #0A84FF;
        --accent-hover: #409CFF;
        --accent-light: rgba(10, 132, 255, 0.12);
        --danger: #FF453A;
        --danger-light: rgba(255, 69, 58, 0.12);
        --success: #30D158;
        --success-light: rgba(48, 209, 88, 0.12);
        --warning: #FF9F0A;
        --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
        --shadow: 0 2px 20px rgba(0,0,0,0.3);
        --shadow-lg: 0 8px 40px rgba(0,0,0,0.4);
        --divider: #38383a;
    }
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font);
    background: var(--bg-secondary);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Container */
.auth-container {
    width: 100%;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

/* Card */
.auth-card {
    width: 100%;
    max-width: 420px;
    /* background: var(--bg-card); */
    border-radius: var(--radius);
    /* box-shadow: var(--shadow); */
    padding: 40px 36px;
    animation: cardEnter 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both;
    position: relative;
    overflow: hidden;
}

@keyframes cardEnter {
    from { opacity: 0; transform: translateY(20px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Title */
.auth-title {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--text-primary);
    margin-bottom: 8px;
    animation: fadeSlideDown 0.5s 0.1s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.auth-subtitle {
    font-size: 15px;
    color: var(--text-secondary);
    margin-bottom: 32px;
    line-height: 1.4;
    animation: fadeSlideDown 0.5s 0.15s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

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

/* Form */
.auth-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
    animation: fadeSlideDown 0.5s 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
}

/* Input Group */
.auth-input-group {
    position: relative;
    animation: inputSlideIn 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
}
.auth-input-group:nth-child(1) { animation-delay: 0.25s; }
.auth-input-group:nth-child(2) { animation-delay: 0.30s; }
.auth-input-group:nth-child(3) { animation-delay: 0.35s; }
.auth-input-group:nth-child(4) { animation-delay: 0.40s; }
.auth-input-group:nth-child(5) { animation-delay: 0.45s; }
.auth-input-group:nth-child(6) { animation-delay: 0.50s; }

@keyframes inputSlideIn {
    from { opacity: 0; transform: translateX(-10px); }
    to { opacity: 1; transform: translateX(0); }
}

/* Input */
.auth-input {
    width: 100%;
    padding: 14px 16px;
    font-size: 14px;
    font-family: var(--font);
    color: var(--text-primary);
    background: var(--bg-input);
    border: none;
    border-radius: var(--radius-input);
    outline: none;
    transition: background var(--transition-fast), box-shadow var(--transition-fast);
    -webkit-appearance: none;
}

/* .auth-input:focus {
    box-shadow: 0 0 0 3.5px var(--accent-light);
} */

.auth-input::placeholder {
    color: var(--text-tertiary);
}

.auth-input.error {
    box-shadow: 0 0 0 3.5px var(--danger-light);
}

/* Select */
.auth-select {
    width: 100%;
    padding: 14px 16px;
    font-size: 16px;
    font-family: var(--font);
    color: var(--text-primary);
    background: var(--bg-input);
    border: none;
    border-radius: var(--radius-input);
    outline: none;
    cursor: pointer;
    transition: box-shadow var(--transition-fast);
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%2386868b' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 40px;
}

.auth-select:focus {
    box-shadow: 0 0 0 3.5px var(--accent-light);
}

.auth-select option {
    background: var(--bg-card);
    color: var(--text-primary);
}

/* Password wrapper */
.auth-input-wrapper {
    position: relative;
}

.auth-input-wrapper .auth-input {
    padding-right: 44px;
}

.auth-toggle-pw {
    position: absolute;
    right: 4px;
    top: 4px;
    bottom: 4px;
    width: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-tertiary);
    border-radius: 8px;
    transition: color var(--transition-fast), background var(--transition-fast);
}

.auth-toggle-pw:hover {
    color: var(--text-secondary);
    background: var(--accent-light);
}

.auth-toggle-pw svg {
    width: 18px;
    height: 18px;
}

/* Code row */
.auth-code-row {
    display: flex;
    gap: 10px;
}

.auth-code-row .auth-input {
    /* flex: 1;
    letter-spacing: 4px;
    text-align: center;
    font-weight: 600; */
}

.auth-btn-send {
    white-space: nowrap;
    padding: 14px 18px;
    font-size: 14px;
    /* font-weight: 600; */
    font-family: var(--font);
    color: var(--accent);
    background: var(--accent-light);
    border: none;
    border-radius: var(--radius-input);
    cursor: pointer;
    transition: all var(--transition-fast);
    min-width: 110px;
}

.auth-btn-send:hover {
    background: var(--accent);
    color: #fff;
}

.auth-btn-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    color: var(--text-tertiary);
    background: var(--bg-input);
}

/* Agree checkbox */
.auth-agree {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 2px 0 0;
    cursor: pointer;
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.5;
    user-select: none;
}

.auth-agree input[type="checkbox"] {
    display: none;
}

.auth-agree .check-mark {
    width: 18px;
    height: 18px;
    border: 2px solid var(--divider);
    border-radius: 5px;
    flex-shrink: 0;
    margin-top: 1px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.auth-agree input:checked + .check-mark {
    background: var(--accent);
    border-color: var(--accent);
}

.auth-agree input:checked + .check-mark::after {
    content: '';
    width: 5px;
    height: 9px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    margin-top: -2px;
}

.auth-agree a {
    color: var(--accent);
    text-decoration: none;
}

.auth-agree a:hover { opacity: 0.7; }

/* Footer */
.auth-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 26px 26px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 12px;
    color: var(--text-tertiary);
    z-index: 10;
}

.auth-footer a {
    color: var(--text-tertiary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

.auth-footer a:hover {
    color: var(--text-secondary);
}

.auth-footer .auth-copyright {
    display: flex;
    align-items: center;
    gap: 8px;
}

.auth-footer .auth-copyright a {
    font-weight: 500;
    color: var(--text-secondary);
}

.auth-footer .auth-footer-links {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.auth-footer .auth-footer-dot {
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: var(--text-tertiary);
    opacity: 0.5;
}

/* Buttons */
.auth-btn {
    width: 100%;
    padding: 14px;
    font-size: 14px;
    font-weight: 600;
    font-family: var(--font);
    color: #ffffff;
    background: var(--accent);
    border: none;
    border-radius: var(--radius-input);
    cursor: pointer;
    transition: background var(--transition-fast), transform 0.1s ease, opacity var(--transition-fast);
    outline: none;
    margin-top: 6px;
    position: relative;
    overflow: hidden;
}

.auth-btn:hover {
    background: var(--accent-hover);
}

.auth-btn:active {
    transform: scale(0.98);
}

.auth-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Ripple effect */
.auth-btn .ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(255,255,255,0.3);
    transform: scale(0);
    animation: ripple 0.6s linear;
    pointer-events: none;
}

@keyframes ripple {
    to { transform: scale(4); opacity: 0; }
}

/* Loading */
.auth-btn .spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2.5px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    vertical-align: middle;
    margin-right: 8px;
}

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

/* Links area */
.auth-links {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    padding-top: 20px;
    animation: fadeSlideDown 0.5s 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
}

.auth-link {
    font-size: 12px;
    font-weight: 500;
    color: var(--accent);
    text-decoration: none;
    cursor: pointer;
    transition: opacity var(--transition-fast);
    background: none;
    border: none;
    font-family: var(--font);
    padding: 0;
}

.auth-link:hover { opacity: 0.7; }

.auth-link-text {
    font-size: 12px;
    color: var(--text-secondary);
    margin-right: 4px;
}

/* Message */
.auth-message {
    padding: 12px 16px;
    border-radius: var(--radius-input);
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    animation: msgIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes msgIn {
    from { opacity: 0; transform: translateY(-10px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.auth-message-error {
    background: var(--danger-light);
    color: var(--danger);
}

.auth-message-success {
    background: var(--success-light);
    color: var(--success);
}

/* Form panel transitions */
.auth-form-wrapper {
    position: relative;
}

.auth-form-panel {
    transition: opacity var(--transition), transform var(--transition);
}

.auth-form-panel.panel-hidden {
    opacity: 0;
    transform: translateX(20px);
    position: absolute;
    pointer-events: none;
    top: 0; left: 0; right: 0;
}

.auth-form-panel.panel-active {
    opacity: 1;
    transform: translateX(0);
    position: relative;
}

/* Logo */
.auth-logo {
    position: fixed;
    top: 20px;
    left: 26px;
    z-index: 99;
    animation: fadeIn 0.5s 0.6s both;
}

.auth-logo img {
    height: 28px;
    width: auto;
    display: block;
}

/* Language switcher - icon + dropdown */
.auth-lang {
    position: fixed;
    top: 26px;
    right: 26px;
    z-index: 100;
    animation: fadeIn 0.5s 0.6s both;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.auth-lang-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    transition: color var(--transition-fast);
}

.auth-lang-btn:hover {
    color: var(--text-primary);
}

.auth-lang-btn svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.auth-lang-name {
    font-size: 13px;
    font-weight: 500;
    font-family: var(--font);
    color: inherit;
    white-space: nowrap;
}

.auth-lang-dropdown {
    position: absolute;
    top: 48px;
    right: 0;
    min-width: 160px;
    background: var(--bg-card);
    /* border-radius: 12px;
    box-shadow: var(--shadow-lg); */
    /* padding: 6px 0; */
    opacity: 0;
    transform: scale(0.9) translateY(-8px);
    transform-origin: top right;
    pointer-events: none;
    transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.auth-lang.open .auth-lang-dropdown {
    opacity: 1;
    transform: scale(1) translateY(0);
    pointer-events: all;
}

.auth-lang-dropdown a {
    display: block;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 400;
    font-family: var(--font);
    color: var(--text-primary);
    text-decoration: none;
    transition: background var(--transition-fast);
}

.auth-lang-dropdown a:hover {
    background: var(--bg-input);
}

.auth-lang-dropdown a.active {
    color: var(--accent);
    font-weight: 600;
}

.auth-lang-dropdown a span {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-left: 8px;
    font-weight: 400;
}

.auth-lang-dropdown a.active span {
    color: var(--accent);
    opacity: 0.6;
}

/* Responsive */
@media (max-width: 480px) {
    .auth-card {
        padding: 102px 24px;
        border-radius: 0;
        box-shadow: none;
        max-width: 100%;
        min-height: 100vh;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
    }
    body {
        background: var(--bg-primary);
    }
    .auth-container {
            display: flex;
    align-items: center;
    justify-content: flex-start;
    }
    .auth-title {
        font-size: 24px;
    }
    .auth-lang {
        top: auto;
        bottom: 56px;
        right: 26px;
    }
    .auth-logo {
        top: auto;
        bottom: 56px;
        left: 26px;
    }

    .auth-input {
        background: #f5f5f7;
    }
    .auth-lang-dropdown {
        bottom: 48px;
        top: auto;
        transform-origin: bottom right;
    }
    .auth-lang.open .auth-lang-dropdown {
        transform: scale(1) translateY(0);
        box-shadow: var(--shadow-lg);
    }

    .auth-footer {

    position: fixed;
    bottom: 90px;
    left: 0;
    right: 0;
    padding: 12px 26px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 12px;
    color: var(--text-tertiary);
    z-index: 10;

    }
}

/* RTL support for Arabic */
[dir="rtl"] .auth-input,
[dir="rtl"] .auth-select {
    text-align: right;
}

[dir="rtl"] .auth-code-row .auth-input {
    text-align: center;
}
