/* ================================================================
   OTC Brokerage System — Design System
   واحد پول: تومان | زبان: فارسی | جهت: RTL
   ================================================================ */

/* ─── Variables ──────────────────────────────────────────────── */
:root {
    --font: 'Vazirmatn', system-ui, sans-serif;

    /* رنگ‌های اصلی */
    --primary:       #1B4F8A;
    --primary-hover: #153D6B;
    --primary-light: #EBF2FB;

    /* سطح‌ها */
    --bg:         #F4F6F9;
    --surface:    #FFFFFF;
    --surface-2:  #F8FAFC;

    /* متن */
    --text:       #1A1D23;
    --text-muted: #6B7280;
    --text-light: #9CA3AF;

    /* حاشیه */
    --border:      #E5E7EB;
    --border-focus: #1B4F8A;

    /* وضعیت‌ها */
    --success:      #0D7A4E;
    --success-bg:   #ECFDF5;
    --error:        #C0392B;
    --error-bg:     #FEF2F2;
    --warning:      #92540A;
    --warning-bg:   #FFFBEB;
    --info:         #1B4F8A;
    --info-bg:      #EBF2FB;

    /* Sidebar */
    --sidebar-w:    240px;
    --sidebar-bg:   #0F2744;
    --sidebar-text: #B8C7DC;
    --sidebar-hover:#1B4F8A;
    --sidebar-active:#2563EB;

    /* Layout */
    --topbar-h:  56px;
    --radius:    8px;
    --radius-lg: 12px;

    /* Shadow */
    --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,.10);
}

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

html { font-size: 15px; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    direction: rtl;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── Layout: Sidebar + Main ─────────────────────────────────── */
.sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    z-index: 100;
    transition: transform .25s ease;
}

.main-wrapper {
    margin-right: var(--sidebar-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ─── Sidebar Header ─────────────────────────────────────────── */
.sidebar-header {
    padding: 1.25rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,.08);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: .625rem;
}

.sidebar-logo-icon {
    font-size: 1.5rem;
    color: #4B9FE1;
}

.sidebar-logo-text {
    font-size: .9375rem;
    font-weight: 600;
    color: #FFFFFF;
    letter-spacing: .01em;
}

/* ─── Sidebar Nav ────────────────────────────────────────────── */
.sidebar-nav {
    flex: 1;
    padding: .75rem 0;
}

.nav-group {
    margin-bottom: .5rem;
}

.nav-group-label {
    padding: .5rem 1rem .25rem;
    font-size: .6875rem;
    font-weight: 600;
    color: var(--sidebar-text);
    opacity: .6;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: .625rem;
    padding: .5rem 1rem;
    color: var(--sidebar-text);
    font-size: .875rem;
    border-radius: 0;
    transition: background .15s, color .15s;
    text-decoration: none;
    cursor: pointer;
}

.nav-item:hover {
    background: rgba(255,255,255,.06);
    color: #FFFFFF;
    text-decoration: none;
}

.nav-item.active {
    background: var(--sidebar-active);
    color: #FFFFFF;
}

.nav-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    opacity: .85;
    display: inline-block;
    vertical-align: middle;
}

/* ─── Sidebar Footer ─────────────────────────────────────────── */
.sidebar-footer {
    padding: .75rem 1rem;
    border-top: 1px solid rgba(255,255,255,.08);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: .625rem;
}

.sidebar-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--sidebar-active);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .875rem;
    font-weight: 600;
    flex-shrink: 0;
}

.sidebar-user-info { flex: 1; min-width: 0; }

.sidebar-user-name {
    font-size: .8125rem;
    font-weight: 500;
    color: #FFFFFF;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: .6875rem;
    color: var(--sidebar-text);
    opacity: .7;
}

.btn-icon {
    background: none;
    border: none;
    color: var(--sidebar-text);
    cursor: pointer;
    padding: .25rem;
    font-size: 1rem;
    border-radius: 4px;
    transition: color .15s;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
}

.btn-icon:hover { color: #FFFFFF; }

/* ─── Topbar ─────────────────────────────────────────────────── */
.topbar {
    height: var(--topbar-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 1.25rem;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow-sm);
}

.topbar-menu-btn {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: .25rem;
    border-radius: var(--radius);
    transition: background .15s;
    align-items: center;
}

.topbar-menu-btn:hover { background: var(--bg); }

.topbar-breadcrumb {
    flex: 1;
    font-size: .875rem;
    color: var(--text-muted);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: .75rem;
}

.topbar-date {
    font-size: .8125rem;
    color: var(--text-muted);
    background: var(--bg);
    padding: .25rem .625rem;
    border-radius: 20px;
    border: 1px solid var(--border);
    white-space: nowrap;
}

.topbar-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .8125rem;
    font-weight: 700;
    cursor: default;
    flex-shrink: 0;
}

