/* Custom Bulma Overrides and Extensions */

:root {
    /* Default values that will be overridden by theme CSS */
    --primary-color: #00d1b2;
    --secondary-color: #3273dc;
    --background-color: #ffffff;
    --text-color: #363636;
    --sidebar-bg: #f5f5f5;
    --card-bg: #ffffff;
    --border-color: #dbdbdb;
    --success-color: #48c78e;
    --warning-color: #ffe08a;
    --danger-color: #f14668;
    --info-color: #3298dc;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
}



.navbar {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.sidebar-menu .menu {
    background-color: transparent;
}

.sidebar-menu .menu-list a {
    border-left: 3px solid transparent;
    transition: all 0.2s ease;
    color: var(--text-color);
}

.sidebar-menu .menu-list a:hover {
    border-left-color: var(--primary-color);
    background-color: rgba(50, 115, 220, 0.1); /* Using secondary color for hover */
}

.box {
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
    transition: box-shadow 0.2s ease;
    background-color: var(--card-bg);
    color: var(--text-color);
}

.box:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.table {
    background-color: var(--card-bg);
    color: var(--text-color);
}

.table tbody tr:hover {
    background-color: rgba(50, 115, 220, 0.05); /* Using secondary color for hover */
}

.button {
    font-weight: 500;
    border-radius: 4px;
    transition: all 0.2s ease;
    color: var(--text-color);
}

.button:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.12);
}

.tag {
    border-radius: 4px;
    font-weight: 500;
}

.has-background-info-light {
    background-color: rgba(50, 144, 220, 0.1) !important; /* Updated to use info color */
}

.has-background-success-light {
    background-color: rgba(72, 219, 151, 0.1) !important;
}

.has-background-warning-light {
    background-color: rgba(255, 193, 7, 0.1) !important;
}

.has-background-danger-light {
    background-color: rgba(241, 70, 104, 0.1) !important;
}

/* HTMX Loading State */
.htmx-request .htmx-indicator {
    opacity: 1;
}

.htmx-indicator {
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

/* Form Enhancements */
.input:focus,
.textarea:focus,
.select select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.125em rgba(50, 115, 220, 0.25); /* Using secondary color */
}

/* Ensure proper text contrast in all themes */
.has-text-white {
    color: var(--text-color) !important;
}

.has-text-black {
    color: var(--text-color) !important;
}

/* Animations */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.notification {
    animation: slideIn 0.3s ease-out;
}


/* Footer styling */
.footer {
    background-color: var(--card-bg);
    color: var(--text-color);
    border-top: 1px solid var(--border-color);
    padding: 0.5rem 1.5rem;
    margin: 0;
}

/* ========================================
   MOBILE RESPONSIVE STYLES
   ======================================== */

/* Mobile Navigation Toggle */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 0.75rem;
    left: 0.75rem;
    z-index: 1000;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 0.5rem;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.mobile-menu-toggle:hover {
    background: var(--secondary-color);
}

/* Navbar Burger Menu Styles */
.navbar-burger {
    display: none;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    margin-right: 0.5rem;
}

.navbar-burger span {
    display: block;
    width: 20px;
    height: 2px;
    background-color: #ffffff;
    margin: 4px 0;
    transition: all 0.3s ease;
}

.navbar-burger.is-active span:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
}

.navbar-burger.is-active span:nth-child(2) {
    opacity: 0;
}

.navbar-burger.is-active span:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
}

/* For light navbar */
.navbar:not(.is-dark):not(.is-accountant) .navbar-burger span {
    background-color: currentColor;
}

/* Sidebar toggle (left) and Menu toggle (right) */
.navbar-burger.sidebar-toggle {
    order: 1;
    margin-right: 0;
    margin-left: 0.25rem;
}

.navbar-burger.menu-toggle {
    order: 3;
    margin-right: 0.25rem;
    margin-left: auto;
}

