/* ═══════════════════════════════════════════════════
   Mikrotik Hotspot Login – Premium Stylesheet
   ═══════════════════════════════════════════════════ */

/* ─── Custom Properties (Theme) ─────────────────── */
:root {
    /* Primary palette */
    --primary: #6366f1;
    --primary-light: #818cf8;
    --primary-dark: #4f46e5;
    --primary-glow: rgba(99, 102, 241, 0.35);

    /* Accent */
    --accent: #06b6d4;
    --accent-light: #22d3ee;

    /* Status */
    --success: #10b981;
    --success-glow: rgba(16, 185, 129, 0.3);
    --error: #ef4444;
    --error-light: #fef2f2;
    --error-bg: rgba(239, 68, 68, 0.08);
    --warning: #f59e0b;

    /* Neutrals */
    --bg-start: #0f0c29;
    --bg-mid: #302b63;
    --bg-end: #24243e;
    --card-bg: rgba(255, 255, 255, 0.06);
    --card-border: rgba(255, 255, 255, 0.1);
    --card-shadow: 0 25px 50px rgba(0, 0, 0, 0.4);
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --input-bg: rgba(255, 255, 255, 0.07);
    --input-border: rgba(255, 255, 255, 0.12);
    --input-focus: rgba(99, 102, 241, 0.5);
    --input-text: #e2e8f0;

    /* Layout */
    --radius: 16px;
    --radius-sm: 10px;
    --radius-xs: 8px;
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);

    /* Fonts */
    --font-ar: 'Cairo', sans-serif;
    --font-en: 'Inter', sans-serif;
}

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

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-ar);
    background: linear-gradient(135deg, var(--bg-start), var(--bg-mid), var(--bg-end));
    color: var(--text-primary);
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow-x: hidden;
    padding: 16px;
    line-height: 1.6;
}

html[dir="ltr"] body {
    font-family: var(--font-en);
}

/* ─── Background Decorations ────────────────────── */
.bg-decoration {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.bg-circle {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.35;
}

.bg-circle-1 {
    width: 400px;
    height: 400px;
    background: var(--primary);
    top: -100px;
    right: -80px;
    animation: floatCircle 15s ease-in-out infinite;
}

.bg-circle-2 {
    width: 300px;
    height: 300px;
    background: var(--accent);
    bottom: -60px;
    left: -60px;
    animation: floatCircle 20s ease-in-out infinite reverse;
}

.bg-circle-3 {
    width: 200px;
    height: 200px;
    background: var(--primary-light);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation: floatCircle 18s ease-in-out infinite;
}

@keyframes floatCircle {

    0%,
    100% {
        transform: translate(0, 0) scale(1);
    }

    25% {
        transform: translate(30px, -20px) scale(1.05);
    }

    50% {
        transform: translate(-20px, 30px) scale(0.95);
    }

    75% {
        transform: translate(20px, 20px) scale(1.03);
    }
}

/* ─── Language Toggle ────────────────────────────── */
.lang-toggle {
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 100;
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--card-border);
    border-radius: 50px;
    padding: 8px 16px;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    transition: var(--transition);
    font-family: var(--font-en);
}

html[dir="ltr"] .lang-toggle {
    left: auto;
    right: 16px;
}

.lang-toggle:hover {
    background: rgba(255, 255, 255, 0.12);
    transform: scale(1.05);
}

.lang-icon {
    font-size: 1.1rem;
}

/* ─── Container ──────────────────────────────────── */
.container {
    width: 100%;
    max-width: 420px;
    position: relative;
    z-index: 1;
}

/* ─── Card ───────────────────────────────────────── */
.card {
    background: var(--card-bg);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    padding: 32px 28px;
    box-shadow: var(--card-shadow);
    position: relative;
    overflow: hidden;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--primary), var(--accent), var(--primary-light));
    opacity: 0.8;
}

/* ─── Brand ──────────────────────────────────────── */
.brand {
    text-align: center;
    margin-bottom: 28px;
}

.brand-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 12px;
    color: var(--primary-light);
    animation: pulse 3s ease-in-out infinite;
    display: flex;
    align-items: center;
    justify-content: center;
}

.brand-logo {
    max-width: 140px;
    height: auto;
    margin: 0 auto 15px;
    display: block;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.2));
    animation: floatLogo 6s ease-in-out infinite;
}

