/* Layout */
body {
    background: #eef2f7;
    font-family: 'Segoe UI', Tahoma, sans-serif;
    min-height: 100vh;
}
.app-wrapper {
    display: flex;
    min-height: 100vh;
}
.sidebar {
    width: 250px;
    min-width: 250px;
    background: #1e2b37;
    color: #fff;
    padding: 1.5rem 1rem;
    height: 100vh;
    position: sticky;
    top: 0;
    overflow-y: auto;
}
.sidebar .brand {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    color: #f1c40f;
}
.sidebar .nav-link {
    color: rgba(255,255,255,0.7);
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.sidebar .nav-link:hover {
    color: #fff;
    background: rgba(255,255,255,0.1);
}
.sidebar .nav-link.active {
    color: #fff;
    background: #2c3e50;
    box-shadow: inset 3px 0 0 #f1c40f;
}
.sidebar .nav-link i {
    font-size: 1.2rem;
    width: 1.5rem;
    text-align: center;
}
.main-content {
    flex: 1;
    padding: 1.5rem 2rem;
    background: #f8fafc;
}
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #dee2e6;
}
.topbar .user-area {
    display: flex;
    align-items: center;
    gap: 1rem;
}
.topbar .user-area .avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #f1c40f;
}
.login-form .input-group {
    max-width: 280px;
}
.login-form .input-group input {
    border-radius: 0.5rem 0 0 0.5rem;
}
.login-form .input-group button {
    border-radius: 0 0.5rem 0.5rem 0;
}
.page-content {
    background: #fff;
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        min-width: unset;
        height: auto;
        position: relative;
        padding: 1rem;
    }
    .app-wrapper {
        flex-direction: column;
    }
    .topbar {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    .login-form .input-group {
        max-width: 100%;
    }
}

/* Dark Theme Overrides */
body.theme-dark {
    background-color: #121212;
    color: #e0e0e0;
}

/* Sidebar */
body.theme-dark .sidebar {
    background: #1a1a2e;
    border-right: 1px solid #2a2a4a;
}
body.theme-dark .sidebar .nav-link {
    color: rgba(255,255,255,0.6);
}
body.theme-dark .sidebar .nav-link:hover {
    background: rgba(255,255,255,0.05);
}
body.theme-dark .sidebar .nav-link.active {
    background: #2c3e50;
    color: #fff;
}

/* Topbar */
body.theme-dark .topbar {
    border-bottom-color: #2a2a4a;
}

/* Main content wrapper */
body.theme-dark .main-content {
    background: #1e1e2e;
}

/* Page content panels */
body.theme-dark .page-content {
    background: #16213e;
    color: #e0e0e0;
    border: 1px solid #2a3a5e;
    box-shadow: none;
}

/* Cards */
body.theme-dark .card {
    background: #1a1a2e;
    border-color: #2a3a5e;
}
body.theme-dark .card-header {
    background: #2a2a4a;
    border-bottom-color: #3a3a5a;
}
body.theme-dark .card-body {
    color: #e0e0e0;
}

/* Tables */
body.theme-dark .table {
    color: #e0e0e0;
}
body.theme-dark .table th {
    background: #2a2a4a;
    border-color: #3a3a5a;
}
body.theme-dark .table td {
    border-color: #3a3a5a;
}
body.theme-dark .table-striped tbody tr:nth-of-type(odd) {
    background: rgba(255,255,255,0.03);
}
body.theme-dark .table-hover tbody tr:hover {
    background: rgba(255,255,255,0.06);
}

/* Forms */
body.theme-dark .form-control,
body.theme-dark .form-select {
    background: #1e1e2e;
    border-color: #3a3a5a;
    color: #e0e0e0;
}
body.theme-dark .form-control:focus,
body.theme-dark .form-select:focus {
    background: #1e1e2e;
    border-color: #f1c40f;
    color: #e0e0e0;
}

/* Alerts */
body.theme-dark .alert-warning {
    background: #2d2d1a;
    border-color: #f1c40f;
    color: #f1c40f;
}
body.theme-dark .alert-danger {
    background: #3d1a1a;
    border-color: #e74c3c;
    color: #e74c3c;
}
body.theme-dark .alert-success {
    background: #1a3d1a;
    border-color: #2ecc71;
    color: #2ecc71;
}
body.theme-dark .alert-info {
    background: #1a2d3d;
    border-color: #3498db;
    color: #3498db;
}

