/* ============================================================
   OPTIMA ASSET MANAGEMENT - RESPONSIVE FIXES
   Covers: header, dashboard, all member pages, tables, charts,
           navigation, cards, footer
   ============================================================ */

/* -----------------------------------------------
   0. FORCE LIGHT MODE (fixes black chart backgrounds on macOS dark mode)
   ----------------------------------------------- */
html {
    color-scheme: light only;
}

body {
    background-color: #f9fafb;
    color: #212529;
}

/* Ensure all chart containers have explicit white backgrounds */
.card,
.card-body,
.highcharts-container,
.highcharts-background,
#chart-nav-line,
#chart-stock-valuation-polar,
#chart-top-stock-statistic-donut-chart,
#chart-top-promoter-statistic-donut-chart,
#chart-top-realestate-statistic-donut-chart,
#chart-top-comodity-statistic-donut-chart {
    background-color: #ffffff;
}

input, select, textarea, button {
    color-scheme: light;
}

.highcharts-background {
    fill: #ffffff !important;
}

canvas {
    background-color: transparent;
}

/* -----------------------------------------------
   1. PAGE HEADER / LOGO / BRAND
   ----------------------------------------------- */
.page-header.dashboard-page-header {
    flex-wrap: wrap;
    gap: 10px;
    padding-top: 10px;
}

.page-header.dashboard-page-header .page-title {
    flex-shrink: 0;
}

.page-header.dashboard-page-header .page-title img {
    max-width: 200px;
    height: auto;
    display: block;
}

@media (max-width: 767px) {
    .page-header.dashboard-page-header {
        padding-top: 15px;
        padding-bottom: 15px;
    }

    .page-header.dashboard-page-header .page-title img {
        max-width: 160px;
    }
}

@media (max-width: 576px) {
    .page-header.dashboard-page-header {
        flex-direction: column;
        align-items: flex-start !important;
        padding-top: 10px;
        padding-bottom: 12px;
    }

    .page-header.dashboard-page-header .page-title img {
        max-width: 140px;
    }

    .page-header.dashboard-page-header .d-flex {
        width: 100%;
    }

    .page-header.dashboard-page-header p {
        font-size: 12px;
        word-break: break-word;
    }
}

/* -----------------------------------------------
   2. MOBILE NAVIGATION (completely independent of theme header)
   ----------------------------------------------- */

/* --- Mobile nav bar & menu --- */
.mobile-nav-wrapper {
    margin-bottom: 0;
}

.mobile-nav-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    height: 50px;
    border-radius: 4px 4px 0 0;
}

.mobile-nav-toggle {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 4px;
}

.mobile-nav-toggle i {
    font-size: 24px;
}

.mobile-nav-toggle.active {
    opacity: 0.8;
}

.mobile-profile-btn {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    padding: 8px;
}

.mobile-profile-wrapper {
    position: relative;
}

/* Profile dropdown - separate from main menu */
.mobile-profile-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    background: #fff;
    border-radius: 4px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
    min-width: 160px;
    z-index: 100;
    overflow: hidden;
    margin-top: 6px;
}

.mobile-profile-dropdown.open {
    display: block;
}

.mobile-profile-dropdown a {
    display: block;
    padding: 12px 18px;
    color: #333 !important;
    text-decoration: none;
    font-size: 14px;
    border-bottom: 1px solid #f0f0f0;
}

.mobile-profile-dropdown a:last-child {
    border-bottom: none;
    color: #c0392b !important;
}

.mobile-profile-dropdown a:hover {
    background: #f5f5f5;
}

/* Menu - hidden by default */
.mobile-nav-menu {
    display: none;
    flex-direction: column;
    background: #4a8ec4;
    border-radius: 0 0 4px 4px;
    overflow: hidden;
}

.mobile-nav-menu.open {
    display: flex;
}

.mobile-nav-menu > a {
    display: block;
    color: #fff !important;
    padding: 12px 18px;
    font-size: 14px;
    text-decoration: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    transition: background 0.15s;
}

.mobile-nav-menu > a:hover,
.mobile-nav-menu > a:active {
    background: rgba(255, 255, 255, 0.1);
}

.mobile-nav-menu > a i.mdi-chevron-down {
    float: right;
    font-size: 18px;
    margin-top: 1px;
}

/* Submenu inside mobile nav — hidden by default */
.mobile-submenu {
    display: none;
    background: rgba(0, 0, 0, 0.12);
}

