/* ==========================================================================
   OXIRA PUBLIC CLIENT PORTAL - PURE OLED BLACK & MONOCHROME STEEL UI (v1.0)
   Lightweight, 60fps Mobile-First Stylesheet for 3,000+ Subscribers
   ========================================================================== */

@font-face {
    font-family: 'Vazirmatn';
    src: url('/static/vazirmatn.woff2') format('woff2');
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

:root {
    --bg-base: #000000;
    --bg-surface: #0a0a0c;
    --bg-elevated: #121216;
    --bg-subtle: #070709;
    --bg-hover: #18181d;

    --border-color: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.16);
    --rim-highlight: inset 0 1px 0 rgba(255, 255, 255, 0.07);

    --accent: #f4f4f5;
    --accent-hover: #ffffff;
    --accent-ink: #09090b;
    --accent-soft: rgba(244, 244, 245, 0.10);
    --accent-text: #e4e4e7;

    --steel: #a1a1aa;

    --success: #10b981;
    --success-soft: rgba(16, 185, 129, 0.14);
    --success-text: #34d399;

    --warning: #f59e0b;
    --warning-soft: rgba(245, 158, 11, 0.14);
    --warning-text: #fbbf24;

    --danger: #ef4444;
    --danger-hover: #dc2626;
    --danger-soft: rgba(239, 68, 68, 0.14);
    --danger-text: #f87171;

    --text-main: #fafafa;
    --text-secondary: #d4d4d8;
    --text-muted: #8e8e98;
    --text-dim: #52525b;

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.55);
    --shadow-lg: 0 18px 44px rgba(0, 0, 0, 0.90);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 22px;
    --radius-full: 9999px;

    --font-family: 'Vazirmatn', -apple-system, BlinkMacSystemFont, 'Segoe UI', Tahoma, Roboto, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
    --ease-spring: cubic-bezier(0.22, 1, 0.36, 1);
    --transition: all 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    width: 100%;
    min-height: 100%;
    background-color: var(--bg-base);
    color: var(--text-main);
    font-family: var(--font-family);
    font-size: 14px;
    line-height: 1.6;
    direction: rtl;
    text-align: right;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

button, input, select, textarea {
    font-family: var(--font-family);
    color: inherit;
}

body {
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
}

.ltr-text {
    direction: ltr;
    unicode-bidi: isolate;
}

.ltr-block {
    direction: ltr !important;
    text-align: left !important;
}

.ltr-input {
    direction: ltr !important;
    text-align: left !important;
}

.ltr-input::placeholder {
    direction: ltr;
    text-align: left;
    color: var(--text-dim);
}

code {
    font-family: var(--font-mono);
    font-size: 11.5px;
    background-color: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 2px 7px;
    border-radius: 6px;
    color: var(--accent-text);
    direction: ltr;
    display: inline-block;
}

/* Progress Bar & Pull-to-Refresh */
.top-progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    height: 2.5px;
    width: 0%;
    background: linear-gradient(90deg, #a1a1aa, #fafafa, #10b981);
    z-index: 10001;
    opacity: 0;
    pointer-events: none;
    transition: width 0.26s var(--ease-spring), opacity 0.2s ease;
}

.top-progress-bar.loading {
    opacity: 1;
    width: 78%;
}

.top-progress-bar.done {
    opacity: 1;
    width: 100%;
}

.ptr-indicator {
    position: fixed;
    top: calc(env(safe-area-inset-top, 0px) + 8px);
    left: 50%;
    transform: translate(-50%, -60px);
    background-color: #141418;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-full);
    padding: 6px 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text-secondary);
    z-index: 9990;
    opacity: 0;
    pointer-events: none;
    transition: transform 0.2s var(--ease-spring), opacity 0.2s ease;
}

.ptr-indicator.visible {
    opacity: 1;
}