/* Buttons (outline variants) */
body.theme-dark .btn-outline-secondary {
    color: #ccc;
    border-color: #5a5a7a;
}
body.theme-dark .btn-outline-secondary:hover {
    background: #5a5a7a;
    color: #fff;
}
body.theme-dark .btn-outline-danger {
    color: #e74c3c;
    border-color: #e74c3c;
}
body.theme-dark .btn-outline-danger:hover {
    background: #e74c3c;
    color: #fff;
}
body.theme-dark .btn-outline-primary {
    color: #3498db;
    border-color: #3498db;
}
body.theme-dark .btn-outline-primary:hover {
    background: #3498db;
    color: #fff;
}

/* Badges */
body.theme-dark .badge.bg-secondary {
    background: #4a4a6a !important;
}
body.theme-dark .badge.bg-success {
    background: #2ecc71 !important;
}
body.theme-dark .badge.bg-warning {
    background: #f1c40f !important;
    color: #1a1a2e;
}
body.theme-dark .badge.bg-danger {
    background: #e74c3c !important;
}
body.theme-dark .badge.bg-light {
    background: #3a3a5a !important;
    color: #e0e0e0 !important;
}

/* Misc elements used in modules */
body.theme-dark .faction-header-clean {
    background: #1e2b3e;
}
body.theme-dark .faction-header-clean .leader-info a {
    color: #f1c40f;
}
body.theme-dark .faction-header-clean .rank-info {
    color: #aaa;
}
body.theme-dark .dashboard-stats .stat-card {
    background: #1a1a2e;
    border-color: #2a3a5e;
}
body.theme-dark .dashboard-stats .stat-card .number {
    color: #f1c40f;
}
body.theme-dark .dashboard-stats .stat-card .label {
    color: #aaa;
}
body.theme-dark .transparency-box {
    background: #1a1a2e;
    border-left-color: #f1c40f;
}
body.theme-dark .transparency-box ul {
    color: #ccc;
}
body.theme-dark .war-toolbar {
    background: #1a1a2e;
    border-color: #2a3a5e;
}
body.theme-dark .war-toolbar .badge-faction-id {
    background: #2a2a4a;
    color: #ccc;
}
body.theme-dark .member-row {
    /* override row background – we keep the inline style from PHP, but we can add a fallback */
}
body.theme-dark .member-row td {
    border-color: #3a3a5a;
}
body.theme-dark .member-row:hover {
    filter: brightness(0.9);
}
body.theme-dark .status-cell .countdown-badge {
    background: rgba(255,255,255,0.1);
    color: #ccc;
}
body.theme-dark .faction-card {
    background: #1a1a2e;
    border-color: #2a3a5e;
}
body.theme-dark .faction-card.selected {
    border-color: #f1c40f;
}
body.theme-dark .faction-card.opponent {
    border-color: #e74c3c;
}
body.theme-dark .stat-label {
    color: #aaa;
}
body.theme-dark .stat-value {
    color: #f1c40f;
}
body.theme-dark .payout-highlight {
    color: #2ecc71;
}
body.theme-dark .item-badge {
    background: #2a2a4a;
    color: #ccc;
}
body.theme-dark .total-row {
    background: #2a2a4a !important;
}
body.theme-dark .total-row td {
    color: #f1c40f;
}
/* All headings, paragraphs, labels, small text */
body.theme-dark h1, body.theme-dark h2, body.theme-dark h3,
body.theme-dark h4, body.theme-dark h5, body.theme-dark h6,
body.theme-dark p, body.theme-dark .text-muted,
body.theme-dark .text-secondary, body.theme-dark .form-label,
body.theme-dark .form-text, body.theme-dark .small,
body.theme-dark .stat-label, body.theme-dark .matchup,
body.theme-dark .war-id, body.theme-dark .badge-faction-id {
    color: #e0e0e0;
}

/* Table cells – explicit color */
body.theme-dark .table td,
body.theme-dark .table th {
    color: #e0e0e0;
}

/* Ensure table headers are not too bright */
body.theme-dark .table th {
    color: #ccc;
}

/* Make muted text a bit lighter but still muted */
body.theme-dark .text-muted {
    color: #aaa !important;
}

/* Checkboxes and their labels (if any) */
body.theme-dark .form-check-label {
    color: #e0e0e0;
}