@keyframes floatLogo {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-6px);
    }
}

.brand-icon svg {
    width: 100%;
    height: 100%;
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.08);
        opacity: 0.85;
    }
}

.brand-title {
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--text-primary), var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 4px;
}

.brand-subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 400;
}

/* ─── Step Indicator ─────────────────────────────── */
.step-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    margin-bottom: 24px;
}

.step-dot {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    color: transparent;
    transition: var(--transition);
    flex-shrink: 0;
}

.step-dot.active {
    border-color: var(--primary);
    background: var(--primary);
    color: white;
    box-shadow: 0 0 16px var(--primary-glow);
}

.step-dot.completed {
    border-color: var(--success);
    background: var(--success);
    color: white;
}

.step-line {
    width: 40px;
    height: 2px;
    background: var(--text-muted);
    transition: var(--transition);
}

.step-line.completed {
    background: var(--success);
}

/* ─── Steps ──────────────────────────────────────── */
.step {
    display: none;
    animation: fadeSlideIn 0.5s ease forwards;
}

.step-active {
    display: block;
}

@keyframes fadeSlideIn {
    from {
        opacity: 0;
        transform: translateY(16px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.step-title {
    font-size: 1.25rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 6px;
}

.step-desc {
    font-size: 0.88rem;
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 24px;
}

/* ─── Input Groups ───────────────────────────────── */
.input-group {
    margin-bottom: 18px;
}

.input-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

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

.input-icon {
    position: absolute;
    right: 14px;
    font-size: 1.1rem;
    pointer-events: none;
    z-index: 2;
}

html[dir="ltr"] .input-icon {
    right: auto;
    left: 14px;
}

.input-wrapper input {
    width: 100%;
    padding: 14px 44px 14px 16px;
    background: var(--input-bg);
    border: 1.5px solid var(--input-border);
    border-radius: var(--radius-sm);
    color: var(--input-text);
    font-size: 1rem;
    font-family: inherit;
    outline: none;
    transition: var(--transition);
}

html[dir="ltr"] .input-wrapper input {
    padding: 14px 16px 14px 44px;
}

.input-wrapper input::placeholder {
    color: var(--text-muted);
}

.input-wrapper input:focus {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.06);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.input-wrapper input.input-error-state {
    border-color: var(--error);
    box-shadow: 0 0 0 3px var(--error-bg);
}

.input-error {
    display: block;
    font-size: 0.78rem;
    color: var(--error);
    min-height: 18px;
    margin-top: 4px;
    transition: var(--transition);
}

/* ─── OTP Boxes ──────────────────────────────────── */
.otp-container {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin: 20px 0 8px;
    direction: ltr;
}

.otp-box {
    width: 48px;
    height: 56px;
    text-align: center;
    font-size: 1.4rem;
    font-weight: 700;
    font-family: var(--font-en);
    background: var(--input-bg);
    border: 1.5px solid var(--input-border);
    border-radius: var(--radius-xs);
    color: var(--text-primary);
    outline: none;
    transition: var(--transition);
    caret-color: var(--primary);
}

.otp-box:focus {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.08);
    box-shadow: 0 0 0 3px var(--primary-glow);
    transform: translateY(-2px);
}

.otp-box.filled {
    border-color: var(--primary-light);
    background: rgba(99, 102, 241, 0.1);
}

.otp-box.error {
    border-color: var(--error);
    animation: shake 0.4s ease;
}

.otp-error {
    text-align: center;
    margin-bottom: 8px;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    20% {
        transform: translateX(-6px);
    }

    40% {
        transform: translateX(6px);
    }

    60% {
        transform: translateX(-4px);
    }

    80% {
        transform: translateX(4px);
    }
}

/* ─── Countdown ──────────────────────────────────── */
.countdown {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 16px 0;
}

.countdown-svg {
    width: 36px;
    height: 36px;
    transform: rotate(-90deg);
}

.countdown-bg {
    fill: none;
    stroke: rgba(255, 255, 255, 0.08);
    stroke-width: 2.5;
}

.countdown-progress {
    fill: none;
    stroke: var(--primary);
    stroke-width: 2.5;
    stroke-linecap: round;
    transition: stroke-dasharray 1s linear;
}

.countdown-text {
    font-family: var(--font-en);
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    min-width: 50px;
}

.countdown.expired .countdown-progress {
    stroke: var(--error);
}

.countdown.expired .countdown-text {
    color: var(--error);
}

/* ─── Buttons ────────────────────────────────────── */
.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    box-shadow: 0 4px 15px var(--primary-glow);
    margin-top: 8px;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px var(--primary-glow);
}

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

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-link {
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.88rem;
    font-weight: 600;
    margin-top: 8px;
}

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

/* Button loading state */
.btn.loading .btn-text {
    opacity: 0;
}

.btn.loading .btn-spinner {
    display: block;
}

.btn-spinner {
    display: none;
    width: 22px;
    height: 22px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    position: absolute;
}

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

/* ─── Success Animation ──────────────────────────── */
.success-animation {
    display: flex;
    justify-content: center;
    margin-bottom: 16px;
}

.checkmark {
    width: 72px;
    height: 72px;
}

.checkmark-circle {
    stroke: var(--success);
    stroke-width: 2;
    stroke-dasharray: 166;
    stroke-dashoffset: 166;
    animation: strokeCircle 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards;
}

.checkmark-check {
    stroke: var(--success);
    stroke-width: 3;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 48;
    stroke-dashoffset: 48;
    animation: strokeCheck 0.3s cubic-bezier(0.65, 0, 0.45, 1) 0.5s forwards;
}

@keyframes strokeCircle {
    to {
        stroke-dashoffset: 0;
    }
}

@keyframes strokeCheck {
    to {
        stroke-dashoffset: 0;
    }
}

.success-title {
    color: var(--success) !important;
}

.success-details {
    background: rgba(16, 185, 129, 0.06);
    border: 1px solid rgba(16, 185, 129, 0.15);
    border-radius: var(--radius-xs);
    padding: 16px;
    margin-top: 16px;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    font-size: 0.9rem;
}

.detail-row span {
    color: var(--text-secondary);
}

.detail-row strong {
    color: var(--text-primary);
}

/* ─── Toast ──────────────────────────────────────── */
.toast {
    position: fixed;
    top: -80px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-mid);
    backdrop-filter: blur(20px);
    border: 1px solid var(--card-border);
    border-radius: 50px;
    padding: 12px 24px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-primary);
    z-index: 200;
    transition: top 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    white-space: nowrap;
    max-width: 90vw;
}