.ptr-spinner {
    width: 13px;
    height: 13px;
    border: 2px solid rgba(255, 255, 255, 0.16);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

/* Loader Overlay */
.loader-overlay {
    position: fixed;
    inset: 0;
    background-color: var(--bg-base);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    gap: 14px;
}

.loader-ring {
    position: relative;
    width: 46px;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.loader-ring::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.08);
    border-bottom-color: var(--steel);
    animation: spinReverse 1.2s linear infinite;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 2.5px solid rgba(255, 255, 255, 0.08);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
}

.loader-text {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
}

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

.anim-card {
    animation: cardReveal 0.36s var(--ease-spring) backwards;
    animation-delay: var(--delay, 0s);
}

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

/* Toasts */
.toast-container {
    position: fixed;
    top: calc(env(safe-area-inset-top, 0px) + 12px);
    left: 14px;
    right: 14px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    pointer-events: none;
}

.toast {
    width: 100%;
    max-width: 460px;
    background-color: #141418;
    color: var(--text-main);
    padding: 11px 14px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg), var(--rim-highlight);
    border: 1px solid var(--border-strong);
    font-size: 12.5px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 9px;
    animation: toastIn 0.28s var(--ease-spring);
    pointer-events: auto;
}

.toast-success { border-right: 3px solid var(--success); }
.toast-error   { border-right: 3px solid var(--danger); }
.toast-warning { border-right: 3px solid var(--warning); }
.toast-info    { border-right: 3px solid var(--accent); }