/* Table rows – even rows background (Bootstrap default) */
body.theme-dark .table-striped tbody tr:nth-of-type(odd) {
    background: rgba(255,255,255,0.04);
}

/* Hover effect should also have readable text */
body.theme-dark .table-hover tbody tr:hover td,
body.theme-dark .table-hover tbody tr:hover th {
    color: #fff;
    background: rgba(255,255,255,0.08);
}
/* ---- Faction member rows in dark mode ---- */
body.theme-dark .member-row td {
    background-color: rgba(0, 0, 0, 0.4) !important;  /* darkens the row background */
    color: #fff !important;
    border-color: #3a3a5a;
}

body.theme-dark .member-row a {
    color: #f1c40f;
}

body.theme-dark .member-row .status-text {
    color: #fff;
}

body.theme-dark .member-row .countdown-badge {
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
}

body.theme-dark .member-row .status-dot {
    border: 1px solid rgba(255, 255, 255, 0.3);
}
/* ---- Status column in dark mode (crisp & readable) ---- */
body.theme-dark .status-text {
    color: #fff !important;
    text-shadow: 0 0 8px rgba(0, 0, 0, 0.9), 0 0 2px rgba(0, 0, 0, 0.8);
    font-weight: 500;
}

/* Keep the status dot visible with a slight glow */
body.theme-dark .status-dot {
    box-shadow: 0 0 6px rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

/* Countdown badges - dark background, white text */
body.theme-dark .countdown-badge {
    background: rgba(0, 0, 0, 0.7) !important;
    color: #fff !important;
    border-radius: 3px;
    padding: 0 6px;
}
/* ---- Unified Table Headers (Light & Dark) ---- */

/* Light mode table headers */
.table thead th {
    background: #f1f3f6;
    color: #2c3e50;
    font-weight: 600;
    border-bottom: 2px solid #dee2e6;
    padding: 0.6rem 0.75rem;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* Dark mode table headers */
body.theme-dark .table thead th {
    background: #2a2a4a;
    color: #e0e0e0;
    border-bottom: 2px solid #3a3a5a;
}

/* Table header links (for sortable columns) */
.table thead th a {
    color: inherit;
    text-decoration: none;
    display: block;
}

body.theme-dark .table thead th a {
    color: #e0e0e0;
}

.table thead th a:hover {
    background: rgba(0, 0, 0, 0.04);
}

body.theme-dark .table thead th a:hover {
    background: rgba(255, 255, 255, 0.05);
}

/* Table cells - consistent padding */
.table td {
    padding: 0.5rem 0.75rem;
    vertical-align: middle;
    font-size: 0.9rem;
}

/* Table footer (totals) */
.table tfoot td {
    font-weight: 600;
    background: #f8f9fa;
    border-top: 2px solid #dee2e6;
}

body.theme-dark .table tfoot td {
    background: #2a2a4a;
    border-top: 2px solid #3a3a5a;
    color: #f1c40f;
}
/* ---- Profile page dark mode ---- */
body.theme-dark .profile-card {
    background: #1a1a2e;
    border-color: #2a3a5e;
}
body.theme-dark .profile-name {
    color: #fff;
}

body.theme-dark .profile-level {
    color: #ccc;
}

body.theme-dark .profile-stats dt {
    color: #aaa;
}

body.theme-dark .profile-stats dd {
    color: #e0e0e0;
}

body.theme-dark .profile-stats .text-muted {
    color: #aaa !important;
}

/* Battle stats table */
body.theme-dark .profile-stats table th {
    background: #2a2a4a;
    color: #ccc;
    border-color: #3a3a5a;
}

body.theme-dark .profile-stats table td {
    color: #e0e0e0;
    border-color: #3a3a5a;
}

body.theme-dark .profile-stats table .table-active {
    background: #2a2a4a;
}

body.theme-dark .profile-stats table .table-active td {
    color: #f1c40f;
}

/* Settings labels */
body.theme-dark .settings-section h6 {
    color: #e0e0e0;
}

body.theme-dark .settings-section .form-label {
    color: #ccc;
}

body.theme-dark .settings-section .form-text {
    color: #aaa !important;
}

body.theme-dark .text-danger {
    color: #e74c3c !important;
}
/* Sidebar dropdown toggles */
.sidebar .nav-link[data-bs-toggle="collapse"] {
    cursor: pointer;
}
.sidebar .nav-link[data-bs-toggle="collapse"] .bi-chevron-down {
    transition: transform 0.2s;
}
.sidebar .nav-link[data-bs-toggle="collapse"][aria-expanded="true"] .bi-chevron-down {
    transform: rotate(180deg);
}

/* Nested nav items indentation */
.sidebar .ms-3 {
    margin-left: 1.5rem !important;
}
.sidebar .ms-3 .nav-link {
    padding: 0.3rem 0.75rem;
    font-size: 0.9rem;
}
.sidebar .ms-3 .nav-link i {
    font-size: 1rem;
    width: 1.2rem;
    text-align: center;
}

/* Dark theme adjustments */
body.theme-dark .sidebar .nav-link[data-bs-toggle="collapse"] {
    color: rgba(255,255,255,0.7);
}
body.theme-dark .sidebar .nav-link[data-bs-toggle="collapse"]:hover {
    color: #fff;
}
body.theme-dark .sidebar .ms-3 .nav-link {
    color: rgba(255,255,255,0.6);
}
body.theme-dark .sidebar .ms-3 .nav-link:hover {
    color: #fff;
}
body.theme-dark .sidebar .ms-3 .nav-link.active {
    color: #fff;
    background: #2c3e50;
}
/* Profile Details */
.profile-details {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #e9ecef;
}
body.theme-dark .profile-details {
    border-top-color: #3a3a5a;
}

.detail-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem 0.75rem;
    background: #f8f9fa;
    border-radius: 0.5rem;
    margin-bottom: 0.25rem;
}
body.theme-dark .detail-item {
    background: #1a1a2e;
}

.detail-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
body.theme-dark .detail-label {
    color: #999;
}

.detail-value {
    font-weight: 600;
    color: #212529;
}
body.theme-dark .detail-value {
    color: #e0e0e0;
}
/* Profile Details */
.profile-details {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #e9ecef;
}
body.theme-dark .profile-details {
    border-top-color: #3a3a5a;
}

.detail-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem 0.75rem;
    background: #f8f9fa;
    border-radius: 0.5rem;
    margin-bottom: 0.25rem;
}
body.theme-dark .detail-item {
    background: #1a1a2e;
}