/* ─── Content ────────────────────────────────────────────────── */
.content {
    flex: 1;
    padding: 1.5rem;
    max-width: 1200px;
    width: 100%;
}

/* ─── Page Header ────────────────────────────────────────────── */
.page-header {
    margin-bottom: 1.5rem;
}

.page-title {
    font-size: 1.375rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: .25rem;
}

.page-subtitle {
    font-size: .875rem;
    color: var(--text-muted);
}

/* ─── Stats Grid ─────────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    transition: box-shadow .15s;
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
}

.stat-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: .875rem;
}

.stat-icon-wrap {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-icon-primary  { background: var(--primary-light); color: var(--primary); }
.stat-icon-success  { background: var(--success-bg);    color: var(--success); }
.stat-icon-error    { background: var(--error-bg);      color: var(--error); }
.stat-icon-warning  { background: var(--warning-bg);    color: var(--warning); }

.stat-trend {
    font-size: .75rem;
    font-weight: 600;
    padding: .2rem .5rem;
    border-radius: 20px;
}

.stat-trend-up      { background: var(--success-bg); color: var(--success); }
.stat-trend-down    { background: var(--error-bg);   color: var(--error); }
.stat-trend-neutral { background: var(--bg);         color: var(--text-light); }

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1;
    margin-bottom: .25rem;
}

.stat-label {
    font-size: .8125rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: .125rem;
}

.stat-hint {
    font-size: .75rem;
    color: var(--text-light);
}

/* ─── Dashboard Grid ─────────────────────────────────────────── */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 1rem;
    align-items: start;
}

/* ─── Card ───────────────────────────────────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-title {
    font-size: .9375rem;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
}

.card-body { padding: 1.25rem; }

/* ─── Empty State ────────────────────────────────────────────── */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .75rem;
    padding: 3rem 1.25rem;
    color: var(--text-muted);
    text-align: center;
}

.empty-state p {
    font-size: .875rem;
    color: var(--text-light);
}

/* ─── Quick Actions ──────────────────────────────────────────── */
.quick-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .625rem;
}

.quick-action-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .5rem;
    padding: .875rem .5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-align: center;
    font-size: .8125rem;
    color: var(--text-muted);
    text-decoration: none;
    transition: border-color .15s, background .15s, color .15s;
}

.quick-action-item:hover {
    border-color: var(--primary);
    background: var(--primary-light);
    color: var(--primary);
    text-decoration: none;
}

.quick-action-icon {
    width: 40px;
    height: 40px;
    background: var(--bg);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    transition: background .15s;
}

.quick-action-item:hover .quick-action-icon {
    background: var(--primary-light);
}

/* ─── Forms ──────────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }

.form-group-inline {
    display: flex;
    align-items: center;
    gap: .5rem;
}

.form-label {
    display: block;
    font-size: .875rem;
    font-weight: 500;
    color: var(--text);
    margin-bottom: .375rem;
}

.form-input {
    width: 100%;
    padding: .5625rem .875rem;
    font-family: var(--font);
    font-size: .9375rem;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    outline: none;
    transition: border-color .15s, box-shadow .15s;
    direction: rtl;
}

.form-input:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(27,79,138,.12);
}

.form-input::placeholder { color: var(--text-light); }

.form-error {
    display: block;
    font-size: .8125rem;
    color: var(--error);
    margin-top: .25rem;
}

.form-hint {
    display: block;
    font-size: .8125rem;
    color: var(--text-muted);
    margin-top: .25rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: .875rem;
    cursor: pointer;
}

/* ─── Input with Icon ────────────────────────────────────────── */
.input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    right: .8125rem;
    width: 16px;
    height: 16px;
    color: var(--text-light);
    pointer-events: none;
    flex-shrink: 0;
}

.form-input-icon {
    padding-right: 2.5rem;
}

/* ─── Buttons ────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .375rem;
    padding: .5625rem 1.125rem;
    font-family: var(--font);
    font-size: .9375rem;
    font-weight: 500;
    border: 1px solid transparent;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background .15s, border-color .15s, opacity .15s;
    white-space: nowrap;
    text-decoration: none;
}

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

.btn-primary {
    background: var(--primary);
    color: #FFFFFF;
}
.btn-primary:hover { background: var(--primary-hover); text-decoration: none; color: #fff; }

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border);
}
.btn-secondary:hover { background: var(--bg); }

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

.btn-full { width: 100%; }

.btn-sm {
    padding: .375rem .75rem;
    font-size: .8125rem;
}

.btn-login {
    height: 46px;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: .01em;
    border-radius: var(--radius);
    margin-top: .25rem;
}

/* ─── Alerts ─────────────────────────────────────────────────── */
.alert {
    display: flex;
    align-items: flex-start;
    gap: .625rem;
    padding: .75rem 1rem;
    border-radius: var(--radius);
    font-size: .875rem;
    margin-bottom: 1rem;
    border: 1px solid transparent;
}

