/*
 * Application styles: a light dashboard look with a violet accent, on top of Bootstrap 5.
 * LTR and RTL builds of Bootstrap are both loaded by the layout.
 *
 * Only logical properties (inline-start, padding-inline, ...) are used so the layout mirrors
 * automatically when the page direction is RTL.
 */

:root {
    --app-ink: #111111;
    --app-muted: #6b6b6b;
    --app-line: #e9e9e9;
    --app-page: #f4f4f4;
    --app-surface: #ffffff;
    --app-accent: #111111;
    --app-accent-strong: #000000;
    --app-accent-soft: #ededed;
    --app-radius: 1rem;
    --app-sidebar-width: 15rem;
    --app-gutter: 1rem;
    --app-chart-height: 18rem;

    --bs-body-font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Arabic", Tahoma, sans-serif;
    --bs-body-color: var(--app-ink);
    --bs-body-bg: var(--app-page);
    --bs-border-color: var(--app-line);
    --bs-secondary-color: var(--app-muted);
    --bs-link-color: var(--app-accent);
    --bs-link-hover-color: var(--app-accent-strong);
    --bs-focus-ring-color: rgba(17, 17, 17, 0.2);
    --bs-offcanvas-width: var(--app-sidebar-width);
    --bs-offcanvas-bg: #ffffff;
}

body {
    font-size: 0.95rem;
    line-height: 1.55;
    overflow-wrap: anywhere;
}

/* ---------------------------------------------------------------- shell */

.app-body {
    background-color: var(--app-page);
}

.app-shell {
    min-height: 100vh;
}

.app-sidebar {
    background-color: var(--app-surface);
    border-inline-end: 1px solid var(--app-line);
}

@media (min-width: 992px) {
    .app-sidebar {
        position: sticky;
        top: 0;
        height: 100vh;
        flex-shrink: 0;
        width: var(--app-sidebar-width);
    }
}

.app-main {
    min-width: 0;
}

.app-topbar {
    background-color: transparent;
    padding: 0.75rem 0.75rem 0;
}

@media (min-width: 992px) {
    .app-topbar {
        padding: var(--app-gutter) var(--app-gutter) 0;
    }
}

/* Main content: a compact gutter that uses the available width. */
.app-content {
    width: 100%;
    max-width: none;
    padding: 1rem 0.75rem 2rem;
}

/* Sidebar inner spacing: compact, so the navigation sits close to the edges. */
.app-sidebar-body {
    padding: 1rem 0.75rem;
}

/* Page headings sit closer to the content below them. */
.app-content .mb-4 {
    margin-bottom: 1.25rem !important;
}

.app-content h1.h3 {
    font-size: 1.5rem;
}

@media (min-width: 992px) {
    .app-content {
        padding: var(--app-gutter) var(--app-gutter) 2rem;
    }
}

/* Cards: tighter inner padding than Bootstrap's default p-4. */
.tile.p-4,
.balance-card.p-4 {
    padding: 1.25rem !important;
}

.app-brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 0.75rem;
    background: var(--app-accent);
    color: #fff;
    font-size: 1.1rem;
}

.app-nav-link {
    color: var(--app-muted);
    border-radius: 0.75rem;
    padding: 0.6rem 0.85rem;
    font-weight: 500;
}

.app-nav-link:hover {
    color: var(--app-ink);
    background-color: #f5f5fa;
}

.app-nav-link.active {
    color: #ffffff;
    background-color: #111111;
    font-weight: 600;
}

.app-nav-link i {
    font-size: 1.05rem;
}

.app-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 50%;
    background: var(--app-accent-soft);
    color: var(--app-accent-strong);
    font-weight: 600;
}

/* Sidebar brand, section label and language switch. */
.app-brand-name {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--app-ink);
}

.app-nav-heading {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--app-muted);
}

.app-segment {
    display: flex;
    gap: 0.25rem;
    padding: 0.25rem;
    border-radius: 999px;
    background-color: #f1f1f1;
}

.app-segment form {
    flex: 1;
}

.app-segment-button {
    width: 100%;
    border: 0;
    border-radius: 999px;
    padding: 0.4rem 0.6rem;
    font-size: 0.85rem;
    font-weight: 500;
    background: transparent;
    color: var(--app-muted);
}

.app-segment-button.active {
    background: #111111;
    color: #ffffff;
}

/* Top bar search: a pill field with a leading icon. */
.app-search-field {
    position: relative;
    max-width: 26rem;
}

.app-search-field i {
    position: absolute;
    inset-inline-start: 0.9rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--app-muted);
    pointer-events: none;
}

.app-search-field input {
    width: 100%;
    padding: 0.55rem 1rem 0.55rem 2.5rem;
    border: 1px solid var(--app-line);
    border-radius: 999px;
    background-color: var(--app-surface);
    font-size: 0.9rem;
}

.app-search-field input:focus {
    outline: none;
    border-color: #111111;
    box-shadow: 0 0 0 0.2rem rgba(17, 17, 17, 0.08);
}

/* Right-to-left: the icon and text padding follow the page direction. */
[dir="rtl"] .app-search-field input {
    padding: 0.55rem 2.5rem 0.55rem 1rem;
}

/* Settings popup. */
.app-modal {
    border: 1px solid var(--app-line);
    border-radius: 1.25rem;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.12);
}

.app-settings-link {
    padding: 0.85rem 1rem;
    border: 1px solid var(--app-line);
    border-radius: 0.75rem;
    color: var(--app-ink);
    text-decoration: none;
    font-weight: 500;
}