.mobile-submenu.open {
    display: block;
}

/* Rotate chevron when submenu is open */
.mobile-submenu-toggle i {
    transition: transform 0.2s;
}

.mobile-submenu-toggle.active i {
    transform: rotate(180deg);
}

.mobile-submenu a {
    display: block;
    color: #e8f0f8 !important;
    padding: 10px 18px 10px 34px;
    font-size: 13px;
    text-decoration: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.mobile-submenu a:hover,
.mobile-submenu a:active {
    background: rgba(255, 255, 255, 0.08);
    color: #fff !important;
}

/* --- Desktop nav wrapper --- */
.desktop-nav-wrapper .header {
    position: relative !important;
}

/* --- Hide desktop nav on mobile, mobile nav on desktop --- */
/* d-lg-none and d-none d-lg-block handle this via Bootstrap,
   but reinforce just in case: */
@media (min-width: 992px) {
    .mobile-nav-wrapper {
        display: none !important;
    }
}

@media (max-width: 991px) {
    .desktop-nav-wrapper {
        display: none !important;
    }
}

/* -----------------------------------------------
   3. DASHBOARD STAT CARDS (Listed Securities, etc.)
   ----------------------------------------------- */
.card {
    margin-bottom: 15px;
}

.card .card-header {
    flex-wrap: wrap;
    gap: 8px;
}

.card .card-header .card-title {
    font-size: 14px;
    word-break: break-word;
}

.card .card-body .d-flex-space-between {
    flex-wrap: wrap;
    gap: 5px;
}

.card .card-body .d-flex-space-between h4 {
    font-size: 13px;
    margin-bottom: 5px;
}

.card .card-body .d-flex-space-between h2 {
    font-size: 20px;
}

@media (max-width: 767px) {
    .card .card-body .d-flex-space-between {
        flex-direction: column;
    }

    .card .card-body .d-flex-space-between h2 {
        font-size: 22px;
    }
}

@media (max-width: 576px) {
    .col-sm-6.col-md-3,
    .col-md-3 {
        flex: 0 0 50%;
        max-width: 50%;
    }

    .card .card-body .d-flex-space-between h4 {
        font-size: 11px;
    }

    .card .card-body .d-flex-space-between h2 {
        font-size: 18px;
    }
}

@media (max-width: 400px) {
    .col-sm-6.col-md-3,
    .col-md-3 {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* -----------------------------------------------
   4. NAV CHART CARD (NAV of Date / filter buttons)
   ----------------------------------------------- */
.filter-buttons {
    flex-wrap: wrap !important;
    gap: 6px !important;
}

.filter-buttons .btn {
    padding: 4px 10px !important;
    font-size: 12px !important;
    min-width: auto !important;
}

@media (max-width: 767px) {
    .card .card-header h4.card-title strong {
        font-size: 13px;
        display: block;
        margin-bottom: 8px;
    }

    .filter-buttons {
        margin-bottom: 10px !important;
    }

    .filter-buttons .btn {
        padding: 3px 8px !important;
        font-size: 11px !important;
    }
}

/* -----------------------------------------------
   5. CHART CONTAINERS - Responsive heights
   ----------------------------------------------- */
#chart-nav-line,
#chart-stock-valuation-polar,
#chart-top-stock-statistic-donut-chart,
#chart-top-promoter-statistic-donut-chart,
#chart-top-realestate-statistic-donut-chart,
#chart-top-comodity-statistic-donut-chart {
    width: 100% !important;
    max-width: 100%;
}

/* Donut / polar chart containers — cap the height on desktop */
#chart-stock-statistic-donut-chart,
#chart-promoter-statistic-donut-chart,
#chart-realestate-statistic-donut-chart,
#chart-commodity-statistic-donut-chart {
    max-height: 350px !important;
}

#chart-stock-valuation-polar {
    max-height: 380px;
}

.highcharts-container {
    width: 100% !important;
    max-width: 100%;
}

canvas {
    max-width: 100% !important;
}

@media (max-width: 999px) {
    [style*="height: 420px"] {
        height: 400px !important;
    }

    .col-md-7,
    .col-md-5.stretch-card {
        flex: 0 0 100%;
        max-width: 100%;
    }

    .col-md-6 {
        flex: 0 0 100%;
        max-width: 100%;
    }

    #chart-stock-statistic-donut-chart,
    #chart-promoter-statistic-donut-chart,
    #chart-realestate-statistic-donut-chart,
    #chart-commodity-statistic-donut-chart {
        max-height: 300px !important;
    }
}