.alert-icon { flex-shrink: 0; font-weight: 600; }

.alert-success {
    background: var(--success-bg);
    color: var(--success);
    border-color: #A7F3D0;
}

.alert-error {
    background: var(--error-bg);
    color: var(--error);
    border-color: #FECACA;
}

.alert-warning {
    background: var(--warning-bg);
    color: var(--warning);
    border-color: #FDE68A;
}

/* ─── Table ──────────────────────────────────────────────────── */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: .875rem;
}

thead {
    background: var(--surface-2);
}

thead th {
    padding: .75rem 1rem;
    font-weight: 600;
    color: var(--text-muted);
    text-align: right;
    font-size: .8125rem;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

tbody td {
    padding: .75rem 1rem;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }

/* ─── Badges ─────────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: .2rem .5rem;
    font-size: .75rem;
    font-weight: 500;
    border-radius: 4px;
    white-space: nowrap;
}

.badge-success { background: var(--success-bg); color: var(--success); }
.badge-error   { background: var(--error-bg);   color: var(--error); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-info    { background: var(--info-bg);    color: var(--info); }
.badge-neutral { background: var(--bg);         color: var(--text-muted); }

/* ─── Notice Box ─────────────────────────────────────────────── */
.notice-box {
    display: flex;
    align-items: flex-start;
    gap: .875rem;
    padding: 1rem 1.25rem;
    background: var(--info-bg);
    border: 1px solid #BFDBFE;
    border-radius: var(--radius-lg);
    font-size: .875rem;
    color: #1E3A5F;
}

.notice-icon {
    font-size: 1.25rem;
    color: var(--primary);
    flex-shrink: 0;
    margin-top: .1rem;
}

/* ─── Login Page — Split Layout ──────────────────────────────── */
.login-body {
    background: var(--bg);
    min-height: 100vh;
    display: flex;
    align-items: stretch;
    padding: 0;
}

.login-split {
    display: flex;
    width: 100%;
    min-height: 100vh;
    flex-direction: row-reverse; /* RTL: form side (right) first */
}

.login-form-side {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2.5rem 1.5rem;
    background: var(--surface);
}

.login-form-inner {
    width: 100%;
    max-width: 380px;
}

.login-brand-mobile {
    display: none;
    align-items: center;
    gap: .625rem;
    margin-bottom: 2rem;
}

.login-brand-name-mobile {
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary);
}

.login-heading {
    font-size: 1.625rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: .375rem;
}

.login-subheading {
    font-size: .875rem;
    color: var(--text-muted);
    margin-bottom: 2rem;
}

.login-footer-note {
    margin-top: 1.75rem;
    text-align: center;
    font-size: .8125rem;
    color: var(--text-light);
}

/* Brand side — dark navy panel */
.login-brand-side {
    width: 420px;
    flex-shrink: 0;
    background: linear-gradient(160deg, #0F2744 0%, #1B4F8A 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem 2.5rem;
}

.login-brand-content {
    color: #FFFFFF;
    max-width: 320px;
}

.login-brand-logo {
    margin-bottom: 2rem;
}

.login-brand-mark {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: rgba(255,255,255,.15);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.login-brand-title {
    font-size: 1.375rem;
    font-weight: 700;
    margin-bottom: .75rem;
    line-height: 1.3;
}

.login-brand-desc {
    font-size: .875rem;
    color: rgba(255,255,255,.7);
    line-height: 1.7;
    margin-bottom: 2rem;
}

.login-brand-features {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: .75rem;
}

.login-brand-features li {
    display: flex;
    align-items: center;
    gap: .625rem;
    font-size: .875rem;
    color: rgba(255,255,255,.85);
}

.login-brand-features li i {
    background: rgba(255,255,255,.2);
    border-radius: 50%;
    padding: 2px;
    flex-shrink: 0;
    color: #fff;
}

/* ─── Utility ────────────────────────────────────────────────── */
.d-inline { display: inline; }
.text-error { color: var(--error); }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }

/* ─── Responsive ─────────────────────────────────────────────── */
@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .login-brand-side {
        width: 360px;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-wrapper {
        margin-right: 0;
    }

    .topbar-menu-btn {
        display: flex;
    }

    .content {
        padding: 1rem;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Login: stack vertically on mobile */
    .login-split {
        flex-direction: column;
    }

    .login-brand-side {
        display: none;
    }

    .login-brand-mobile {
        display: flex;
    }

    .login-form-side {
        align-items: flex-start;
        padding: 2rem 1.25rem;
    }

    .login-form-inner {
        max-width: 100%;
    }

    .topbar-date {
        display: none;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .quick-actions {
        grid-template-columns: repeat(2, 1fr);
    }
}