.app-settings-link:hover {
    background-color: #f7f7f7;
    color: var(--app-ink);
}

/* ------------------------------------------------------------- surfaces */

.tile,
.card {
    background-color: var(--app-surface);
    border: 1px solid var(--app-line);
    border-radius: var(--app-radius);
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

.card-header {
    background-color: transparent;
    border-bottom: 1px solid var(--app-line);
    font-weight: 600;
}

.card-footer {
    background-color: transparent;
    border-top: 1px solid var(--app-line);
}

.balance-card {
    border-radius: var(--app-radius);
    color: #fff;
    background: linear-gradient(160deg, #2a2a2a 0%, #0d0d0d 100%);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
}

.tile-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 0.75rem;
    font-size: 1.1rem;
}

.tile-icon-income {
    background-color: #111111;
    color: #ffffff;
}

.tile-icon-expense {
    background-color: #ececec;
    color: #111111;
}

/* Donut chart is shorter than the line chart. */
.chart-container-donut {
    height: 13rem;
}

/* --------------------------------------------------------- typography */

h1,
.h1,
h2,
.h2,
h3,
.h3 {
    font-weight: 600;
    letter-spacing: -0.015em;
}

.form-label {
    font-size: 0.875rem;
    font-weight: 500;
}

/* ------------------------------------------------------------ buttons */

.btn-primary {
    --bs-btn-color: #fff;
    --bs-btn-bg: var(--app-accent);
    --bs-btn-border-color: var(--app-accent);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: var(--app-accent-strong);
    --bs-btn-hover-border-color: var(--app-accent-strong);
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: var(--app-accent-strong);
    --bs-btn-active-border-color: var(--app-accent-strong);
    --bs-btn-disabled-bg: var(--app-accent);
    --bs-btn-disabled-border-color: var(--app-accent);
    --bs-btn-disabled-color: #fff;
    font-weight: 500;
    border-radius: 0.6rem;
}

.btn-outline-primary,
.btn-outline-secondary {
    --bs-btn-color: var(--app-ink);
    --bs-btn-border-color: #d9dce6;
    --bs-btn-hover-color: var(--app-ink);
    --bs-btn-hover-bg: #f3f4f9;
    --bs-btn-hover-border-color: #d9dce6;
    --bs-btn-active-color: var(--app-ink);
    --bs-btn-active-bg: #e9ebf3;
    --bs-btn-active-border-color: #d9dce6;
    font-weight: 500;
    border-radius: 0.6rem;
}

.btn-link {
    color: var(--app-accent);
}

/* -------------------------------------------------------------- forms */

.form-control,
.form-select {
    min-width: 0;
    border-color: #d9dce6;
    border-radius: 0.6rem;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--app-accent);
    box-shadow: 0 0 0 0.2rem rgba(109, 75, 242, 0.15);
}

/* ------------------------------------------------------------- tables */

.table {
    --bs-table-bg: transparent;
    --bs-table-hover-bg: #f9f9fc;
    --bs-table-border-color: var(--app-line);
}

.table > :not(caption) > * > * {
    padding-block: 0.8rem;
}

.table thead th {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--app-muted);
    border-bottom-width: 1px;
}

/* Keep the page's own width when a table scrolls sideways (see note below). */
.table-responsive {
    position: relative;
}

/* --------------------------------------------------------------- badges */

.badge {
    font-weight: 500;
}

.text-bg-success,
.text-bg-danger {
    background-color: transparent !important;
    border: 1px solid currentColor;
}

.text-bg-success {
    color: #047857 !important;
}

.text-bg-danger {
    color: #b91c1c !important;
}

/* ---------------------------------------------------- category & progress */

.category-dot {
    display: inline-block;
    flex-shrink: 0;
    width: 0.625rem;
    height: 0.625rem;
    border-radius: 50%;
    background-color: #9ca3af;
}

.progress {
    height: 0.4rem;
    background-color: #f1f1f6;
    border-radius: 999px;
}

.progress-bar {
    border-radius: 999px;
}

/* ---------------------------------------------------------------- charts */

.chart-container {
    position: relative;
    height: var(--app-chart-height);
    width: 100%;
}

.chart-container canvas {
    display: block;
}

/* Keep numbers aligned in both directions. */
.text-nowrap,
td.text-end {
    font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------- alerts */

.alert {
    border-radius: 0.75rem;
    border-width: 1px;
    box-shadow: none;
}

.alert-success {
    background-color: #ecfdf5;
    border-color: #a7f3d0;
    color: #065f46;
}

.alert-danger {
    background-color: #fef2f2;
    border-color: #fecaca;
    color: #991b1b;
}

.alert-warning {
    background-color: #fffbeb;
    border-color: #fde68a;
    color: #92400e;
}

/* -------------------------------------------------- layout safety rules */

/*
 * Positioned so that absolutely positioned children (such as visually hidden header labels)
 * are clipped by this scroll container. Without it, in RTL they widen the whole page.
 */
.table-responsive {
    position: relative;
}

/* Form controls may shrink below their native width (date inputs are wide by default). */
.form-control,
.form-select {
    min-width: 0;
}

/* Let long words and addresses wrap instead of pushing the page wider than the screen. */
body {
    overflow-wrap: anywhere;
}

/* Small screens: tighter padding, nothing wider than the screen. */
@media (max-width: 575.98px) {
    .card-body,
    .tile {
        padding: 1rem;
    }
}

/* Visible focus for keyboard users on every interactive element. */
:focus-visible {
    outline: 2px solid var(--app-accent);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
