/* Shell styles copied from the coupon CRM (cfa/crm/assets/app.css + main.css).
   CRM-only selectors (SweetAlert2, Tom Select, rate widget, API docs, stores summary, copy chips) removed. */

:root {
    --bg-body: #0f1015;
    --bg-sidebar: #16171d;
    --bg-card: #1e1f26;
    --text-primary: #e0e6ed;
    --text-muted: #d1d5db;
    --border-color: #2b2d36;
    --accent-gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    --accent-hover: linear-gradient(135deg, #4f46e5 0%, #9333ea 100%);
    --danger-gradient: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%);
    --success-gradient: linear-gradient(135deg, #22c55e 0%, #15803d 100%);
    --warning-gradient: linear-gradient(135deg, #f59e0b 0%, #b45309 100%);
}

body {
    background-color: var(--bg-body);
    color: var(--text-primary);
    font-family: 'Source Sans Pro', -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-body); 
}
::-webkit-scrollbar-thumb {
    background: #4b5563; 
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #6b7280; 
}

/* Login Page */
.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background: radial-gradient(circle at center, #1f2937 0%, #0f1015 100%);
}

.login-box {
    width: 400px;
    background: var(--bg-card);
    padding: 2.5rem;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    border: 1px solid var(--border-color);
}

.login-box h3 {
    margin-bottom: 30px;
    font-weight: 300;
    letter-spacing: 1px;
}

.form-control {
    background-color: #2a2b35;
    border: 1px solid #3f4250;
    color: var(--text-primary);
}

.form-control:focus {
    background-color: #2a2b35;
    border-color: #6366f1;
    color: var(--text-primary);
    box-shadow: 0 0 0 0.2rem rgba(99, 102, 241, 0.25);
}

.input-group-text {
    background-color: #323541;
    border: 1px solid #3f4250;
    color: var(--text-muted);
}

/* Layout */
.wrapper {
    display: flex;
    width: 100%;
    align-items: stretch;
}

#sidebar {
    min-width: 240px;
    max-width: 240px;
    background: var(--bg-sidebar);
    color: var(--text-primary);
    transition: all 0.3s;
    min-height: 100vh;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

#sidebar .sidebar-header {
    padding: 18px 16px 14px;
    background: var(--bg-sidebar);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

#sidebar .sidebar-header h3 {
    font-weight: 700;
    font-size: 0.9rem;
    letter-spacing: 2px;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 2px;
}

#sidebar .sidebar-header .text-muted {
    color: #ffffff !important;
}

#sidebar .sidebar-header p {
    font-size: 0.72rem;
    opacity: 0.4;
    margin: 0;
}

#sidebar ul.components {
    padding: 6px 0 10px;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Thin inner scrollbar */
#sidebar ul.components::-webkit-scrollbar { width: 3px; }
#sidebar ul.components::-webkit-scrollbar-track { background: transparent; }
#sidebar ul.components::-webkit-scrollbar-thumb { background: #2b2d36; border-radius: 3px; }

/* Collapsible sidebar groups */
#sidebar .sidebar-group {
    margin: 0;
}

#sidebar .sidebar-group-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px 6px;
    cursor: pointer;
    user-select: none;
    transition: color 0.15s;
}

#sidebar .sidebar-group-toggle span {
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 1.4px;
    text-transform: uppercase;
    color: #555a6e;
    transition: color 0.15s;
}

#sidebar .sidebar-group-toggle:hover span {
    color: #8b90a5;
}

#sidebar .sidebar-group-chevron {
    font-size: 0.5rem;
    color: #3e4255;
    transition: transform 0.25s ease, color 0.15s;
}

#sidebar .sidebar-group-toggle:hover .sidebar-group-chevron {
    color: #6b7090;
}

#sidebar .sidebar-group.collapsed .sidebar-group-chevron {
    transform: rotate(-90deg);
}

#sidebar .sidebar-group-items {
    list-style: none;
    padding: 0;
    margin: 0;
    overflow: hidden;
    max-height: 500px;
    transition: max-height 0.3s ease;
}