.navbar-brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.navbar-brand .navbar-item {
    order: 2;
    flex-grow: 1;
    text-align: center;
}

/* Sidebar close button for mobile */
.sidebar-close-btn {
    display: none;
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    color: var(--text-color);
    font-size: 1.5rem;
    z-index: 10;
}

@media screen and (max-width: 768px) {
    .sidebar-close-btn {
        display: block;
    }
}

/* Sidebar Mobile Styles */
.sidebar-menu {
    transition: transform 0.3s ease;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 998;
}

.sidebar-mobile {
    display: none;
    position: fixed;
    top: 0;
    left: -280px;
    height: 100vh;
    width: 280px;
    max-width: 85vw;
    background: var(--sidebar-bg);
    z-index: 999;
    overflow-y: auto;
    overflow-x: hidden;
    transition: left 0.3s ease-in-out;
    box-shadow: 2px 0 12px rgba(0,0,0,0.15);
}

.sidebar-mobile.is-open {
    left: 0;
}

/* Page Title Bar Mobile */
.page-title-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.5rem;
    background-color: #ffffff;
    border-bottom: 1px solid #e0e0e0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    flex-wrap: wrap;
    gap: 0.5rem;
}

.page-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #1e3a5f;
    margin: 0;
    flex-shrink: 1;
}

.page-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-shrink: 0;
}

/* Main Content Mobile Adjustments */
.main-content {
    background-color: #f5f7fa;
    min-height: 100vh;
}

/* Card Mobile Styles */
.box {
    margin-bottom: 1rem;
}

/* Table Mobile Styles */
.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
}

.table-container .table {
    width: 100%;
}

.table {
    min-width: 600px;
    width: 100%;
}

.table.is-mobile-responsive {
    width: 100%;
    font-size: 0.9rem;
}

.table.is-mobile-responsive th,
.table.is-mobile-responsive td {
    vertical-align: top;
    word-break: break-word;
}

/* Mobile card view for table rows */
@media screen and (max-width: 768px) {
    .table.is-mobile-card {
        display: block;
    }
    
    .table.is-mobile-card thead {
        display: none;
    }
    
    .table.is-mobile-card tbody {
        display: block;
    }
    
    .table.is-mobile-card tr {
        display: block;
        margin-bottom: 1rem;
        padding: 1rem;
        background: var(--card-bg);
        border-radius: 8px;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    }
    
    .table.is-mobile-card td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.5rem 0;
        border: none;
    }
    
    .table.is-mobile-card td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-color);
        margin-right: 1rem;
    }
}

/* Form Mobile Styles */
.field {
    margin-bottom: 1rem;
}

.input,
.textarea,
.select select {
    font-size: 16px; /* Prevents zoom on iOS */
}

/* Button Mobile Styles - Larger touch targets */
.button {
    min-height: 44px; /* Minimum touch target size */
    min-width: 44px;
}

.button.is-small {
    min-height: 36px;
    min-width: 36px;
}

