/* ============================================================
   Debt Settlement — Design System
   Typography · Tokens · Responsive · Utilities
   ============================================================ */

/* --- 1. Design Tokens ---------------------------------------- */
:root {
    /* Typography — Arabic-first */
    --font-primary: "Cairo", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;

    --fs-base: 0.9375rem;
    /* 15px */
    --fs-sm: 0.8125rem;
    /* 13px */
    --fs-xs: 0.75rem;
    /* 12px */
    --fs-h1: 1.75rem;
    --fs-h2: 1.5rem;
    --fs-h3: 1.25rem;
    --fs-h4: 1.125rem;
    --fs-h5: 1rem;
    --fs-h6: 0.875rem;
    --lh-base: 1.65;

    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;

    /* Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-pill: 50rem;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);

    /* Brand (preserved) */
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --primary-gradient-hover: linear-gradient(135deg, #5a6fd6 0%, #6a4190 100%);

    /* Borders */
    --border-color: #e2e8f0;
    --border-light: #f1f5f9;
}


/* --- 2. Typography ------------------------------------------- */
body {
    font-family: var(--font-primary);
    font-size: var(--fs-base);
    line-height: var(--lh-base);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    background-color: #f8fafc;
}

h1,
.h1 {
    font-size: var(--fs-h1);
    font-weight: 700;
    line-height: 1.2;
}

h2,
.h2 {
    font-size: var(--fs-h2);
    font-weight: 700;
    line-height: 1.25;
}

h3,
.h3 {
    font-size: var(--fs-h3);
    font-weight: 600;
    line-height: 1.3;
}

h4,
.h4 {
    font-size: var(--fs-h4);
    font-weight: 600;
    line-height: 1.35;
}

h5,
.h5 {
    font-size: var(--fs-h5);
    font-weight: 600;
    line-height: 1.4;
}

h6,
.h6 {
    font-size: var(--fs-h6);
    font-weight: 600;
    line-height: 1.45;
}

/* Numbers — always LTR-rendered */
.num-ltr {
    direction: ltr;
    unicode-bidi: plaintext;
    font-variant-numeric: tabular-nums;
}


/* --- 3. Global Layout ---------------------------------------- */
html,
body {
    overflow-x: hidden;
}

main {
    flex: 1;
}


/* --- 4. Navbar ----------------------------------------------- */
.navbar {
    background: var(--primary-gradient) !important;
    box-shadow: var(--shadow-md);
    padding-top: var(--spacing-sm);
    padding-bottom: var(--spacing-sm);
}

.navbar-brand {
    font-weight: 700;
    font-size: 1.15rem;
    white-space: nowrap;
}

/* Keep navbar items tightly packed on mobile */
@media (max-width: 991.98px) {
    .navbar .container {
        padding-inline: var(--spacing-sm);
    }

    .navbar-brand {
        font-size: 1rem;
    }
}


/* --- 5. Cards ------------------------------------------------ */
.card {
    border: none;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.3s ease, transform 0.2s ease;
    overflow: hidden;
}

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

.card-body {
    padding: var(--spacing-md);
}


/* --- 6. Buttons ---------------------------------------------- */
.btn-primary {
    background: var(--primary-gradient);
    border: none;
}

.btn-primary:hover {
    background: var(--primary-gradient-hover);
}


/* --- 7. Progress --------------------------------------------- */
.progress {
    height: 10px;
    border-radius: 5px;
    overflow: hidden;
}

.progress-bar {
    background: var(--primary-gradient);
}


/* --- 8. Footer ----------------------------------------------- */
footer {
    background-color: #1e293b;
    color: #94a3b8;
    padding: var(--spacing-md) 0;
    margin-top: auto;
}


/* --- 9. Utility Classes -------------------------------------- */

/* Flex overflow prevention — CRITICAL for mobile */
.minw-0 {
    min-width: 0 !important;
}

/* Flexible text column (inside flex row) */
.flex-text-col {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    max-width: 100%;
}

/* Fixed-width column (icons, amounts) */
.flex-fixed-col {
    flex: 0 0 auto;
}

/* Single-line truncation */
.truncate-1 {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Two-line clamp */
.clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Long-word wrap safety */
.wrap-anywhere {
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* Amount display — always LTR, truncated */
.amount-fit {
    display: block;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    direction: ltr;
    unicode-bidi: plaintext;
    min-width: 0;
    font-variant-numeric: tabular-nums;
}

/* Card-level overflow safety */
.card-safe {
    overflow: hidden;
    max-width: 100%;
}

.card-safe * {
    min-width: 0;
}

/* Inline LTR helper */
.ltr {
    direction: ltr;
    display: inline-block;
}


/* --- 10. Notification Badge ---------------------------------- */
.notif-badge {
    position: absolute;
    top: 0;
    left: 0;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    padding: 0;
    border: 2px solid var(--bs-navbar-brand-color, #fff);
    background-color: #dc3545;
    z-index: 2;
}


/* --- 11. Notification Dropdown ------------------------------- */
.notification-dropdown {
    width: min(360px, 92vw);
    max-width: 92vw;
    max-height: 60vh;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Mobile centering */
@media (max-width: 991.98px) {
    .notification-dropdown {
        position: fixed !important;
        top: 56px !important;
        left: 50% !important;
        right: auto !important;
        transform: translateX(-50%) !important;
        width: 92vw !important;
        max-width: 360px !important;
        z-index: 1055;
    }
}

/* Desktop — align to start (RTL = left side) */
@media (min-width: 992px) {
    .notification-dropdown {
        left: 0;
        right: auto;
    }
}


/* --- 12. RTL handled by Bootstrap RTL --------------------------------- */
/* 
   We use bootstrap.rtl.min.css which automatically handles:
   - me-* / ms-* margin flipping
   - text-start / text-end alignment flipping
   - dropdown-menu-end positioning
   No manual overrides needed.
*/

.dropdown-menu-start:not(.notification-dropdown) {
    right: auto !important;
    left: 0 !important;
}


/* --- 13. PWA Install Banner ---------------------------------- */
.install-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fff;
    padding: var(--spacing-md);
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.15);
    z-index: 10000;
    display: none;
    border-top: 1px solid var(--border-color);
}

.dark-mode .install-banner {
    background: #1e293b;
    color: #fff;
    border-top-color: #334155;
}


/* --- 14. Push Toast ------------------------------------------ */
.push-toast {
    position: fixed;
    top: 14px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    width: min(560px, calc(100vw - 24px));
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: #fff;
    padding: var(--spacing-md);
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(255, 255, 255, 0.1);
    z-index: 10100;
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    opacity: 0;
    pointer-events: none;
    transition: all 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    text-align: right;
}

.push-toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.push-toast-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
    flex-shrink: 0;
}

.push-toast-content {
    flex: 1;
}

.push-toast-title {
    font-weight: 700;
    font-size: 0.95rem;
    margin-bottom: 0.1rem;
    color: #fff;
}

.push-toast-subtitle {
    font-size: var(--fs-sm);
    color: #94a3b8;
    line-height: 1.3;
}

.push-toast-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.btn-toast-enable {
    background: #fff;
    color: #0f172a;
    border: none;
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: transform 0.2s;
}

.btn-toast-enable:active {
    transform: scale(0.95);
}

.btn-toast-close {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #94a3b8;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.btn-toast-close:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}


/* --- 15. Mobile Responsive Overrides ------------------------- */

/* Small phones (360–575px) */
@media (max-width: 575.98px) {
    :root {
        --fs-base: 0.875rem;
        /* 14px on tiny screens */
        --fs-h3: 1.125rem;
        --fs-h4: 1rem;
        --fs-h5: 0.9375rem;
    }

    .container {
        padding-inline: 12px;
    }

    .card-body {
        padding: var(--spacing-sm);
    }

    /* Reduce icon circle size in stat cards */
    .card .bg-opacity-10.p-3 {
        padding: 0.5rem !important;
    }

    .card .bg-opacity-10 i {
        font-size: 0.85rem;
    }

    /* Amount responsive sizing */
    .amount-fit {
        font-size: clamp(0.75rem, 3.5vw, 1rem);
        line-height: 1.2;
        letter-spacing: -0.3px;
    }

    /* Stat card number auto-shrink */
    .h5.amount-fit {
        font-size: clamp(0.8rem, 3.8vw, 1rem) !important;
    }

    /* Dashboard header stacking */
    .dashboard-header {
        flex-direction: column;
        align-items: flex-start !important;
        gap: var(--spacing-sm);
    }

    .dashboard-header .btn {
        width: 100%;
    }

    /* Full width buttons on mobile */
    .d-grid .btn-lg {
        font-size: 1rem;
    }
}

/* Tablets (576–767px) */
@media (min-width: 576px) and (max-width: 767.98px) {
    .container {
        padding-inline: 1rem;
    }
}

/* Medium screens (768px+) */
@media (max-width: 767.98px) {
    .card {
        margin-bottom: var(--spacing-sm);
    }
}

/* Desktop — ensure no regression */
@media (min-width: 992px) {
    .container {
        padding-inline: 1rem;
    }
}