@media (max-width: 576px) {
    [style*="height: 420px"] {
        height: 260px !important;
    }

    #chart-stock-statistic-donut-chart,
    #chart-promoter-statistic-donut-chart,
    #chart-realestate-statistic-donut-chart,
    #chart-commodity-statistic-donut-chart {
        max-height: 250px !important;
    }
}

/* -----------------------------------------------
   6. SECTORWISE CHART
   ----------------------------------------------- */
#chart-horizental-sectorwise {
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
}

/* -----------------------------------------------
   7. TABLES - Full responsive
   ----------------------------------------------- */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
}

.table {
    min-width: 600px;
}

.card .card-body .table-responsive {
    margin: 0 -10px;
    padding: 0 10px;
}

.dataTables_wrapper {
    overflow-x: auto;
    width: 100%;
}

table.dataTable {
    width: 100% !important;
}

@media (max-width: 767px) {
    .table th,
    .table td {
        padding: 6px 8px !important;
        font-size: 12px;
        white-space: nowrap;
    }

    .table thead th {
        font-size: 11px;
    }

    .dataTables_paginate {
        flex-wrap: wrap;
        justify-content: center;
    }

    .dataTables_info {
        font-size: 12px;
        text-align: center;
        margin-bottom: 8px;
    }
}

@media (max-width: 576px) {
    .table th,
    .table td {
        padding: 5px 6px !important;
        font-size: 11px;
    }
}

/* -----------------------------------------------
   8. NOTE PAGE
   ----------------------------------------------- */
@media (max-width: 767px) {
    .card .card-body table.table th,
    .card .card-body table.table td {
        white-space: normal;
        word-break: break-word;
    }
}

/* -----------------------------------------------
   9. WATCH LIST PAGE
   ----------------------------------------------- */
.watchlist-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 15px;
}

@media (max-width: 576px) {
    .watchlist-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .watchlist-content {
        padding: 14px 16px !important;
    }

    .watchlist-title {
        font-size: 14px !important;
    }

    .watchlist-subtitle {
        font-size: 12px !important;
    }
}

/* -----------------------------------------------
   10. WATCH LIST DETAIL PAGE
   ----------------------------------------------- */
.details-inner {
    max-width: 900px;
    margin: auto;
    padding: 0 15px;
}

.thumnail {
    height: auto !important;
    max-height: 500px;
}

.thumnail img {
    height: auto !important;
    max-height: 500px;
}

.text-description {
    padding: 0 !important;
}

@media (min-width: 768px) {
    .text-description {
        padding: 0 40px !important;
    }
}

@media (max-width: 576px) {
    .details-inner .title {
        margin-top: 25px !important;
    }

    .details-inner .title h1 {
        font-size: 22px !important;
    }

    .thumnail {
        margin-top: 15px !important;
        margin-bottom: 20px !important;
    }

    .text-description {
        font-size: 14px !important;
        line-height: 1.7 !important;
    }

    .watchlist-card-detail {
        padding: 20px !important;
    }

    .banner-overlay h1 {
        font-size: 20px !important;
    }

    .watchlist-container {
        margin-top: -40px !important;
        padding: 0 10px !important;
    }

    .watchlist-inline-image img {
        border-radius: 4px;
    }
}

/* -----------------------------------------------
   11. FOOTER
   ----------------------------------------------- */
footer.bg-white {
    padding: 15px 20px;
    text-align: center;
}

footer.bg-white p {
    font-size: 13px;
    margin-bottom: 5px;
}

@media (max-width: 576px) {
    footer.bg-white {
        padding: 10px 15px;
    }

    footer.bg-white p {
        font-size: 11px;
    }

    main {
        padding-bottom: 80px !important;
    }
}

/* -----------------------------------------------
   12. CONTENT WRAPPER / MAIN LAYOUT
   ----------------------------------------------- */
.page-content {
    overflow-x: hidden;
}

main {
    width: 100% !important;
    overflow-x: hidden;
}

@media (max-width: 767px) {
    .card-body > div[style*="height: 420px"] {
        height: 375px !important;
        min-height: 300px;
        padding: 0 5px;
    }
    .card-body { padding: 10px 8px; }
    .card-title { font-size: 15px; }
}

