/* Dashboard-specific styles */

.dashboard-container {
    background: var(--bg, #f4f6f9);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* Dashboard grid system */
.dashboard-grid {
    display: grid;
    gap: 1rem;
    margin-bottom: 1rem;
}

.dashboard-grid.grid-2 {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.dashboard-grid.grid-3 {
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.dashboard-grid.grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

/* Dashboard cards */
.dashboard-card {
    background: #ffffff;
    border: 1px solid #eaecf0;
    border-radius: 10px;
    padding: 1rem 1.25rem;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
    transition: box-shadow 0.2s ease;
}

.dashboard-card:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}

/* Dashboard stats */
.dashboard-stat {
    display: flex;
    align-items: center;
    gap: 0.875rem;
}

.dashboard-stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.dashboard-stat-icon.primary { background: #ede9fe; color: #7c3aed; }
.dashboard-stat-icon.secondary { background: #dcfce7; color: #16a34a; }
.dashboard-stat-icon.accent { background: #fef3c7; color: #d97706; }
.dashboard-stat-icon.danger { background: #fee2e2; color: #dc2626; }
.dashboard-stat-icon.navy { background: #e8edf8; color: #1a2744; }

.dashboard-stat-content h4 {
    font-size: 0.72rem;
    color: #6b7280;
    margin: 0 0 0.15rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.dashboard-stat-content .stat-number {
    font-size: 1.6rem;
    font-weight: 700;
    color: #111827;
    line-height: 1;
    margin: 0;
}

.dashboard-stat-content .stat-label {
    font-size: 0.7rem;
    color: #9ca3af;
    margin: 0.2rem 0 0;
}

/* Welcome card — compact horizontal bar */
.dashboard-welcome {
    background: linear-gradient(120deg, #1a2744 0%, #2d3f6e 100%);
    color: white;
    margin-bottom: 1rem;
    border: none;
    padding: 0.875rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.dashboard-welcome h2 {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0 0 0.1rem;
    line-height: 1.2;
}

.dashboard-welcome p {
    opacity: 0.75;
    margin: 0;
    font-size: 0.8rem;
}

.dashboard-welcome .term-badge {
    background: rgba(255,255,255,0.15);
    padding: 0.2rem 0.65rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    margin-top: 0.35rem;
    display: inline-block;
    border: 1px solid rgba(255,255,255,0.2);
}

.dashboard-welcome .date-badge {
    background: rgba(255,255,255,0.12);
    padding: 0.35rem 0.85rem;
    border-radius: 8px;
    font-size: 0.8rem;
    border: 1px solid rgba(255,255,255,0.15);
    white-space: nowrap;
}

/* Alert cards */
.dashboard-alert {
    margin-bottom: 0.75rem;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.dashboard-alert.warning { background: #fffbeb; border: 1px solid #fde68a; }
.dashboard-alert.danger  { background: #fef2f2; border: 1px solid #fecaca; }

.dashboard-alert-icon {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.85rem;
}

.dashboard-alert.warning .dashboard-alert-icon { background: #f59e0b; color: white; }
.dashboard-alert.danger  .dashboard-alert-icon { background: #ef4444; color: white; }

.dashboard-alert-content strong { font-size: 0.875rem; display: block; margin-bottom: 0.25rem; }
.dashboard-alert.warning strong { color: #92400e; }
.dashboard-alert.danger  strong { color: #991b1b; }
.dashboard-alert-content p { margin: 0; font-size: 0.8rem; }
.dashboard-alert.warning p { color: #b45309; }
.dashboard-alert.danger  p { color: #b91c1c; }

/* Progress bars */
.dashboard-progress {
    background: #e5e7eb;
    border-radius: 9999px;
    height: 8px;
    overflow: hidden;
    margin: 0.5rem 0;
}

.dashboard-progress-bar {
    background: linear-gradient(90deg, #16a34a, #22c55e);
    height: 100%;
    transition: width 0.5s ease;
}

/* Status cards for invoice breakdown */
.dashboard-status-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
}

.dashboard-status-card {
    padding: 0.75rem;
    border-radius: 8px;
    text-align: center;
    text-decoration: none;
    transition: all 0.15s ease;
    border: 1px solid transparent;
}

.dashboard-status-card:hover { transform: translateY(-1px); box-shadow: 0 3px 10px rgba(0,0,0,0.1); }
.dashboard-status-card.unpaid  { background: #fef2f2; color: #dc2626; }
.dashboard-status-card.partial { background: #fffbeb; color: #d97706; }
.dashboard-status-card.paid    { background: #f0fdf4; color: #16a34a; }
.dashboard-status-card.overdue { background: #fef2f2; border: 1px solid #fca5a5; color: #dc2626; }

.dashboard-status-number { font-size: 1.4rem; font-weight: 700; display: block; margin-bottom: 0.15rem; }
.dashboard-status-label  { font-size: 0.7rem; opacity: 0.8; }

/* Quick action buttons */
.dashboard-quick-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.45rem 0.85rem;
    font-size: 0.78rem;
    font-weight: 500;
    border-radius: 7px;
    text-decoration: none;
    transition: all 0.15s ease;
    border: 1px solid #e5e7eb;
    background: #f9fafb;
    color: #374151;
    cursor: pointer;
}
.dashboard-quick-btn:hover { background: #f3f4f6; border-color: #d1d5db; color: #111827; }
.dashboard-quick-btn.primary { background: #fff1f2; border-color: #fecaca; color: #c0152a; }
.dashboard-quick-btn.primary:hover { background: #fee2e2; border-color: #fca5a5; }

/* Recent items list */
.dashboard-recent-list { list-style: none; padding: 0; margin: 0; }

.dashboard-recent-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid #f3f4f6;
}
.dashboard-recent-item:last-child { border-bottom: none; }

.dashboard-recent-name    { font-weight: 600; color: #111827; margin: 0 0 0.15rem; font-size: 0.825rem; }
.dashboard-recent-details { font-size: 0.7rem; color: #6b7280; margin: 0; }
.dashboard-recent-amount  { font-weight: 700; color: #16a34a; font-size: 0.825rem; white-space: nowrap; }

/* Dark mode */
[data-theme="dark"] .dashboard-card { background: var(--card-bg); border-color: rgba(255,255,255,0.07); }
[data-theme="dark"] .dashboard-welcome { background: linear-gradient(120deg, #0f1a33 0%, #1a2744 100%); }
[data-theme="dark"] .dashboard-stat-content .stat-number { color: #f1f5f9; }
[data-theme="dark"] .dashboard-stat-content h4 { color: #94a3b8; }
[data-theme="dark"] .dashboard-recent-name { color: #f1f5f9; }

/* Responsive */
@media (max-width: 1024px) {
    .dashboard-grid.grid-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .dashboard-grid.grid-4,
    .dashboard-grid.grid-3,
    .dashboard-grid.grid-2 { grid-template-columns: 1fr; gap: 0.75rem; }
    .dashboard-card { padding: 0.875rem 1rem; }
    .dashboard-stat-content .stat-number { font-size: 1.4rem; }
    .dashboard-welcome { padding: 0.75rem 1rem; }
    .dashboard-welcome h2 { font-size: 1rem; }
    .dashboard-status-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Loading / error states */
.dashboard-loading {
    display: flex; align-items: center; justify-content: center;
    min-height: 200px; color: #6b7280;
}
.dashboard-loading::before {
    content: ''; width: 1.5rem; height: 1.5rem;
    border: 2px solid #e5e7eb; border-top-color: #1a2744;
    border-radius: 50%; animation: spin 0.8s linear infinite; margin-right: 0.5rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

.dashboard-error {
    background: #fef2f2; border: 1px solid #fecaca;
    border-radius: 8px; padding: 1rem; color: #991b1b; text-align: center;
}

.dashboard-content { opacity: 1; visibility: visible; }
.dashboard-content.loading { opacity: 0.7; }
.dashboard-content.force-visible { opacity: 1 !important; visibility: visible !important; }

/* ============================================
   TABLE STYLES - Added to fix missing data display
   ============================================ */

/* Table container */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Base table styles */
.table {
    width: 100%;
    border-collapse: collapse;
    border: 2px solid #bfbfbf;
    font-size: 0.875rem;
}

/* Table header */
.table thead {
    background: var(--primary-color, #1a1f3c);
    border-bottom: none;
}

.table thead th {
    padding: 0.5rem 0.75rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: rgba(255,255,255,0.9);
    white-space: nowrap;
    border-right: 1px solid rgba(255,255,255,0.25);
    border-bottom: 2px solid rgba(255,255,255,0.3);
}
.table thead th:last-child { border-right: none; }
.table thead th span { color: inherit; }

/* Table body */
.table tbody tr:nth-child(odd)  { background: #ffffff; }
.table tbody tr:nth-child(even) { background: #f2f2f2; }
.table tbody tr:hover { background: #fff3cd !important; }

.table tbody td {
    padding: 0.5rem 0.75rem;
    color: #374151;
    vertical-align: middle;
    border: 1px solid #d0d0d0;
    font-size: 0.8rem;
}

/* Footer */
.table tfoot td, .table tfoot th {
    background: #e8e8e8;
    border-top: 2px solid #bfbfbf;
    border: 1px solid #d0d0d0;
    font-weight: 700;
    padding: 0.5rem 0.75rem;
}

/* Numeric alignment */
.table .num {
    text-align: right;
    font-family: 'Inter', monospace;
}

/* Card styles enhancement */
.card {
    background: white;
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border: 1px solid #e5e7eb;
    overflow: hidden;
}

/* Badge styles */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Empty state styling */
.table tbody tr:has(td[colspan]) {
    text-align: center;
    color: #9ca3af;
}

/* Dark mode support for tables */
[data-theme="dark"] .table { border-color: #4b5563; }
[data-theme="dark"] .table thead { background: rgba(0,0,0,0.4); }
[data-theme="dark"] .table thead th { color: rgba(255,255,255,0.85); border-color: rgba(255,255,255,0.15); }
[data-theme="dark"] .table tbody tr:nth-child(odd)  { background: #1f2937; }
[data-theme="dark"] .table tbody tr:nth-child(even) { background: #111827; }
[data-theme="dark"] .table tbody tr:hover { background: #374151 !important; }
[data-theme="dark"] .table tbody td { color: #d1d5db; border-color: #374151; }
[data-theme="dark"] .table tfoot td, [data-theme="dark"] .table tfoot th { background: #111827; border-color: #4b5563; color: #d1d5db; }

/* ============================================
   MODERN TABLE REFINEMENTS
   Tighter rows, smaller fonts, clean action btns
   ============================================ */

/* Tighter table rows — handled by base styles above */

.table tbody tr:last-child td { border-bottom: 1px solid #d0d0d0; }

/* ── Action button group in tables ── */
table .flex,
table .action-group {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    flex-wrap: nowrap;
}

/* ── Modern table action buttons ─────────────────────────────── */
table .btn-sm {
    display: inline-flex;
    align-items: center;
    gap: 0.28rem;
    height: 24px;
    min-width: unset !important;
    min-height: unset !important;
    width: auto;
    padding: 0 0.55rem;
    border-radius: 6px;
    font-size: 0.68rem;
    font-weight: 500;
    line-height: 1;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background 0.15s, box-shadow 0.15s, transform 0.1s;
    text-decoration: none;
    white-space: nowrap;
    letter-spacing: 0.01em;
}

table .btn-sm:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0,0,0,0.12);
}

table .btn-sm:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: none;
}

table .btn-sm:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

/* View / neutral / edit — indigo tint */
table .btn-outline,
table .btn-edit {
    background: #eef2ff;
    border-color: #c7d2fe;
    color: #4338ca;
}
table .btn-outline:hover:not(:disabled),
table .btn-edit:hover:not(:disabled) {
    background: #e0e7ff;
    border-color: #a5b4fc;
}

/* Primary / create — emerald tint */
table .btn-primary {
    background: #ecfdf5;
    border-color: #6ee7b7;
    color: #065f46;
}
table .btn-primary:hover:not(:disabled) {
    background: #d1fae5;
    border-color: #34d399;
}

/* Warning / disable — amber tint */
table .btn-warning {
    background: #fefce8;
    border-color: #fde68a;
    color: #854d0e;
}
table .btn-warning:hover:not(:disabled) {
    background: #fef9c3;
    border-color: #fcd34d;
}

/* Success / enable — green tint */
table .btn-success {
    background: #f0fdf4;
    border-color: #bbf7d0;
    color: #166534;
}
table .btn-success:hover:not(:disabled) {
    background: #dcfce7;
    border-color: #86efac;
}

/* Danger / delete — rose tint */
table .btn-danger {
    background: #fff1f2;
    border-color: #fecaca;
    color: #dc2626;
}
table .btn-danger:hover:not(:disabled) {
    background: #fee2e2;
    border-color: #fca5a5;
}

/* Secondary / info — sky tint */
table .btn-secondary {
    background: #f0f9ff;
    border-color: #bae6fd;
    color: #0369a1;
}
table .btn-secondary:hover:not(:disabled) {
    background: #e0f2fe;
    border-color: #7dd3fc;
}

/* Dark mode table — consolidated above */
[data-theme="dark"] table .btn-outline,
[data-theme="dark"] table .btn-edit {
    background: rgba(99,102,241,0.15);
    border-color: rgba(99,102,241,0.3);
    color: #a5b4fc;
}
[data-theme="dark"] table .btn-danger {
    background: rgba(220,38,38,0.12);
    border-color: rgba(220,38,38,0.3);
    color: #fca5a5;
}
[data-theme="dark"] table .btn-warning {
    background: rgba(245,158,11,0.12);
    border-color: rgba(245,158,11,0.3);
    color: #fcd34d;
}
[data-theme="dark"] table .btn-success {
    background: rgba(22,163,74,0.12);
    border-color: rgba(22,163,74,0.3);
    color: #86efac;
}
[data-theme="dark"] table .btn-primary {
    background: rgba(6,95,70,0.15);
    border-color: rgba(52,211,153,0.3);
    color: #6ee7b7;
}

/* ── Modern topbar action buttons ────────────────────────────── */
.topbar-right .btn-sm,
.topbar-right .btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    height: 30px;
    padding: 0 0.75rem;
    border-radius: 7px;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    letter-spacing: 0.01em;
    transition: background 0.15s, box-shadow 0.15s, transform 0.1s;
}

.topbar-right .btn-sm:hover,
.topbar-right .btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

.topbar-right .btn-sm:active,
.topbar-right .btn:active {
    transform: translateY(0);
    box-shadow: none;
}

/* Primary — crimson solid */
.topbar-right .btn-primary {
    background: #c0152a;
    border-color: #c0152a;
    color: #fff;
}
.topbar-right .btn-primary:hover {
    background: #a01020;
    border-color: #a01020;
    color: #fff;
}

/* Outline — neutral */
.topbar-right .btn-outline {
    background: #f8fafc;
    border-color: #e2e8f0;
    color: #374151;
}
.topbar-right .btn-outline:hover {
    background: #f1f5f9;
    border-color: #d1d5db;
    color: #1a2744;
}

/* Success / green */
.topbar-right .btn-success {
    background: #ecfdf5;
    border-color: #6ee7b7;
    color: #065f46;
}
.topbar-right .btn-success:hover {
    background: #d1fae5;
    border-color: #34d399;
}

/* Warning / amber */
.topbar-right .btn-warning {
    background: #fefce8;
    border-color: #fde68a;
    color: #854d0e;
}
.topbar-right .btn-warning:hover {
    background: #fef9c3;
    border-color: #fcd34d;
}

/* Danger / rose */
.topbar-right .btn-danger {
    background: #fff1f2;
    border-color: #fecaca;
    color: #dc2626;
}
.topbar-right .btn-danger:hover {
    background: #fee2e2;
    border-color: #fca5a5;
}

/* Dark mode topbar buttons */
[data-theme="dark"] .topbar-right .btn-primary {
    background: #c0152a;
    border-color: #c0152a;
    color: #fff;
}
[data-theme="dark"] .topbar-right .btn-outline {
    background: rgba(255,255,255,0.06);
    border-color: rgba(255,255,255,0.12);
    color: #cbd5e1;
}
[data-theme="dark"] .topbar-right .btn-outline:hover {
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.2);
    color: #ffffff;
}
[data-theme="dark"] .topbar-right .btn-danger {
    background: rgba(220,38,38,0.12);
    border-color: rgba(220,38,38,0.3);
    color: #fca5a5;
}