.toast.show {
    top: 20px;
}

.toast.toast-error {
    border-color: rgba(239, 68, 68, 0.3);
}

.toast.toast-success {
    border-color: rgba(16, 185, 129, 0.3);
}

/* ─── Mikrotik Error Banner ──────────────────────── */
.mikrotik-error {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--error-bg);
    border: 1px solid rgba(239, 68, 68, 0.25);
    border-radius: var(--radius-xs);
    padding: 12px 16px;
    margin-bottom: 20px;
    animation: fadeSlideIn 0.4s ease;
}

.mikrotik-error .error-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
}

.mikrotik-error .error-text {
    font-size: 0.88rem;
    color: #fca5a5;
    font-weight: 600;
}

/* ─── Footer ─────────────────────────────────────── */
.footer {
    text-align: center;
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 20px;
}

/* ─── Responsive ─────────────────────────────────── */
@media (max-width: 480px) {
    body {
        padding: 8px;
        align-items: flex-start;
        padding-top: 40px;
    }

    .card {
        padding: 24px 20px;
        border-radius: 14px;
    }

    .brand-icon {
        width: 48px;
        height: 48px;
    }

    .brand-title {
        font-size: 1.3rem;
    }

    .otp-box {
        width: 42px;
        height: 50px;
        font-size: 1.25rem;
    }

    .otp-container {
        gap: 7px;
    }
}

@media (max-width: 360px) {
    .otp-box {
        width: 38px;
        height: 46px;
        font-size: 1.1rem;
    }

    .otp-container {
        gap: 5px;
    }

    .step-line {
        width: 28px;
    }
}

/* ─── High contrast preference ───────────────────── */
@media (prefers-contrast: high) {
    :root {
        --card-bg: rgba(0, 0, 0, 0.8);
        --card-border: rgba(255, 255, 255, 0.3);
        --input-border: rgba(255, 255, 255, 0.4);
    }
}

/* ─── Reduced motion preference ──────────────────── */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}