/* ========================================
   TFF - Tobacco Free Farmers
   Custom Styles
   ======================================== */

:root {
    --app-sidebar-width: 260px;
    --app-shell-gutter: 1.5rem;
}

/* Base font */
body {
    font-family: 'Montserrat', sans-serif;
    font-size: 0.875rem;
    background-color: #f4f6f9;
    color: #333;
    overflow-x: hidden;
}

/* ========================================
   Sidebar
   ======================================== */
.sidebar {
    height: 100vh;
    height: 100dvh;
    min-height: 100vh;
    background: linear-gradient(180deg, #03173c 0%, #05245a 56%, #02112f 100%);
    color: #fff;
    width: var(--app-sidebar-width);
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1040;
    transition: all 0.3s ease;
    box-shadow: 4px 0 20px rgba(0,0,0,0.15);
    display: block;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.35) transparent;
}

.sidebar::-webkit-scrollbar {
    width: 7px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.3);
    border-radius: 999px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.48);
}

.sidebar > .nav {
    overflow: visible;
    padding-bottom: 0.75rem;
}

.sidebar .nav-item {
    width: 100%;
}

.sidebar .sidebar-brand {
    padding: 1.25rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    text-align: center;
}

.sidebar .sidebar-brand h4 {
    font-weight: 700;
    margin: 0;
    font-size: 1.1rem;
    letter-spacing: 0.5px;
}

.sidebar .sidebar-brand small {
    opacity: 0.7;
    font-size: 0.75rem;
}

.sidebar .nav-link {
    color: rgba(255,255,255,0.85);
    padding: 0.85rem 1.25rem;
    font-size: 0.88rem;
    font-weight: 500;
    border-left: 4px solid transparent;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    width: 100%;
    min-width: 0;
    overflow: hidden;
}

.sidebar .nav-link:hover,
.sidebar .nav-link.active {
    color: #fff;
    background: linear-gradient(90deg, rgba(255,255,255,0.15) 0%, rgba(255,255,255,0.05) 100%);
    border-left-color: #f4c430;
}

.sidebar .nav-link.active {
    background: linear-gradient(90deg, rgba(244,196,48,0.2) 0%, rgba(255,255,255,0.05) 100%);
    font-weight: 600;
}

.sidebar .nav-link i {
    width: 24px;
    text-align: center;
    margin-right: 12px;
    font-size: 1rem;
    opacity: 0.9;
}

.sidebar .nav-link .fw-semibold {
    font-weight: 600 !important;
}

.sidebar .nav-link span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar .nav-header {
    padding: 1.2rem 1.25rem 0.5rem;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    opacity: 0.5;
    font-weight: 700;
    color: #fff;
}

.sidebar-add-new .btn-success {
    background: linear-gradient(135deg, #031a42 0%, #07306f 100%);
    border: none;
    box-shadow: 0 4px 12px rgba(3,26,66,0.4);
    transition: all 0.3s ease;
}

.sidebar-add-new .btn-success:hover {
    background: linear-gradient(135deg, #05245a 0%, #0b3d89 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(10,79,168,0.5);
}

/* ========================================
   Main Content
   ======================================== */
.main-content {
    margin-left: var(--app-sidebar-width);
    width: calc(100% - var(--app-sidebar-width));
    max-width: calc(100vw - var(--app-sidebar-width));
    min-height: 100vh;
    transition: all 0.3s ease;
    min-width: 0;
    overflow-x: hidden;
}

/* ========================================
   Topbar
   ======================================== */
.topbar {
    background: #fff;
    padding: 0.75rem 1.5rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.04);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 1030;
}

.topbar > .d-flex {
    min-width: 0;
}

.topbar nav,
.topbar .breadcrumb {
    min-width: 0;
}

.topbar .breadcrumb {
    flex-wrap: wrap;
    row-gap: .15rem;
}

.topbar-search {
    min-width: 180px;
}

.topbar .btn-toggle-sidebar {
    border: none;
    background: none;
    font-size: 1.2rem;
    color: #555;
    cursor: pointer;
}

/* ========================================
   Content Area
   ======================================== */
.content-wrapper {
    padding: var(--app-shell-gutter);
    min-width: 0;
    max-width: 100%;
}

.card,
.table-card,
.stat-card,
.dash-module-card,
.dash-chart-card,
.dash-list-card,
.table-responsive {
    min-width: 0;
}

/* ========================================
   Stat Cards (Dashboard)
   ======================================== */
.stat-card {
    border: none;
    border-radius: 0.75rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
}

.stat-card .stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
}