@media (max-width: 767px) {
    .content-inner {
        padding: 20px 10px;
    }

    .row {
        margin-left: -8px;
        margin-right: -8px;
    }

    .row > [class*="col-"] {
        padding-left: 8px;
        padding-right: 8px;
    }
}

/* -----------------------------------------------
   13. CUSTOM TABLE BLOCK (from thestyles.css)
   ----------------------------------------------- */
@media (max-width: 991px) {
    main .custom-table-block .block-item:nth-of-type(1) {
        width: 100% !important;
    }

    main .custom-table-block .block-item:nth-of-type(2) {
        width: 100% !important;
    }

    main .common-block-container .block-item:nth-of-type(1) {
        width: 100% !important;
        padding-right: 0 !important;
    }

    main .common-block-container .block-item:nth-of-type(2) {
        width: 100% !important;
    }
}

/* -----------------------------------------------
   14. COMMON POSTBOX
   ----------------------------------------------- */
@media (max-width: 576px) {
    main .common-postbox .title {
        padding: 6px 10px;
    }

    main .common-postbox .title h2 {
        font-size: 14px;
    }

    main .common-postbox .content {
        padding: 8px;
    }

    main .common-postbox .foot {
        flex-wrap: wrap;
        gap: 8px;
        padding: 8px;
    }
}

/* -----------------------------------------------
   15. COMMON VIEW ALL TABLE
   ----------------------------------------------- */
@media (max-width: 767px) {
    main .common-view-all-table table.dataTable tbody tr td ul {
        opacity: 1;
    }

    main .common-view-all-table table.dataTable tr td,
    main .common-view-all-table table.dataTable tr th {
        padding: 6px 8px !important;
        font-size: 12px;
    }
}

/* -----------------------------------------------
   16. COMMON TAB (from thestyles.css)
   ----------------------------------------------- */
@media (max-width: 767px) {
    main .common-tab .nav-tabs {
        flex-wrap: wrap;
    }

    main .common-tab .nav-tabs li a {
        font-size: 12px;
        padding: 8px 12px;
        line-height: 1.4;
    }
}

/* -----------------------------------------------
   17. TOGGLE & FORM ELEMENTS
   ----------------------------------------------- */
@media (max-width: 576px) {
    main .form-group.type-canvas .inner .signature-pad {
        width: 100% !important;
        height: 180px !important;
    }
}

/* -----------------------------------------------
   18. COMMON ADD NEW PAGE CONTAINER
   ----------------------------------------------- */
@media (max-width: 576px) {
    main .common-add-new-page-container {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
}

/* -----------------------------------------------
   19. IMAGE UPLOAD GALLERY
   ----------------------------------------------- */
@media (max-width: 576px) {
    main .common-image-upload-area.gallery-type ul li {
        width: 50%;
    }
}

/* -----------------------------------------------
   20. FINANCIAL REPORT / TRANSACTION REPORT DATATABLES
   ----------------------------------------------- */
@media (max-width: 767px) {
    #financial-report-table_wrapper .row {
        flex-direction: column;
    }

    .dataTables_length,
    .dataTables_filter {
        margin-bottom: 10px;
        text-align: left !important;
    }

    .dataTables_filter input {
        width: 100% !important;
        max-width: 250px;
    }

    table#financial-report-table {
        min-width: 500px;
    }
}

.navbar-header {
    padding: 17px !important;
}

/* -----------------------------------------------
   21. PROFILE ICON / USER DROPDOWN
   ----------------------------------------------- */
@media (max-width: 991px) {
    .navbar-header .notification .dropdown-menu {
        right: 0;
        left: auto;
        min-width: 200px;
    }
}

/* -----------------------------------------------
   22. LOGIN / HOME PAGE
   ----------------------------------------------- */
@media (max-width: 767px) {
    #contact-page .block-container {
        flex-direction: column;
    }

    #contact-page .block-container .block-item {
        width: 100% !important;
    }
}

/* -----------------------------------------------
   23. PRINT STYLES
   ----------------------------------------------- */
@media print {
    .mobile-nav-wrapper,
    .navbar.navbar-header,
    footer {
        display: none !important;
    }

    .page-content,
    main,
    .content-inner {
        width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    .table {
        min-width: auto;
        font-size: 10px;
    }

    .card {
        border: none !important;
        box-shadow: none !important;
        break-inside: avoid;
    }
}