/* =========================
   STATIC/CSS/STYLE.CSS-->STRIPE-INSPIRED SACCO DASHBOARD
   Modern, clean, professional, high-trust UI
   ========================= */

:root {
    --primary: #635bff;
    --primary-dark: #4f46e5;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --gray-100: #f8fafc;
    --gray-200: #e2e8f0;
    --gray-700: #334155;
    --gray-900: #0f172a;
}

body {
    background-color: #f8fafc;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--gray-900);
    line-height: 1.6;
}

.container {
    max-width: 1280px;
}

/* Headings */
h1, h2, h3, h4, h5 {
    font-weight: 600;
    letter-spacing: -0.025em;
}

h1 {
    color: var(--gray-900);
}

/* Cards - Stripe style */
.card {
    border: none;
    border-radius: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05), 
                0 10px 15px -3px rgba(0, 0, 0, 0.1);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    background: white;
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 
                0 8px 10px -6px rgba(0, 0, 0, 0.1);
}

.card-body {
    padding: 1.75rem;
}

/* Metric Cards */
.card.bg-info, .card.bg-success, .card.bg-warning, .card.bg-primary {
    border: none;
    color: white;
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 10%);
}

.card.bg-info { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.card.bg-success { background: linear-gradient(135deg, #10b981, #059669); }
.card.bg-warning { background: linear-gradient(135deg, #f59e0b, #d97706); color: white; }
.card.bg-primary { background: linear-gradient(135deg, #635bff, #4f46e5); }

/* Tables */
.table {
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.table thead th {
    background: #f1f5f9;
    color: var(--gray-700);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    border: none;
}

.table-hover tbody tr:hover {
    background-color: #f8fafc;
}

/* Buttons */
.btn {
    border-radius: 10px;
    font-weight: 600;
    padding: 0.65rem 1.25rem;
    transition: all 0.2s ease;
}

.btn-primary {
    background-color: var(--primary);
    border: none;
}

.btn-primary:hover {
    background-color: var(--primary-dark);
    transform: translateY(-1px);
}

.btn-success { background-color: var(--success); }
.btn-warning { background-color: var(--warning); color: white; }
.btn-info { background-color: #06b6d4; }

/* Modals */
.modal-content {
    border-radius: 20px;
    border: none;
    box-shadow: 0 25px 50px -12px rgb(0 0 0 / 25%);
}

.modal-header {
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    border-bottom: none;
    padding: 1.5rem 2rem;
}

.modal-body {
    padding: 2rem;
}

/* Badges & Status */
.badge {
    font-weight: 600;
    padding: 0.35em 0.75em;
    border-radius: 9999px;
    font-size: 0.75rem;
}

.status-online {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Revenue Chart Container */
# s a c c o R e v e n u e C h a r t {
    max-height: 320px;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99999;
    border-radius: 12px;
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1);
}

/* Responsive */
@media (max-width: 768px) {
    .card-body {
        padding: 1.25rem;
    }
    .modal-body {
        padding: 1.5rem;
    }
}

.dest-item {
    padding: 14px 16px;
    margin: 6px 0;
    background: #334155;
    border-radius: 12px;
    color: white;
    cursor: pointer;
    transition: all 0.2s;
}

.dest-item:hover {
    background: #22c55e;
    transform: translateX(4px);
}

#destList p {
    color: #94a3b8;
    text-align: center;
    padding: 20px;
}

/* Enhanced Device Secrets Modal */
#secretsModal .modal-content {
  border-radius: 16px;
}

#secretsModal code {
  background: #f8f9fa;
  padding: 4px 8px;
  border-radius: 4px;
  font-family: monospace;
}

/* Better button hover */
.btn-outline-info:hover {
  background-color: #0dcaf0;
  color: white;
  border-color: #0dcaf0;
}

/* seed button */
.btn-outline-success {
    border-color: #10b981;
    color: #10b981;
    font-weight: 600;
}

.btn-outline-success:hover {
    background-color: #10b981;
    color: white;
}

.nganya-pay-logo {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, 
                 "Helvetica Neue", Arial, sans-serif;
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.025em;
    background: linear-gradient(90deg, 
                #10b981 0%,      /* Professional green */
                #14b8a6 35%, 
                #6366f1 65%,     /* Indigo (matches your --primary) */
                #4f46e5 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: inline-block;
    line-height: 1;
    transition: all 0.25s ease;
}

.nganya-pay-logo:hover {
    transform: scale(1.03);
    filter: brightness(1.08);
}

/* Optional: Split color version (very premium) */
.nganya-pay-logo .pay {
    background: linear-gradient(90deg, #6366f1, #4f46e5);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.navbar {
    padding: 1rem 0;
}

.navbar-light .navbar-brand {
    padding: 0;
}

.navbar-nav .nav-link {
    font-weight: 500;
    color: #334155;
    padding: 0.5rem 1rem;
    transition: color 0.2s;
}

.navbar-nav .nav-link:hover {
    color: var(--primary);
}

/* Make active nav item stand out */
.navbar-nav .nav-link.active {
    color: var(--primary);
    font-weight: 600;
    position: relative;
}

.navbar-nav .nav-link.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 1rem;
    right: 1rem;
    height: 2px;
    background: var(--primary);
    border-radius: 2px;
}

/* ====================== IMPROVED FLASH MESSAGES ====================== */

.alert {
    border-radius: 12px;
    font-weight: 500;
    margin-bottom: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    animation: slideIn 0.3s ease forwards;
}

.alert-success { border-left: 5px solid #10b981; }
.alert-danger  { border-left: 5px solid #ef4444; }
.alert-warning { border-left: 5px solid #f59e0b; }
.alert-info    { border-left: 5px solid #3b82f6; }

@keyframes slideIn {
    from { transform: translateY(-20px); opacity: 0; }
    to   { transform: translateY(0); opacity: 1; }
}

/* Auto dismiss after 5 seconds */
.alert-auto-dismiss {
    animation: slideIn 0.3s ease forwards;
}

/* Make close button nicer */
.alert .btn-close {
    opacity: 0.7;
}

.alert .btn-close:hover {
    opacity: 1;
}

/* Stripe-inspired Pagination */
.pagination-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-top: 1px solid #e5e7eb;
    background: #f9fafb;
    border-radius: 0 0 8px 8px;
}

.pagination {
    display: flex;
    gap: 4px;
    list-style: none;
    padding: 0;
    margin: 0;
}

.pagination li {
    display: inline;
}

.pagination button {
    padding: 6px 12px;
    border: 1px solid #d1d5db;
    background: white;
    color: #374151;
    border-radius: 6px;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
}

.pagination button:hover {
    background: #f3f4f6;
}

.pagination button.active {
    background: #1f2937;
    color: white;
    border-color: #1f2937;
}

.pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.results-info {
    font-size: 0.875rem;
    color: #6b7280;
}

/* ═══════════════════════════════════════════
   REVENUE TICKER — contained within page grid
   ═══════════════════════════════════════════ */

/* The wrapper sits inside .col-12 which Bootstrap
   already constrains to the container width.
   We only need overflow:hidden + the fade mask. */
.revenue-ticker-wrapper {
  position: relative;
  overflow: hidden;
  border-radius: 12px;
  /* same horizontal padding feel as the metric cards above */
  padding: 4px 0;

  /* graceful fade at both edges */
  -webkit-mask-image: linear-gradient(
    to right,
    transparent 0%,
    black 5%,
    black 95%,
    transparent 100%
  );
  mask-image: linear-gradient(
    to right,
    transparent 0%,
    black 5%,
    black 95%,
    transparent 100%
  );
}

/* Pause the whole ticker on hover */
.revenue-ticker-wrapper:hover .revenue-ticker {
  animation-play-state: paused;
}

/* ── TRACK ── */
.revenue-ticker {
  display: flex;
  gap: 16px;
  width: max-content;           /* lets cards size themselves */
  animation: ticker-scroll 32s linear infinite;
}

/* ── CARD ── */
.revenue-card {
  flex: 0 0 210px;              /* fixed width per card */
  background: #ffffff;
  border-radius: 12px;
  padding: 18px 20px;
  border-left: 4px solid #e5e7eb;
  box-shadow: 0 1px 3px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.04);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
  user-select: none;
}

.revenue-card:hover {
  box-shadow: 0 4px 14px rgba(0,0,0,0.11);
  transform: translateY(-2px);
}

.revenue-label {
  font-size: 0.72rem;
  color: #6b7280;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}

.revenue-amount {
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 5px;
}

.revenue-sub {
  font-size: 0.73rem;
  color: #9ca3af;
  min-height: 16px;
  line-height: 1.4;
}

/* ── KEYFRAME ──────────────────────────────
   Translate exactly ONE full set of 6 cards:
   6 × (210px card + 16px gap) = 6 × 226 = 1356px
   ─────────────────────────────────────────── */
@keyframes ticker-scroll {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-1356px); }
}

/* SACCO NAME — MATCHES BRAND STYLE (SUBTLE VARIANT) */
.sacco-name {
    font-weight: 700;
    letter-spacing: -0.025em;

    background: linear-gradient(90deg,
        #6366f1 0%,   /* primary indigo */
        #4f46e5 50%,  /* deeper indigo */
        #3b82f6 100%  /* slight blue lift */
    );

    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;

    display: inline-block;
}

@media (max-width: 576px) {
  .revenue-ticker {
    animation-duration: 45s;
  }
}

/* ================= MOBILE FOUNDATION ================= */
@media (max-width: 768px) {

    body {
        font-size: 15px;
    }

    h1 { font-size: 1.5rem; }
    h2 { font-size: 1.3rem; }
    h3 { font-size: 1.15rem; }

    .container {
        padding-left: 12px;
        padding-right: 12px;
    }
}

@media (max-width: 576px) {
    .revenue-card { flex: 0 0 160px; }

    @keyframes ticker-scroll {
        0%   { transform: translateX(0); }
        100% { transform: translateX(-1056px); } /* 6 × (160+16) */
    }
}

/* ═══════════════════════════════════════════
   STRIPE-LEVEL MOBILE DASHBOARD
   ═══════════════════════════════════════════ */

@media (max-width: 576px) {

    /* ── Page padding ── */
    .container-fluid,
    .container {
        padding-left: 16px;
        padding-right: 16px;
    }

    /* ── Welcome heading ── */
    h1.mb-4 {
        font-size: 1.4rem;
        margin-bottom: 1rem !important;
    }

    /* ── SACCO Management card ── */
    .card.shadow.mb-4 .card-body {
        padding: 1rem;
    }

    /* ── Action buttons: 2-per-row grid on mobile ── */
    .card.shadow.mb-4 .row.g-2.mb-4,
    .card.shadow.mb-4 .row.g-2:not(.mb-4) {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .card.shadow.mb-4 .row.g-2 > [class*="col-"] {
        width: 100%;
        padding: 0;
    }

    .card.shadow.mb-4 .btn {
        font-size: 0.78rem;
        padding: 10px 6px;
        border-radius: 10px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* ── Core metric cards: 2×2 grid ── */
    .row.g-4 > .col-md-3 {
        width: 50%;
        flex: 0 0 50%;
    }

    .row.g-4 > .col-md-3 .card-body {
        padding: 1rem 0.75rem;
    }

    .row.g-4 > .col-md-3 h5 {
        font-size: 0.8rem;
        margin-bottom: 4px;
    }

    .row.g-4 > .col-md-3 h2 {
        font-size: 1.5rem;
    }

    /* ── Revenue ticker ── */
    .revenue-ticker-wrapper {
        border-radius: 10px;
    }

    .revenue-card {
        flex: 0 0 175px;
        padding: 14px 16px;
    }

    .revenue-amount {
        font-size: 1.15rem;
    }

    .revenue-label {
        font-size: 0.68rem;
    }

    /* ── Section headings ── */
    section h4,
    h3.mb-3 {
        font-size: 1.05rem;
    }

    /* ── Tables: make them scroll horizontally ── */
    .table-responsive {
        -webkit-overflow-scrolling: touch;
    }

    .table th,
    .table td {
        font-size: 0.78rem;
        padding: 10px 8px;
        white-space: nowrap;
    }

    /* ── Per-vehicle breakdown: hide less important cols ── */
    .table thead th:nth-child(6),   /* SACCO col */
    .table tbody td:nth-child(6) {
        display: none;
    }

    /* ── Pagination ── */
    .pagination-container {
        flex-direction: column;
        gap: 8px;
        padding: 12px;
        text-align: center;
    }

    .pagination button {
        padding: 6px 10px;
        font-size: 0.8rem;
    }

    /* ── Modal: full-screen on mobile ── */
    .modal-dialog {
        margin: 0;
        max-width: 100%;
        min-height: 100vh;
    }

    .modal-content {
        border-radius: 0;
        min-height: 100vh;
    }

    .modal-dialog-centered {
        align-items: flex-end;
    }

    .modal-dialog-centered .modal-content {
        border-radius: 20px 20px 0 0;
        min-height: auto;
    }

    /* ── Badge text ── */
    .badge {
        font-size: 0.68rem;
    }

    /* ── Revenue summary aggregate cards ── */
    section.mb-5.mt-4 .row.g-3 > .col-md-3 {
        width: 50%;
        flex: 0 0 50%;
    }

    section.mb-5.mt-4 .row.g-3 > .col-md-3 .fw-bold.fs-4 {
        font-size: 1.1rem !important;
    }

    /* ── Live trip monitoring cards ── */
    #tripLiveContainer > .col-md-4 {
        width: 100%;
        flex: 0 0 100%;
    }

    /* ── Revenue chart ── */
    #saccoRevenueChart {
        max-height: 200px;
    }

    /* ── Device/conductor management buttons ── */
    section .d-flex.justify-content-between {
        flex-direction: column;
        gap: 8px;
        align-items: flex-start !important;
    }

    section .d-flex.justify-content-between > div {
        width: 100%;
        display: flex;
        gap: 8px;
    }

    section .d-flex.justify-content-between > div .btn,
    section .d-flex.justify-content-between > .btn {
        flex: 1;
        font-size: 0.82rem;
        padding: 10px 8px;
    }
}

@media (max-width: 576px) {
    .btn {
        font-size: 0.8rem;
        padding: 10px 8px;
    }

    .card .btn {
        width: 100%;
    }
}

@media (max-width: 576px) {
    .container[style*="max-width: 420px"] {
        max-width: 100% !important;
    }

    .card-body.p-5 {
        padding: 1.5rem !important;
    }

    .nganya-pay-logo {
        font-size: 2rem !important;
    }
}

@media (max-width: 576px) {
    .row.g-4 > .col-md-3 {
        width: 50%;
        flex: 0 0 50%;
    }
}

@media (max-width: 576px) {
    section {
        margin-bottom: 1.5rem;
    }

    .card {
        border-radius: 14px;
    }
}

@media (max-width: 576px) {
    section .d-flex.justify-content-between {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }
}