#sidebar .sidebar-group.collapsed .sidebar-group-items {
    max-height: 0;
}

#sidebar ul li.nav-item a {
    padding: 7px 16px;
    font-size: 0.82rem;
    line-height: 1.3;
    display: flex;
    align-items: center;
    color: #7c8091;
    text-decoration: none;
    transition: color 0.15s, background 0.15s;
    border-left: 2px solid transparent;
    margin: 0;
}

#sidebar ul li.nav-item a span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#sidebar ul li.nav-item a:hover {
    color: #b8bdd0;
    background: rgba(255,255,255,0.025);
}

#sidebar ul li.active > a {
    color: #e0e4f0;
    background: rgba(99, 102, 241, 0.08);
    border-left-color: #6366f1;
}

#sidebar ul li.nav-item a i {
    width: 18px;
    min-width: 18px;
    text-align: center;
    margin-right: 10px;
    font-size: 0.78rem;
    opacity: 0.45;
    flex-shrink: 0;
}

#sidebar ul li.nav-item a:hover i {
    opacity: 0.7;
}

#sidebar ul li.active > a i {
    opacity: 0.9;
}

/* Sidebar footer */
#sidebar .sidebar-footer {
    padding: 10px 14px !important;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

#sidebar .sidebar-footer .btn {
    font-size: 0.78rem;
    padding: 5px 0;
    border-radius: 6px;
}

#content {
    width: 100%;
    padding: 2.5rem;
    min-height: 100vh;
    transition: all 0.3s;
    background: #0f1015;
}

/* Top Navbar */
.navbar {
    padding: 0;
    background: transparent !important;
    border-bottom: none;
    margin-bottom: 2rem !important;
}

#sidebarCollapse {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    box-shadow: none;
}

/* Cards */
.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    border-radius: 8px;
    margin-bottom: 25px;
}

.card-header {
    background-color: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: 1.25rem;
}

.card-header h5 {
    color: var(--text-primary);
    font-weight: 600;
    margin: 0;
}

.card-body {
    color: var(--text-muted);
    padding: 1.5rem;
}

/* Buttons */
.btn-primary {
    background: var(--accent-gradient);
    border: none;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}
.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: 0 6px 15px rgba(99, 102, 241, 0.4);
}

.btn-danger {
    background: var(--danger-gradient);
    border: none;
}
.btn-success {
    background: var(--success-gradient);
    border: none;
}
.btn-warning {
    background: var(--warning-gradient);
    border: none;
    color: #fff;
}

.badge.bg-warning {
    background: #b45309 !important;
    color: #fff !important;
}

.badge.bg-info {
    background: #0e7490 !important;
    color: #fff !important;
}

/* Tables */
.table {
    color: var(--text-primary);
    border-color: var(--border-color);
}

.table>:not(caption)>*>* {
    background-color: transparent;
    border-bottom-color: var(--border-color);
    padding: 1rem 0.5rem;
}

.table-striped>tbody>tr:nth-of-type(odd)>* {
    color: var(--text-primary);
    background-color: rgba(255,255,255,0.02);
}

/* Fix for Even rows visibility */
.table-striped>tbody>tr:nth-of-type(even)>* {
    color: var(--text-primary) !important;
    background-color: transparent;
}

table.dataTable tbody tr.even {
    background-color: transparent !important;
}

table.dataTable tbody tr {
    color: var(--text-primary) !important;
}

.table-hover>tbody>tr:hover>* {
    color: #fff;
    background-color: rgba(255,255,255,0.05);
}

thead th {
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 1px;
    color: #ffffff !important;
    background-color: #1f2029;
    padding: 12px !important;
    border-bottom: 2px solid var(--border-color) !important;
}