@keyframes toastIn {
    from { transform: translateY(-14px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Main Container & Header */
.app-container {
    max-width: 540px;
    margin: 0 auto;
    padding: 12px 14px;
}

.app-header {
    background-color: var(--bg-surface);
    padding: 12px 15px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm), var(--rim-highlight);
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.header-branding {
    display: flex;
    align-items: center;
    gap: 11px;
}

.brand-logo {
    width: 38px;
    height: 38px;
    background: linear-gradient(145deg, #1b1b21, #0e0e12);
    color: var(--accent);
    border: 1px solid var(--border-strong);
    box-shadow: var(--rim-highlight);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.brand-details {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.brand-title {
    font-size: 14.5px;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.25;
}

.header-status-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.live-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background-color: var(--success);
    display: inline-block;
    flex-shrink: 0;
}

.btn-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    background-color: var(--bg-elevated);
    border: 1px solid var(--border-color);
    box-shadow: var(--rim-highlight);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.btn-icon:active { transform: scale(0.92); }
.btn-icon.spinning svg { animation: spin 0.65s linear infinite; }

/* Badges & Text Helpers */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 9px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-primary {
    background-color: var(--accent-soft);
    color: var(--accent-text);
    border: 1px solid rgba(255, 255, 255, 0.1);
}
.badge-success { background-color: var(--success-soft); color: var(--success-text); }
.badge-warning { background-color: var(--warning-soft); color: var(--warning-text); }
.badge-danger  { background-color: var(--danger-soft);  color: var(--danger-text); }

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

/* Cards */
.card {
    background-color: var(--bg-surface);
    border-radius: var(--radius-lg);
    padding: 16px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm), var(--rim-highlight);
    margin-bottom: 12px;
}

/* Login Card */
.login-card {
    text-align: center;
    padding: 26px 18px 22px 18px;
}

.login-icon-wrap {
    width: 54px;
    height: 54px;
    margin: 0 auto 14px auto;
    border-radius: var(--radius-lg);
    background-color: var(--bg-elevated);
    border: 1px solid var(--border-strong);
    box-shadow: var(--rim-highlight);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
}

.login-card h2 {
    font-size: 17px;
    font-weight: 700;
    margin-bottom: 7px;
}

.login-card p {
    color: var(--text-muted);
    font-size: 12.5px;
    line-height: 1.65;
    margin-bottom: 20px;
}

/* Forms & Buttons */
.form-group {
    margin-bottom: 14px;
    text-align: right;
}

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

.form-control {
    width: 100%;
    height: 42px;
    padding: 8px 13px;
    font-size: 13.5px;
    color: var(--text-main);
    background-color: var(--bg-elevated);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    outline: none;
    transition: var(--transition);
}

.form-control:focus {
    background-color: #16161c;
    border-color: rgba(244, 244, 245, 0.45);
    box-shadow: 0 0 0 3px rgba(244, 244, 245, 0.08);
}

.password-input-wrap {
    position: relative;
}

.password-input-wrap .form-control {
    padding-right: 40px;
}

.pwd-eye-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.input-with-button {
    display: flex;
    gap: 8px;
    align-items: center;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 41px;
    padding: 0 14px;
    font-size: 13px;
    font-weight: 600;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
    background-color: var(--accent);
    color: var(--accent-ink);
    font-weight: 700;
    box-shadow: 0 2px 10px rgba(255, 255, 255, 0.12);
}

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

.btn-outline {
    background-color: var(--bg-elevated);
    border-color: var(--border-strong);
    box-shadow: var(--rim-highlight);
    color: var(--text-main);
}

.btn-danger-outline {
    background-color: var(--danger-soft);
    border-color: rgba(239, 68, 68, 0.28);
    color: var(--danger-text);
}

.btn-block { width: 100%; }

.btn-sm {
    height: 36px;
    padding: 0 12px;
    font-size: 12px;
    border-radius: 10px;
}

.btn-xs {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 28px;
    padding: 0 10px;
    font-size: 11px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    background-color: var(--bg-elevated);
    border: 1px solid var(--border-strong);
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
}

/* Dashboard Summary & Quota Gauge */
.subscriber-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 13px;
    margin-bottom: 15px;
}

.sub-label {
    font-size: 11.5px;
    color: var(--text-muted);
    display: block;
}

.sub-name {
    font-size: 20px;
    font-weight: 800;
    color: var(--text-main);
}

.quota-meter-box {
    background-color: var(--bg-elevated);
    border-radius: var(--radius-md);
    padding: 14px;
    margin-bottom: 15px;
    border: 1px solid var(--border-color);
    box-shadow: var(--rim-highlight);
}

.quota-labels {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12.5px;
    font-weight: 600;
    margin-bottom: 8px;
}

.progress-bar-container {
    width: 100%;
    height: 9px;
    background-color: rgba(255, 255, 255, 0.07);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-bottom: 13px;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #a1a1aa, #f4f4f5);
    border-radius: var(--radius-full);
    transition: width 0.5s var(--ease-spring);
}

.progress-bar-fill.warn { background: linear-gradient(90deg, #d97706, #fbbf24); }
.progress-bar-fill.danger { background: linear-gradient(90deg, #dc2626, #f87171); }

.quota-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 7px;
    text-align: center;
}

.stat-item {
    background-color: var(--bg-surface);
    padding: 8px 5px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.highlight-stat {
    border-color: rgba(16, 185, 129, 0.25);
    background-color: rgba(16, 185, 129, 0.05);
}

.stat-title {
    font-size: 10.5px;
    color: var(--text-muted);
}

.stat-num {
    font-size: 12.5px;
    font-weight: 700;
    color: var(--text-main);
}

.metadata-list {
    display: flex;
    flex-direction: column;
    gap: 9px;
    margin-bottom: 16px;
}

.meta-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    padding-bottom: 9px;
    border-bottom: 1px solid var(--border-color);
}

.meta-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.meta-label { color: var(--text-muted); }
.meta-val { font-weight: 600; color: var(--text-main); }

.client-actions-grid {
    display: flex;
    flex-direction: column;
    gap: 9px;
}

.two-col-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

/* Setup Guide */
.client-guide-box {
    margin-top: 14px;
    border-top: 1px solid var(--border-color);
    padding-top: 12px;
}

.client-guide-toggle {
    width: 100%;
    background-color: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 10px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12.5px;
    font-weight: 700;
    cursor: pointer;
}

.client-guide-body {
    margin-top: 8px;
    background-color: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px 14px;
}

.guide-steps-list {
    padding-right: 18px;
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.75;
    margin-bottom: 10px;
}

.guide-apps-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
}

/* Bottom-Sheet Modals */
.modal-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.84);
    display: none;
    align-items: flex-end;
    justify-content: center;
    z-index: 9998;
}

@media (min-width: 600px) {
    .modal-overlay {
        align-items: center;
        padding: 16px;
    }
}

.modal-overlay.active {
    display: flex;
}

.modal-box {
    background-color: var(--bg-surface);
    width: 100%;
    max-width: 500px;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    box-shadow: var(--shadow-lg), var(--rim-highlight);
    border: 1px solid var(--border-strong);
    border-bottom: none;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    animation: sheetSlideUp 0.3s var(--ease-spring);
    overflow: hidden;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

.modal-box::before {
    content: "";
    width: 38px;
    height: 4px;
    background-color: rgba(255, 255, 255, 0.22);
    border-radius: var(--radius-full);
    margin: 9px auto 0 auto;
    flex-shrink: 0;
}

@media (min-width: 600px) {
    .modal-box {
        border-radius: var(--radius-lg);
        border-bottom: 1px solid var(--border-strong);
    }
    .modal-box::before { display: none; }
    .modal-sm { max-width: 390px; }
}

@keyframes sheetSlideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.modal-header {
    padding: 13px 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    margin: 0;
    font-size: 14.5px;
    font-weight: 700;
}

.modal-close {
    width: 30px;
    height: 30px;
    border-radius: var(--radius-full);
    background-color: var(--bg-elevated);
    border: 1px solid var(--border-color);
    font-size: 18px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.modal-body {
    padding: 15px 16px;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.modal-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
    background-color: var(--bg-subtle);
}

/* Protocol Tabs inside Configs Modal */
.proto-tabs-bar {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 5px;
    background-color: var(--bg-elevated);
    padding: 4px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    margin-bottom: 14px;
}

.proto-tab-btn {
    height: 32px;
    padding: 0 4px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: var(--transition);
}

.proto-tab-btn.active {
    background-color: var(--accent);
    color: var(--accent-ink);
}

.proto-pane { display: none; }
.proto-pane.active { display: block; }

.empty-note {
    text-align: center;
    font-size: 12.5px;
    color: var(--text-muted);
    padding: 22px 12px;
    background-color: var(--bg-elevated);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-md);
}

.qr-box {
    background-color: #ffffff;
    border-radius: var(--radius-md);
    padding: 12px;
    width: 196px;
    height: 196px;
    margin: 0 auto 8px auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

.qr-box svg {
    width: 100%;
    height: 100%;
    display: block;
}

.qr-hint {
    text-align: center;
    font-size: 11.5px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.field-mini-label {
    display: block;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.code-textarea {
    height: 120px;
    font-family: var(--font-mono);
    font-size: 11px;
    resize: none;
    background-color: #050507;
}

.sub-link-card {
    background-color: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 11px 12px;
    margin-bottom: 9px;
}

.inline-qr-wrap {
    margin-top: 9px;
    padding: 12px;
    background-color: #ffffff;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
}

.inline-qr-wrap svg {
    width: 160px;
    height: 160px;
    display: block;
}

.manual-servers-list {
    display: flex;
    flex-direction: column;
    gap: 9px;
}

.srv-clean-card {
    background-color: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 11px 13px;
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.srv-clean-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.srv-clean-title {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 13px;
    font-weight: 700;
}

.srv-kv-list {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.srv-kv-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: 12px;
    padding: 5px 8px;
    border-radius: 7px;
    background-color: rgba(0, 0, 0, 0.32);
    cursor: pointer;
}

.srv-kv-row:active {
    background-color: rgba(255, 255, 255, 0.08);
}

.srv-kv-key {
    color: var(--text-muted);
    font-size: 11px;
}

.srv-kv-val {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 12px;
    color: var(--text-main);
}

.flex-between { display: flex; align-items: center; justify-content: space-between; }
.mt-2 { margin-top: 8px; }