.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1;
}

.stat-card .stat-label {
    font-size: 0.75rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

/* ========================================
   Table Card
   ======================================== */
.table-card {
    border: none;
    border-radius: 0.75rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.table-card .card-header {
    background: #fff;
    border-bottom: 1px solid #eee;
    padding: 1rem 1.25rem;
    font-weight: 600;
}

/* ========================================
   Buttons
   ======================================== */
.btn {
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.3px;
    border-radius: 0.5rem;
}

.btn-success {
    background-color: #05245a;
    border-color: #05245a;
}

.btn-success:hover {
    background-color: #031a42;
    border-color: #031a42;
}

/* ========================================
   Page Header
   ======================================== */
.page-header {
    margin-bottom: 1.5rem;
}

.page-header h4 {
    font-weight: 700;
    color: #031a42;
    margin: 0;
}

/* ========================================
   Modals
   ======================================== */
.modal-header {
    background: linear-gradient(135deg, #031a42 0%, #07306f 100%);
    color: #fff;
    border-radius: 0;
}

.modal-header .btn-close {
    filter: brightness(0) invert(1);
}

.modal-title {
    font-weight: 600;
    font-size: 0.95rem;
}

/* ========================================
   Forms
   ======================================== */
.form-label {
    font-weight: 600;
    font-size: 0.8rem;
    color: #555;
    margin-bottom: 0.25rem;
}

.form-control,
.form-select {
    font-size: 0.85rem;
    border-radius: 0.5rem;
}

.form-control:focus,
.form-select:focus {
    border-color: #05245a;
    box-shadow: 0 0 0 0.2rem rgba(3,26,66,0.15);
}

/* ========================================
   Badge
   ======================================== */
.badge {
    font-weight: 600;
    font-size: 0.7rem;
    letter-spacing: 0.3px;
}

/* ========================================
   DataTables Overrides
   ======================================== */
.dataTables_wrapper {
    font-size: 0.85rem;
}

.dataTables_wrapper .dataTables_filter input {
    border-radius: 0.5rem;
    border: 1px solid #ced4da;
    padding: 0.375rem 0.75rem;
}

.dataTables_wrapper .dataTables_length select {
    border-radius: 0.5rem;
}

table.dataTable {
    font-size: 0.83rem;
}

table.dataTable thead th {
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    border-bottom: 2px solid #dee2e6;
}

/* ========================================
   Select2 Overrides
   ======================================== */
.select2-container--bootstrap-5 .select2-selection {
    border: 1px solid #ced4da;
    border-radius: 0.375rem;
    min-height: 38px;
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
    font-family: 'Montserrat', sans-serif;
}

.select2-container--bootstrap-5 .select2-selection--single .select2-selection__rendered {
    padding: 0;
    line-height: 1.5;
}

.select2-container--bootstrap-5 .select2-selection--single .select2-selection__arrow {
    height: 36px;
}

.select2-container--bootstrap-5 .select2-dropdown {
    border-color: #ced4da;
    border-radius: 0.375rem;
    font-size: 0.875rem;
}

.select2-container--bootstrap-5 .select2-results__option--highlighted[aria-selected] {
    background-color: #05245a;
}

/* Keep Select2 dropdown above Bootstrap modal backdrop (z-index 1055). */
.select2-container--open {
    z-index: 1060 !important;
}

/* ========================================
   Login Page
   ======================================== */
.login-wrapper {
    min-height: 100vh;
    background: linear-gradient(135deg, #03173c 0%, #05245a 55%, #07306f 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-wrapper .login-card {
    background: #fff;
    border-radius: 1rem;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
}

.login-wrapper .login-card .login-logo {
    text-align: center;
    margin-bottom: 1.5rem;
}

.login-wrapper .login-card .login-logo h3 {
    font-weight: 800;
    color: #031a42;
    margin-bottom: 0.25rem;
}

.login-wrapper .login-card .login-logo p {
    color: #888;
    font-size: 0.85rem;
}

/* ========================================
   Responsive Sidebar
   ======================================== */
.sidebar-collapsed .sidebar {
    margin-left: calc(var(--app-sidebar-width) * -1);
}

.sidebar-collapsed .main-content {
    margin-left: 0;
    width: 100%;
    max-width: 100vw;
}

@media (max-width: 768px) {
    :root {
        --app-shell-gutter: 1rem;
    }

    .sidebar {
        margin-left: calc(var(--app-sidebar-width) * -1);
    }

    .main-content {
        margin-left: 0;
        width: 100%;
        max-width: 100vw;
    }

    .sidebar-open .sidebar {
        margin-left: 0;
    }
}

/* ========================================
   Animations
   ======================================== */
.fade-in {
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ========================================
   SweetAlert2 Custom
   ======================================== */
.swal2-popup {
    font-family: 'Montserrat', sans-serif !important;
    font-size: 0.9rem !important;
}

/* ========================================
   Scrollbar
   ======================================== */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #aaa;
    border-radius: 3px;
}

/* ══════════════════════════════════════
   Dashboard Redesign
   ══════════════════════════════════════ */
.dash-banner {
    position: relative;
    background: linear-gradient(135deg, #03173c 0%, #05245a 55%, #07306f 100%);
    border-radius: 16px;
    padding: 1.25rem 2rem;
    overflow: hidden;
    color: #fff;
}
.dash-banner h3 {
    font-size: 1.35rem;
}
.dash-banner p {
    font-size: 0.85rem;
}
.dash-banner-overlay {
    position: absolute;
    inset: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.04'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zM36 6V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    pointer-events: none;
}
.dash-banner-content { position: relative; z-index: 1; }
.dash-search-box {
    position: relative;
    max-width: 420px;
}
.dash-search-box i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: #adb5bd;
    z-index: 2;
}
.dash-search-box .form-control {
    padding-left: 38px;
    border-radius: 50px;
    border: none;
    background: rgba(255,255,255,0.15);
    color: #fff;
    backdrop-filter: blur(4px);
}
.dash-search-box .form-control::placeholder { color: rgba(255,255,255,0.6); }
.dash-search-box .form-control:focus {
    background: rgba(255,255,255,0.25);
    box-shadow: 0 0 0 3px rgba(255,255,255,0.15);
    color: #fff;
}

/* Module Summary Cards */
.dash-module-card {
    background: #fff;
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    transition: transform 0.25s, box-shadow 0.25s;
    height: 100%;
    display: flex;
    flex-direction: column;
    border: none !important;
    position: relative;
}
.dash-module-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 12px 35px rgba(0,0,0,0.15);
}
.dash-module-card .card-decor-img {
    position: absolute;
    top: 0;
    right: 0;
    width: 55%;
    height: 100%;
    object-fit: cover;
    opacity: 0.55;
    pointer-events: none;
    mask-image: linear-gradient(to left, rgba(0,0,0,1) 0%, rgba(0,0,0,0) 80%);
    -webkit-mask-image: linear-gradient(to left, rgba(0,0,0,1) 0%, rgba(0,0,0,0) 80%);
}
.dash-module-header {
    padding: 0.85rem 1.2rem;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    border-radius: 18px 18px 0 0;
    position: relative;
    z-index: 2;
}
.dash-module-header i {
    font-size: 1rem;
}
.dash-module-header span {
    font-weight: 700 !important;
    letter-spacing: 0.3px;
}
/* Vibrant colored headers */
.dash-module-card.card-registry .dash-module-header {
    background: linear-gradient(135deg, #031a42 0%, #07306f 100%);
    color: #fff;
}
.dash-module-card.card-registry .dash-module-header i,
.dash-module-card.card-registry .dash-module-header span { color: #fff !important; }
.dash-module-card.card-ffs .dash-module-header {
    background: linear-gradient(135deg, #0077b6 0%, #00b4d8 100%);
    color: #fff;
}
.dash-module-card.card-ffs .dash-module-header i,
.dash-module-card.card-ffs .dash-module-header span { color: #fff !important; }
.dash-module-card.card-vsla .dash-module-header {
    background: linear-gradient(135deg, #d4a017 0%, #f4c430 100%);
    color: #fff;
}
.dash-module-card.card-vsla .dash-module-header i,
.dash-module-card.card-vsla .dash-module-header span { color: #fff !important; }
.dash-module-card.card-marketplace .dash-module-header {
    background: linear-gradient(135deg, #bc6c25 0%, #e09f3e 100%);
    color: #fff;
}
.dash-module-card.card-marketplace .dash-module-header i,
.dash-module-card.card-marketplace .dash-module-header span { color: #fff !important; }

.dash-module-body { 
    padding: 1rem 1.2rem; 
    flex: 1; 
    position: relative;
    z-index: 2;
    background: linear-gradient(to right, rgba(255,255,255,0.95) 50%, rgba(255,255,255,0.7) 100%);
}
.dash-module-stat {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.5rem 0;
}
.dash-module-stat i { 
    width: 22px; 
    text-align: center; 
    font-size: 0.95rem;
}
.dash-stat-number { 
    font-weight: 800; 
    font-size: 1.15rem; 
    color: #031a42;
    letter-spacing: -0.5px;
}
.dash-stat-text { 
    font-size: 0.78rem; 
    color: #555;
    font-weight: 500;
}
.dash-module-footer {
    padding: 0.65rem 1.2rem;
    border-top: 1px solid #eee;
    font-size: 0.82rem;
    position: relative;
    z-index: 2;
    background: #fff;
}
.dash-module-footer a { 
    text-decoration: none;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
}
.dash-module-footer a:hover { text-decoration: underline !important; }

/* KPI Cards */
.dash-kpi-card {
    background: #fff;
    border-radius: 16px;
    padding: 1.2rem 1.4rem;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
    transition: transform 0.2s;
}
.dash-kpi-card:hover { transform: translateY(-3px); }
.dash-kpi-value { font-size: 1.6rem; font-weight: 800; line-height: 1.2; }
.dash-kpi-label { font-size: 0.75rem; color: #6c757d; margin-top: 2px; font-weight: 500; }
.dash-kpi-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

/* Chart Cards */
.dash-chart-card {
    border-radius: 18px;
    border: none;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
    overflow: hidden;
}
.dash-chart-card .card-header {
    border-bottom: 1px solid #f5f5f5;
    padding: 1rem 1.2rem;
    background: #fff;
}
.dash-chart-card .card-header h6 {
    font-weight: 700 !important;
}

/* List Cards */
.dash-list-card {
    border-radius: 18px;
    border: none;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
    overflow: hidden;
}
.dash-list-card .card-header {
    border-bottom: 1px solid #f5f5f5;
    padding: 1rem 1.2rem;
    background: #fff;
}
.dash-list-card .card-header h6 {
    font-weight: 700 !important;
}
.dash-list-card .list-group-item {
    border-color: #f8f8f8;
    transition: background 0.15s;
}
.dash-list-card .list-group-item:hover { background: #f8fdf9; }

/* Avatar */
.dash-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.78rem;
    flex-shrink: 0;
}

/* Quick Actions */
.dash-quick-action {
    background: #f8f9fa;
    transition: all 0.2s;
    color: #333;
    border: 1px solid transparent;
}
.dash-quick-action:hover {
    background: #e8f0fc;
    border-color: #c5d8f8;
    color: #031a42;
    transform: translateY(-2px);
}

/* Card Decorative Image */
.card-decor-img {
    position: absolute;
    top: 0;
    right: 0;
    width: 55%;
    height: 100%;
    object-fit: cover;
    opacity: 0.5;
    pointer-events: none;
    mask-image: linear-gradient(to left, rgba(0,0,0,1) 0%, rgba(0,0,0,0) 80%);
    -webkit-mask-image: linear-gradient(to left, rgba(0,0,0,1) 0%, rgba(0,0,0,0) 80%);
}

/* Bold Stat Text */
.dash-stat-text strong {
    font-weight: 700;
    color: #333;
}

/* Background opacity utilities */
.bg-opacity-15 {
    --bs-bg-opacity: 0.15;
}

/* Topbar enhancements */
.topbar {
    background: #fff;
    padding: 0.75rem 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 1030;
}

.topbar .btn-toggle-sidebar {
    border: none;
    background: #f8f9fa;
    font-size: 1rem;
    color: #555;
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    transition: all 0.2s;
}

.topbar .btn-toggle-sidebar:hover {
    background: #e8f0fc;
    color: #031a42;
}

/* Quick Add Modal Button */
.sidebar-add-new {
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255,255,255,0.1);
    background: #02112f;
    position: sticky;
    bottom: 0;
    z-index: 2;
}

/* Enhanced Module Header Labels */
.dash-module-header .fw-bold,
.dash-module-header span {
    font-weight: 700 !important;
    text-transform: capitalize;
    letter-spacing: 0.3px;
}

/* Quick Add Modal Items */
.quick-add-item {
    border: 2px solid transparent;
}
.quick-add-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    border-color: currentColor;
}

/* Enhanced Sidebar Profile */
.sidebar-profile {
    background: rgba(0,0,0,0.1);
}

/* Better list item styling */
.list-group-item.border-0:hover {
    background: rgba(10,79,168,0.05) !important;
}

/* Badge improvements */
.badge.rounded-pill {
    font-weight: 600;
}

/* Progress bar styling */
.progress {
    background: #e9ecef;
    overflow: hidden;
}

.progress-bar {
    transition: width 0.6s ease;
}

/* Card header improvements */
.card-header.border-0 {
    border-bottom: 1px solid #f5f5f5 !important;
}

/* Dashboard search in banner */
.dash-search-box .form-control {
    height: 45px;
    font-size: 0.9rem;
}

/* Partner Logos in Sidebar */
.sidebar-logos {
    min-height: 50px;
}

.sidebar-logos .partner-logo-item {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px 6px;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.sidebar-logos .partner-logo-item:hover {
    background: rgba(255,255,255,0.1);
}

.sidebar-logos .partner-logo-item img {
    transition: opacity 0.2s ease;
}

.sidebar-logos .partner-logo-item:hover img {
    opacity: 1 !important;
}

/* Responsive adjustments */
@media (max-width: 1366px) {
    :root {
        --app-shell-gutter: 1.25rem;
    }

    .topbar {
        padding-inline: 1.25rem;
    }

    .topbar-search {
        max-width: 280px !important;
        margin-inline: .75rem !important;
    }

    .topbar > .d-flex:last-child {
        gap: .75rem !important;
    }
}

@media (max-width: 1199.98px) {
    .sidebar {
        margin-left: calc(var(--app-sidebar-width) * -1);
    }

    .main-content {
        margin-left: 0;
        width: 100%;
        max-width: 100vw;
    }

    .sidebar-collapsed .sidebar {
        margin-left: 0;
    }

    .sidebar-collapsed .main-content {
        margin-left: 0;
        width: 100%;
        max-width: 100vw;
    }
}

@media (max-width: 991.98px) {
    .topbar {
        flex-wrap: wrap;
        align-items: flex-start;
    }

    .topbar-search {
        order: 3;
        flex-basis: 100%;
        max-width: none !important;
        margin: .25rem 0 0 !important;
    }

    .dash-module-card .card-decor-img {
        width: 35%;
        opacity: 0.15;
    }
}

@media (max-width: 767.98px) {
    .dash-module-card .card-decor-img {
        display: none;
    }
    
    .sidebar-logos {
        flex-wrap: wrap;
    }
    
    .sidebar-logos img {
        height: 22px !important;
    }
}