/* Full width buttons on mobile */
@media screen and (max-width: 768px) {
    .button.is-fullwidth-mobile {
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    .field.is-grouped-mobile {
        flex-direction: column;
    }
    
    .field.is-grouped-mobile .control {
        width: 100%;
    }
}

/* Menu Mobile Styles */
.menu-list a {
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.menu-list a .icon {
    min-width: 20px;
}

/* Sidebar submenu on mobile */
@media screen and (max-width: 768px) {
    .sidebar-mobile .menu-list ul {
        margin-left: 1.5rem;
    }
    .sidebar-mobile .menu-list ul li a {
        padding: 0.5rem 0.75rem;
        font-size: 0.9rem;
    }
}

/* Dropdown Mobile Styles */
.navbar-item.has-dropdown .navbar-dropdown {
    min-width: 200px;
}

/* Nepali Datepicker Mobile Styles */
@media screen and (max-width: 768px) {
    input[id*="nepali-datepicker"],
    input[id*="date_calendar"],
    input[id*="bill_date"],
    input[id*="payment_date"] {
        width: 100% !important;
        font-size: 16px !important;
    }
    
    /* Ensure datepicker dropdown is positioned correctly */
    .nepali-date-picker-container {
        max-width: 100vw;
        left: 0 !important;
        right: 0 !important;
    }
}

/* Card-based layout for mobile data display */
.mobile-card-view {
    display: none;
}

/* Loading Indicator Mobile */
.htmx-indicator {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2000;
    background: rgba(0,0,0,0.8);
    padding: 1.5rem;
    border-radius: 8px;
    color: white;
}

/* Messages Mobile */
.notification {
    margin: 0.5rem;
    border-radius: 4px;
}

/* ========================================
   MEDIA QUERIES
   ======================================== */

/* Tablet and below (768px and below) */
@media screen and (max-width: 768px) {
    /* Show burger menu */
    .navbar-burger {
        display: block;
    }
    
    /* Show mobile menu toggle */
    .mobile-menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Hide desktop sidebar */
    .sidebar-menu.desktop-sidebar {
        display: none;
    }
    
    /* Show mobile sidebar */
    .sidebar-mobile {
        display: block;
    }
    
    /* Show overlay when sidebar is open */
    .sidebar-overlay.is-active {
        display: block;
    }
    
    /* Adjust main content */
    .columns {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
    
    .column.is-narrow {
        width: 100%;
        padding: 0;
    }
    
    .column.main-content {
        padding-left: 0;
        padding-right: 0;
    }
    
    /* Page title bar adjustments */
    .page-title-bar {
        padding: 0.75rem 1rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    
    .page-title {
        font-size: 1.1rem;
        width: 100%;
    }
    
    .page-actions {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
    }
    
    .page-actions .button {
        flex: 1;
        min-width: 120px;
    }
    
    /* Navigation adjustments */
    .navbar-brand {
        min-height: 3.25rem;
    }
    
    .navbar-item {
        padding: 0.5rem 0.75rem;
    }
    
    /* Card view for data on mobile */
    .desktop-table-view {
        display: none;
    }
    
    .mobile-card-view {
        display: block;
    }
    
    /* Grid adjustments */
    .columns.is-mobile > .column.is-half,
    .columns.is-mobile > .column.is-one-third,
    .columns.is-mobile > .column.is-one-quarter {
        flex: 0 0 100%;
    }
    
    /* Section padding */
    .section {
        padding: 1rem;
    }
    
    .section.is-medium {
        padding: 1.5rem;
    }
    
    /* Box spacing */
    .box {
        margin: 0.5rem;
        padding: 1rem;
    }
    
    /* Menu label */
    .menu-label {
        font-size: 0.75rem;
        padding: 0.5rem 1rem;
    }
}

/* Small mobile (480px and below) */
@media screen and (max-width: 480px) {
    .page-title {
        font-size: 1rem;
    }
    
    .button {
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    .page-actions .button {
        width: 100%;
        min-width: auto;
    }
    
    .box {
        margin: 0.25rem;
        padding: 0.75rem;
    }
    
    .input,
    .textarea {
        font-size: 16px;
    }
    
    /* Table font size */
    .table {
        font-size: 0.85rem;
    }
    
    .table td,
    .table th {
        padding: 0.5rem;
    }
    
    /* Icon adjustments */
    .icon.is-medium {
        height: 2rem;
        width: 2rem;
    }
}

/* Large tablets and desktop (1024px and above) */
@media screen and (min-width: 1024px) {
    .main-content {
        padding: 1.5rem;
    }
}

/* Print styles */
@media print {
    .sidebar-menu,
    .navbar,
    .mobile-menu-toggle,
    .page-actions,
    .menu {
        display: none !important;
    }
    
    .main-content {
        padding: 0;
    }
    
    .box {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}