/* DataTables Overrides */
.dataTables_wrapper .dataTables_length, 
.dataTables_wrapper .dataTables_filter, 
.dataTables_wrapper .dataTables_info, 
.dataTables_wrapper .dataTables_processing, 
.dataTables_wrapper .dataTables_paginate {
    color: var(--text-muted) !important;
    margin-bottom: 1rem;
}

.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
    background-color: #2a2b35;
    border: 1px solid #3f4250;
    color: var(--text-primary);
    border-radius: 4px;
    padding: 4px 8px;
}

.page-item.disabled .page-link {
    background-color: #2a2b35;
    border-color: #3f4250;
    color: #6c757d;
}

.page-item.active .page-link {
    background: var(--accent-gradient);
    border-color: transparent;
}

.page-link {
    background-color: #2a2b35;
    border-color: #3f4250;
    color: var(--text-primary);
}

.page-link:hover {
    background-color: #3f4250;
    border-color: #3f4250;
    color: #fff;
}

/* Page content fade-in */
#page-content {
    opacity: 1;
    transition: opacity 0.18s ease;
}
#page-content.fade-out {
    opacity: 0;
}

/* DataTable processing overlay - modern */
.dataTables_processing {
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    width: auto !important;
    margin: 0 !important;
    padding: 1rem 2rem !important;
    background: rgba(15, 16, 21, 0.92) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 10px !important;
    color: var(--text-muted) !important;
    font-size: 0.85rem !important;
    backdrop-filter: blur(4px) !important;
    z-index: 50 !important;
    align-items: center !important;
    gap: 10px !important;
}
.dataTables_processing[style*="display: block"] {
    display: flex !important;
}
.dataTables_processing::before {
    content: '';
    width: 18px;
    height: 18px;
    border: 2px solid #3f4250;
    border-top-color: #6366f1;
    border-radius: 50%;
    animation: dtSpin 0.7s linear infinite;
    flex-shrink: 0;
}
@keyframes dtSpin {
    to { transform: rotate(360deg); }
}

/* Card body table area - relative for processing */
.card-body { position: relative; }

/* Button loading state */
.btn.is-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}
.btn.is-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 14px;
    height: 14px;
    margin: -7px 0 0 -7px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: dtSpin 0.6s linear infinite;
}

/* Center DataTable cell content both axes. */
.card-body table.table > tbody > tr > td,
.card-body table.table > thead > tr > th {
    vertical-align: middle !important;
    text-align: center !important;
    padding-top: 12px !important;
    padding-bottom: 12px !important;
}

/* ── Negative-balance row highlight ──────────────────────────────────
   The custom `.table > :not(caption) > * > *` rule above resets the cell
   background to transparent, which silently overrides Bootstrap's
   `.table-danger` cell tint. Re-assert it with high specificity so rows
   flagged in createdRow() actually show red. */
table.dataTable tbody tr.table-danger,
table.dataTable tbody tr.table-danger > *,
.table-striped > tbody > tr.table-danger:nth-of-type(odd) > *,
.table-striped > tbody > tr.table-danger:nth-of-type(even) > * {
    background-color: rgba(220, 53, 69, 0.18) !important;
    color: #fecaca !important;
}
table.dataTable tbody tr.table-danger:hover,
table.dataTable tbody tr.table-danger:hover > * {
    background-color: rgba(220, 53, 69, 0.28) !important;
}

/* ====== From main.css (utilities) ====== */

.table td,
.table th {
    text-align: center;
    vertical-align: middle;
}

.spinner-border {
    width: 1rem !important;
    height: 1rem !important;
    font-size: 10px !important;
}

.form-control::placeholder {
    color: #757575;
    opacity: 1;
}

.btn-secondary {
    color: #ffffff !important;
    font-weight: 500 !important;
}

.pagination {
    font-weight: 500 !important;
}

.page-link {
    box-shadow: none !important;
}

div.dataTables_wrapper div.dataTables_length label {
    margin-bottom: 0px;
    padding-top: 5px;
    padding-bottom: 5px;
}

.card-title {
    padding-top: 4px;
    padding-bottom: 4px;
}
