/**
 * Elex Election Auth - Frontend Styles
 * Mobile-first, RTL, clean modern card design
 */

:root {
    --elex-bg: #ffffff;
    --elex-text: #111;
    --elex-text-muted: #6b7280;
    --elex-primary: #3056d3;
    --elex-primary-hover: #2649b6;
    --elex-success: #22c55e;
    --elex-error: #ef4444;
    --elex-border: #e5e7eb;
    --elex-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    --elex-radius: 24px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: "IRANSansX", "Vazirmatn", system-ui, -apple-system, sans-serif;
    background-color: var(--elex-bg);
    color: var(--elex-text);
}

/* Full-page wrapper */
.elex-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100vh;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: var(--elex-bg);
    padding: 20px;
    z-index: 999999;
    overflow-y: auto;
}

.elex-wrapper {
    height: 100dvh;
    min-height: 100dvh;
}

@supports (height: 100svh) {
    .elex-wrapper {
        height: 100svh;
        min-height: 100svh;
    }
}

.ida-login-shell {
    width: 100vw;
    margin: 0;
    padding: 0;
    min-height: 100%;
    height: 100dvh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(680px 460px at 55% 12%, rgba(255, 255, 255, 0.65) 0%, rgba(255, 255, 255, 0) 70%),
        radial-gradient(520px 420px at 18% 28%, rgba(120, 166, 214, 0.28) 0%, rgba(120, 166, 214, 0) 72%),
        radial-gradient(680px 520px at 85% 75%, rgba(96, 136, 196, 0.22) 0%, rgba(96, 136, 196, 0) 75%),
        linear-gradient(135deg, #dbe9fb 0%, #cbdcf4 38%, #c1d3f0 62%, #b6c7ea 100%);
    font-family: "Vazirmatn", "IRANYekan", "IranYekan", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
    color: #0f172a;
    line-height: 2;
    overflow-x: hidden;
    box-sizing: border-box;
}

@supports (height: 100svh) {
    .ida-login-shell {
        height: 100svh;
        min-height: 100svh;
    }
}

.ida-login-shell *,
.ida-login-shell *::before,
.ida-login-shell *::after {
    box-sizing: border-box;
}

.ida-login-grid {
    width: 100%;
    max-width: 1180px;
    margin-inline: auto;
    padding-inline: clamp(16px, 3vw, 24px);
    padding-block: clamp(16px, 3vw, 32px);
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: clamp(24px, 3.5vw, 40px);
    align-items: center;
}

.ida-login-top,
.ida-login-bottom {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.ida-login-form {
    width: 100%;
    max-width: 620px;
    display: flex;
    justify-content: center;
}

.ida-login-shell .elex-card,
.ida-onboard-card {
    width: 100%;
    max-width: 720px;
    background: rgba(255, 255, 255, 0.97);
    border-radius: 24px;
    padding: clamp(20px, 3vw, 32px);
    box-shadow: 0 18px 44px rgba(15, 23, 42, 0.16);
    text-align: right;
}

.ida-login-shell .elex-card {
    max-width: 620px;
}

.ida-onboard-title {
    margin: 0 0 8px;
    font-size: clamp(18px, 2.2vw, 24px);
    font-weight: 700;
    color: #0f172a;
}

.ida-onboard-intro {
    margin: 0 0 16px;
    color: #475569;
    font-size: clamp(14px, 1.7vw, 16px);
}

.ida-onboard-steps {
    list-style: none;
    margin: 0;
    padding: 0;
    counter-reset: ida-step;
}

.ida-onboard-steps li {
    position: relative;
    padding-right: 52px;
    margin-bottom: 12px;
    color: #111827;
    font-size: clamp(14px, 1.7vw, 16px);
}

.ida-onboard-steps li::before {
    counter-increment: ida-step;
    content: counter(ida-step);
    position: absolute;
    right: 0;
    top: 0.1em;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #1f5fa3;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
}

.ida-onboard-steps li:last-child {
    margin-bottom: 0;
}

@media (max-width: 1199px) {
    .ida-login-grid {
        max-width: 1100px;
        gap: clamp(20px, 3vw, 32px);
    }

    .ida-login-shell .elex-card {
        max-width: 560px;
    }

    .ida-onboard-card {
        max-width: 660px;
    }
}

@media (max-width: 991px) {
    .ida-login-shell {
        align-items: flex-start;
    }

    .ida-login-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
}

@media (max-height: 750px) {
    .ida-login-shell {
        align-items: flex-start;
    }

    .ida-login-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
}

@media (max-width: 767px) {
    .ida-login-shell .elex-card,
    .ida-onboard-card {
        border-radius: 20px;
        padding: 20px;
    }

    .ida-onboard-steps li {
        padding-right: 46px;
    }

    .ida-onboard-steps li::before {
        width: 30px;
        height: 30px;
        font-size: 13px;
    }
}

body.dark .ida-login-shell {
    color: #e2e8f0;
    background:
        radial-gradient(700px 500px at 55% 12%, rgba(148, 163, 184, 0.18) 0%, rgba(148, 163, 184, 0) 70%),
        radial-gradient(520px 420px at 18% 28%, rgba(59, 130, 246, 0.22) 0%, rgba(59, 130, 246, 0) 72%),
        radial-gradient(700px 520px at 85% 75%, rgba(30, 64, 175, 0.24) 0%, rgba(30, 64, 175, 0) 75%),
        linear-gradient(135deg, #0f1b33 0%, #0e2442 45%, #0b1e35 100%);
}

body.dark .ida-login-shell .elex-card,
body.dark .ida-onboard-card {
    background: rgba(15, 23, 42, 0.92);
    border: 1px solid rgba(148, 163, 184, 0.22);
    box-shadow: 0 20px 45px rgba(0, 0, 0, 0.45);
}

body.dark .ida-onboard-title {
    color: #e2e8f0;
}

body.dark .ida-onboard-intro {
    color: #cbd5e1;
}

body.dark .ida-onboard-steps li {
    color: #e2e8f0;
}

body.dark .ida-onboard-steps li::before {
    background: #3b82f6;
    color: #ffffff;
}

body.dark .ida-login-shell .elex-title,
body.dark .ida-login-shell .elex-label {
    color: #f8fafc;
}

@media (prefers-color-scheme: dark) {
    .ida-login-shell {
        color: #e2e8f0;
        background:
            radial-gradient(700px 500px at 55% 12%, rgba(148, 163, 184, 0.18) 0%, rgba(148, 163, 184, 0) 70%),
            radial-gradient(520px 420px at 18% 28%, rgba(59, 130, 246, 0.22) 0%, rgba(59, 130, 246, 0) 72%),
            radial-gradient(700px 520px at 85% 75%, rgba(30, 64, 175, 0.24) 0%, rgba(30, 64, 175, 0) 75%),
            linear-gradient(135deg, #0f1b33 0%, #0e2442 45%, #0b1e35 100%);
    }

    .ida-login-shell .elex-card,
    .ida-onboard-card {
        background: rgba(15, 23, 42, 0.92);
        border: 1px solid rgba(148, 163, 184, 0.22);
        box-shadow: 0 20px 45px rgba(0, 0, 0, 0.45);
    }

    .ida-onboard-title {
        color: #e2e8f0;
    }

    .ida-onboard-intro {
        color: #cbd5e1;
    }

    .ida-onboard-steps li {
        color: #e2e8f0;
    }

    .ida-onboard-steps li::before {
        background: #3b82f6;
        color: #ffffff;
    }

    .ida-login-shell .elex-title,
    .ida-login-shell .elex-label {
        color: #f8fafc;
    }
}

.elex-login-wrapper {
    background-color: transparent;
}

.elex-auth-bg {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    z-index: 0;
    pointer-events: none;
}

.elex-auth-bg-layer {
    position: absolute;
    inset: 0;
    background-position: center;
    background-size: cover;
    background-repeat: no-repeat;
    opacity: 0;
    transition: opacity 1s ease;
}

.elex-auth-bg-layer.is-active {
    opacity: 1;
}

/* Card container */
.elex-card {
    background: var(--elex-bg);
    border-radius: var(--elex-radius);
    box-shadow: var(--elex-shadow);
    padding: 32px 24px;
    width: 100%;
    max-width: 420px;
    direction: rtl;
    position: relative;
    z-index: 1;
}

/* Title */
.elex-title {
    font-size: 22px;
    font-weight: bold;
    margin: 0 0 24px 0;
    text-align: center;
    color: var(--elex-text);
}

/* Form group */
.elex-form-group {
    margin-bottom: 20px;
}

.elex-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--elex-text);
}

/* Tabs for role selection */
.elex-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.elex-tab {
    flex: 1;
    padding: 10px 16px;
    border: 1px solid var(--elex-border);
    border-radius: 12px;
    background: var(--elex-bg);
    color: var(--elex-text);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.elex-tab:hover {
    border-color: var(--elex-primary);
}

.elex-tab.active {
    background: var(--elex-primary);
    border-color: var(--elex-primary);
    color: #ffffff;
}

/* Input fields */
.elex-input {
    width: 100%;
    padding: 14px 18px;
    border: 1px solid var(--elex-border);
    border-radius: 12px;
    font-size: 15px;
    font-family: inherit;
    background: var(--elex-bg);
    color: var(--elex-text);
    transition: all 0.2s ease;
}

.elex-input:focus {
    outline: none;
    border-color: var(--elex-primary);
    box-shadow: 0 0 0 3px rgba(48, 86, 211, 0.1);
}

.elex-input-pill {
    border-radius: 50px;
    text-align: center;
    direction: ltr;
    font-variant-numeric: tabular-nums;
}

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

/* OTP boxes */
.elex-otp-boxes {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin: 16px 0;
    direction: ltr !important;
}

.elex-otp-box {
    width: 46px;
    height: 46px;
    border: 2px solid var(--elex-border);
    border-radius: 8px;
    text-align: center;
    font-size: 20px;
    font-weight: 600;
    font-family: inherit;
    background: var(--elex-bg);
    color: var(--elex-text);
    direction: ltr !important;
    transition: all 0.2s ease;
}

.elex-otp-box:focus {
    outline: none;
    border-color: var(--elex-primary);
    box-shadow: 0 0 0 3px rgba(48, 86, 211, 0.1);
}

/* Buttons */
.elex-btn {
    width: 100%;
    padding: 14px 24px;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

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

.elex-btn-primary {
    background: var(--elex-primary);
    color: #ffffff;
}

.elex-btn-primary:hover:not(:disabled) {
    background: var(--elex-primary-hover);
}

.elex-btn-success {
    background: var(--elex-success);
    color: #ffffff;
}

.elex-btn-success:hover:not(:disabled) {
    background: #16a34a;
}

/* Toast messages */
.elex-toast {
    margin-top: 16px;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    display: none;
}

.elex-toast-success {
    background: var(--elex-success);
    color: #ffffff;
}

.elex-toast-error {
    background: var(--elex-error);
    color: #ffffff;
}

/* Steps */
.elex-step {
    animation: fadeIn 0.3s ease;
}

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

/* Login logs table */
.elex-logs-wrapper {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    direction: rtl;
}

.elex-logs-table-wrapper {
    overflow-x: auto;
}

.elex-logs-wrapper h2 {
    font-size: 22px;
    font-weight: bold;
    margin-bottom: 20px;
    color: var(--elex-text);
}

.elex-logs-table {
    width: 100%;
    border-collapse: collapse;
    background: #1f2937;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--elex-shadow);
}

.elex-logs-table thead {
    background: #111827;
}

.elex-logs-table th {
    padding: 12px 16px;
    text-align: right;
    font-size: 14px;
    font-weight: 600;
    color: #ffffff;
    border-bottom: 2px solid #374151;
    white-space: nowrap;
}

.elex-logs-table td {
    padding: 12px 16px;
    text-align: right;
    font-size: 13px;
    color: #d1d5db;
    border-bottom: 1px solid #374151;
    white-space: nowrap;
}

.elex-logs-table tbody tr:hover {
    background: #374151;
}

.elex-logs-table tbody tr:last-child td {
    border-bottom: none;
}

/* Pagination */
.elex-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 24px;
    flex-wrap: wrap;
}

.elex-pagination-link {
    padding: 8px 16px;
    border: 1px solid var(--elex-border);
    border-radius: 8px;
    background: var(--elex-bg);
    color: var(--elex-text);
    text-decoration: none;
    font-size: 14px;
    transition: all 0.2s ease;
}

.elex-pagination-link:hover {
    border-color: var(--elex-primary);
    color: var(--elex-primary);
}

.elex-pagination-current {
    padding: 8px 16px;
    border: 1px solid var(--elex-primary);
    border-radius: 8px;
    background: var(--elex-primary);
    color: #ffffff;
    font-size: 14px;
    font-weight: 600;
}

/* Fullscreen auth pages */
html.elex-auth-fullpage,
html.elex-auth-fullpage body,
body.elex-auth-fullpage {
    margin: 0;
    padding: 0;
    height: 100%;
    width: 100%;
    overflow: hidden;
    background-color: var(--elex-bg);
}

body.elex-auth-fullpage .site-header,
body.elex-auth-fullpage header,
body.elex-auth-fullpage .site-footer,
body.elex-auth-fullpage footer,
body.elex-auth-fullpage .widget-area,
body.elex-auth-fullpage #secondary,
body.elex-auth-fullpage aside,
body.elex-auth-fullpage .sidebar {
    display: none !important;
}

body.elex-auth-fullpage .site-content,
body.elex-auth-fullpage #content,
body.elex-auth-fullpage .content-area {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    margin: 0;
    overflow: hidden;
}

body.elex-auth-fullpage .elex-wrapper:not(.ida-login-shell) {
    position: relative;
    z-index: 1;
    height: 100%;
    overflow-y: auto;
}

body.elex-auth-fullpage .elex-card {
    max-width: 420px;
    width: 100%;
}

/* Logout button */
.elex-btn-ghost {
    background: transparent;
    border: 1px solid var(--elex-border);
    color: var(--elex-text);
}

.elex-btn-ghost:hover {
    background: var(--elex-border);
}

.elex-support-link {
    margin-top: 12px;
}

.elex-support-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    color: #666;
    border-color: #ddd;
    text-decoration: none;
}

.ida-elex-modal-overlay {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: clamp(16px, 4vw, 28px);
    background: rgba(15, 23, 42, 0.55);
    z-index: 1000000;
    overflow-y: auto;
    min-height: 100vh;
    min-height: 100dvh;
}

@supports (height: 100svh) {
    .ida-elex-modal-overlay {
        min-height: 100svh;
    }
}

.ida-elex-modal-overlay.is-active {
    display: flex;
}

.ida-elex-modal {
    width: min(92vw, 780px);
    background: rgba(255, 255, 255, 0.98);
    border-radius: 24px;
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.24);
    padding: clamp(20px, 3vw, 28px);
    text-align: right;
    color: #0f172a;
}

.ida-elex-modal__header h3 {
    margin: 0;
    font-size: clamp(18px, 2.2vw, 22px);
    font-weight: 700;
}

.ida-elex-modal__body {
    margin-top: 12px;
    max-height: 70vh;
    max-height: 70dvh;
    overflow-y: auto;
    padding-inline-end: 4px;
    line-height: 2;
    color: #1f2937;
}

@supports (height: 100svh) {
    .ida-elex-modal__body {
        max-height: 70svh;
    }
}

.ida-elex-modal__list {
    margin: 0;
    padding: 0 18px 0 0;
    list-style: disc;
}

.ida-elex-modal__list li {
    margin-bottom: 10px;
    font-size: clamp(14px, 1.8vw, 16px);
}

.ida-elex-modal__list li:last-child {
    margin-bottom: 0;
}

.ida-elex-modal__footer {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ida-elex-modal__accept,
.ida-elex-modal__support {
    width: 100%;
    border-radius: 14px;
    padding: 14px 20px;
    font-size: 15px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
}

.ida-elex-modal__accept {
    background: var(--elex-primary);
    color: #ffffff;
}

.ida-elex-modal__accept:hover {
    background: var(--elex-primary-hover);
}

.ida-elex-modal__support {
    background: #ffffff;
    border: 1px solid var(--elex-border);
    color: #1f2937;
}

.ida-elex-modal__support:disabled,
.ida-elex-modal__support[aria-disabled="true"] {
    opacity: 0.6;
    cursor: not-allowed;
}

@media (min-width: 768px) {
    .ida-elex-modal__footer {
        flex-direction: row;
    }

    .ida-elex-modal__accept,
    .ida-elex-modal__support {
        width: auto;
        flex: 1;
    }
}

body.ida-elex-modal-open {
    overflow: hidden;
}

body.dark .ida-elex-modal-overlay {
    background: rgba(2, 6, 23, 0.7);
}

body.dark .ida-elex-modal {
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid rgba(148, 163, 184, 0.2);
    color: #e2e8f0;
    box-shadow: 0 24px 55px rgba(0, 0, 0, 0.45);
}

body.dark .ida-elex-modal__body {
    color: #e2e8f0;
}

body.dark .ida-elex-modal__support {
    background: rgba(15, 23, 42, 0.6);
    border-color: rgba(148, 163, 184, 0.3);
    color: #e2e8f0;
}

@media (prefers-color-scheme: dark) {
    .ida-elex-modal-overlay {
        background: rgba(2, 6, 23, 0.7);
    }

    .ida-elex-modal {
        background: rgba(15, 23, 42, 0.95);
        border: 1px solid rgba(148, 163, 184, 0.2);
        color: #e2e8f0;
        box-shadow: 0 24px 55px rgba(0, 0, 0, 0.45);
    }

    .ida-elex-modal__body {
        color: #e2e8f0;
    }

    .ida-elex-modal__support {
        background: rgba(15, 23, 42, 0.6);
        border-color: rgba(148, 163, 184, 0.3);
        color: #e2e8f0;
    }
}

.elex-logs-actions {
    margin: 12px 0 20px;
    display: flex;
    justify-content: flex-end;
}

.elex-reset-details {
    margin-inline-start: 8px;
    padding: 2px 8px;
    border-radius: 999px;
    border: 1px solid #c7d4e8;
    background: #f7fbff;
    color: #1a4b7a;
    font-size: 12px;
    cursor: pointer;
}

.elex-device-status-panel {
    margin: 24px 0;
    padding: 16px 18px;
    border: 1px solid var(--elex-border);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.85);
}

.elex-device-status-message {
    margin-top: 8px;
    font-size: 0.9rem;
    color: #666;
}

.elex-device-status-message.is-error {
    color: #a31313;
}

.elex-device-status-message.is-success {
    color: #0b6b2e;
}

.elex-device-status-message.is-info {
    color: #225a8f;
}

.elex-btn-danger {
    background: #d63b3b;
    color: #fff;
    border: none;
}

.elex-btn-danger:hover {
    background: #bf2d2d;
}

.elex-reset-modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(10, 22, 40, 0.45);
    z-index: 9999;
}

.elex-reset-modal.is-active {
    display: flex;
}

.elex-reset-modal-content {
    width: min(520px, 92vw);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    padding: 16px 18px;
}

.elex-reset-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.elex-reset-modal-close {
    border: none;
    background: transparent;
    font-size: 20px;
    cursor: pointer;
    line-height: 1;
}

/* Responsive */
@media (max-width: 480px) {
    .elex-card {
        padding: 24px 20px;
        border-radius: 20px;
    }

    .elex-title {
        font-size: 20px;
    }

    .elex-otp-box {
        width: 42px;
        height: 42px;
        font-size: 18px;
    }

    .elex-otp-boxes {
        gap: 8px;
    }

    .elex-logs-table {
        font-size: 12px;
    }

    .elex-logs-table th,
    .elex-logs-table td {
        padding: 8px 12px;
    }
}