.detail-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
body.theme-dark .detail-label {
    color: #999;
}

.detail-value {
    font-weight: 600;
    color: #212529;
}
body.theme-dark .detail-value {
    color: #e0e0e0;
}

/* Profile avatar */
.profile-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid #f1c40f;
}
/* Property dashboard */
body.theme-dark .property-dashboard .bg-light {
    background: #1a1a2e !important;
    border-color: #2a3a5e !important;
}
body.theme-dark .property-dashboard .text-muted {
    color: #aaa !important;
}
body.theme-dark .property-dashboard .border {
    border-color: #2a3a5e !important;
}
body.theme-dark .property-dashboard .text-success {
    color: #4caf50 !important;
}
body.theme-dark .property-dashboard .text-info {
    color: #4fc3f7 !important;
}
body.theme-dark .property-dashboard .text-warning {
    color: #ffb74d !important;
}
body.theme-dark .property-dashboard .text-danger {
    color: #ef5350 !important;
}
body.theme-dark .property-dashboard .btn-outline-primary {
    color: #4fc3f7;
    border-color: #4fc3f7;
}
body.theme-dark .property-dashboard .btn-outline-primary:hover {
    background: #4fc3f7;
    color: #1a1a2e;
}

/* Intel page */
body.theme-dark .intel-card {
    background: #1a1a2e !important;
    border-color: #2a3a5e !important;
}
body.theme-dark .intel-card .number {
    color: #e0e0e0;
}
body.theme-dark .intel-card .label {
    color: #aaa;
}
body.theme-dark .performer-item {
    background: #1a1a2e !important;
}
body.theme-dark .type-item {
    background: #1a1a2e !important;
}
/* Sort indicators */
.sort-icon {
    display: inline-block;
    font-size: 0.7rem;
    color: var(--tpm-text-soft, #6c757d);
    transition: color 0.2s;
}
th:hover .sort-icon {
    color: var(--tpm-text-strong, #212529);
}
body.theme-dark th:hover .sort-icon {
    color: #fff;
}
/* Sidebar – compact */
.sidebar {
    padding: 0.5rem 0.5rem;
    overflow-y: visible !important;  /* removes scrollbar */
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.sidebar .brand img {
    height: 40px !important;
    margin-right: 4px;
}

#utc-clock {
    font-size: 0.65rem !important;
    margin: 0 0 0.35rem 0 !important;
}

.sidebar .nav-link {
    padding: 0.2rem 0.4rem;
    font-size: 0.85rem;
}

.sidebar .nav-link[style*="padding-left: 1.5rem"] {
    font-size: 0.8rem;
    padding-top: 0.1rem;
    padding-bottom: 0.1rem;
}

.sidebar .ms-2 {
    margin-left: 0.25rem !important;
}

.sidebar hr {
    margin: 0.15rem 0;
}

.sidebar .small.text-muted {
    font-size: 0.6rem;
    margin-top: auto;
    padding-top: 0.15rem;
}
/* Perks Card Styles */
.perks-card {
    background: var(--tpm-card-bg, #fff);
    border: 1px solid var(--tpm-border, #e9ecef);
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
}
body.theme-dark .perks-card {
    background: #1a1a2e;
    border-color: #2a3a5e;
}
.perks-card .perks-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}
.perks-card .perks-header h6 {
    margin: 0;
    font-weight: 600;
}
.perks-card .perks-header .perk-count {
    font-size: 0.75rem;
    color: var(--tpm-text-soft, #6c757d);
}
.perks-card .perks-header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.perks-card .perks-header-actions .text-muted {
    font-size: 0.7rem;
}
.perks-tabs {
    margin-bottom: 0.5rem;
    border-bottom: 1px solid var(--tpm-border, #dee2e6);
}
.perks-tabs .nav-link {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    color: var(--tpm-text, #212529);
    border: none;
    border-bottom: 2px solid transparent;
}
.perks-tabs .nav-link.active {
    color: var(--tpm-info, #0d6efd);
    background: transparent;
    border-bottom-color: var(--tpm-info, #0d6efd);
}
.perks-tabs .nav-link .badge {
    font-size: 0.6rem;
    padding: 0.1rem 0.35rem;
    background: var(--tpm-border, #dee2e6);
    color: var(--tpm-text, #212529);
}
.perks-tabs .nav-link.active .badge {
    background: var(--tpm-info, #0d6efd);
    color: #fff;
}
body.theme-dark .perks-tabs .nav-link {
    color: #ccc;
}
body.theme-dark .perks-tabs .nav-link.active {
    color: #4fc3f7;
    border-bottom-color: #4fc3f7;
}
body.theme-dark .perks-tabs .nav-link .badge {
    background: #2a3a5e;
    color: #ccc;
}
body.theme-dark .perks-tabs .nav-link.active .badge {
    background: #0d6efd;
    color: #fff;
}

.perks-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem 0.5rem;
    padding: 0.2rem 0;
    max-height: 300px;
    overflow-y: auto;
}
.perks-grid::-webkit-scrollbar {
    width: 4px;
}
.perks-grid::-webkit-scrollbar-thumb {
    background: var(--tpm-border, #ced4da);
    border-radius: 2px;
}
.perk-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.7rem;
    padding: 0.1rem 0.5rem 0.1rem 0.3rem;
    border-radius: 999px;
    border: 1px solid var(--tpm-border, #dee2e6);
    background: var(--tpm-card-bg, #f8f9fa);
    white-space: nowrap;
    max-width: 100%;
}
body.theme-dark .perk-tag {
    background: #1a1a2e;
    border-color: #2a3a5e;
}
.perk-tag .source-badge {
    font-size: 0.55rem;
    font-weight: 600;
    text-transform: uppercase;
    padding: 0.05rem 0.3rem;
    border-radius: 999px;
    background: #0d6efd;
    color: #fff;
    flex-shrink: 0;
}
.perk-tag .source-badge.faction { background: #dc3545; }
.perk-tag .source-badge.job { background: #fd7e14; }
.perk-tag .source-badge.property { background: #28a745; }
.perk-tag .source-badge.education { background: #6f42c1; }
.perk-tag .source-badge.enhancer { background: #e83e8c; }
.perk-tag .source-badge.book { background: #20c997; }
.perk-tag .source-badge.stock { background: #17a2b8; }
.perk-tag .source-badge.merit { background: #ffc107; color: #212529; }

.perk-tag .perk-text {
    color: var(--tpm-text, #212529);
    font-size: 0.7rem;
    overflow: hidden;
    text-overflow: ellipsis;
}
body.theme-dark .perk-tag .perk-text {
    color: #e0e0e0;
}