/* Custom Mobile Optimization for Tareas */

/* Global Visibility Toggle */
#mobile-view { display: none; }
@media (max-width: 991.98px) {
    #desktop-view { display: none !important; }
    #mobile-view { display: block !important; }
}

@media screen and (max-width: 768px) {
    
    /* GLOBAL MOBILE SPACING OVERRIDES */
    .page-content {
        padding: 10px !important;
    }

    .page-content > .container-fluid {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }
    
    .main-content .page-content .card {
        margin-bottom: 12px !important;
        border-radius: 12px !important;
    }
    
    .main-content .page-content .card .card-body {
        padding: 1rem !important;
    }

    /* Better Alignment for Lists */
    .list-group-item {
        padding: 12px !important;
        margin-bottom: 8px !important;
        border-radius: 12px !important;
        background: #fff;
    }

    /* Force Table to behave like a List of Cards */
    #datatable-tasks, 
    #datatable-tasks tbody, 
    #datatable-tasks tr, 
    #datatable-tasks td {
        display: block;
        width: 100%;
    }

    /* Hide Table Header */
    #datatable-tasks thead {
        display: none;
    }

    /* Card Style for Rows */
    #datatable-tasks tr {
        background: #fff;
        margin-bottom: 20px; /* Spacing between cards */
        border: 1px solid #e1e1e1; /* Subtle border */
        border-radius: 12px; /* Rounded corners */
        box-shadow: 0 4px 10px rgba(0,0,0,0.05); /* Float effect */
        padding: 15px;
        position: relative;
    }

    /* Individual Cells Styling */
    #datatable-tasks td {
        padding: 10px 0;
        border-bottom: 1px solid #f0f0f0;
        text-align: center; /* Center everything */
        display: flex;
        flex-direction: column; /* Stack Label and Value */
        justify-content: center;
        align-items: center;
        min-height: 40px;
    }

    #datatable-tasks td:last-child {
        border-bottom: none;
        padding-top: 15px;
        margin-top: 5px;
    }

    /* Labels generated from data-label attribute */
    #datatable-tasks td::before {
        content: attr(data-label);
        font-weight: 700;
        color: #99a1b7; /* Lighter color for label above */
        text-transform: uppercase;
        font-size: 0.7rem;
        margin-right: 0;
        margin-bottom: 5px; /* Space between label and value */
        text-align: center;
        display: block;
    }

    /* Specific Tweaks */
    
    /* Make Title Big and prominent */
    #datatable-tasks td[data-label="Tarea"] {
        display: block;
        text-align: center;
        background-color: #f8f9fa; /* Light header background for title */
        margin: -15px -15px 10px -15px; /* Bleed to edges */
        padding: 15px;
        border-bottom: 1px solid #eee;
        border-radius: 12px 12px 0 0;
    }
    
    #datatable-tasks td[data-label="Tarea"]::before {
        display: none; /* Hide 'Tarea' label, title is self-explanatory */
    }

    #datatable-tasks td[data-label="Tarea"] div.fw-bold {
        font-size: 1.1rem;
        color: #2c302e;
        /* Line Break Fix */
        white-space: normal;
        word-wrap: break-word;
        word-break: break-word; /* Ensures breaking even without spaces if super long */
        line-height: 1.4;
    }

    /* Actions Button sizing */
    #datatable-tasks .btn {
        padding: 10px 20px; /* Bigger touch targets */
        font-size: 1rem;
    }

    #datatable-tasks .d-flex.gap-2 {
        width: 100%;
        justify-content: space-evenly;
    }

    /* Status and Priority Badges bigger */
    #datatable-tasks .badge {
        font-size: 0.9rem;
        padding: 8px 12px;
    }
    
    /* Highlight "Asignado a" */
    #datatable-tasks td[data-label="Asignado a"] {
        background-color: #fefffa;
        color: #5156be; /* Brand color */
    }

    /* === FILTER BAR & SEARCH RESPONSIVE FIXES === */
    
    /* Filter Bar Responsive Chips */
    .filter-bar {
        display: flex;
        overflow-x: auto;
        white-space: nowrap;
        padding-bottom: 10px;
        width: 100%;
        margin-bottom: 15px;
        -webkit-overflow-scrolling: touch; /* Smooth scroll iOS */
        /* Make sure it doesn't wrap */
        flex-wrap: nowrap !important;
    }
    
    .filter-bar::-webkit-scrollbar {
        height: 4px;
    }
    
    .filter-bar::-webkit-scrollbar-thumb {
        background: #ccc; 
        border-radius: 4px;
    }

    .filter-bar .btn {
        flex: 0 0 auto;
        border-radius: 50px !important; /* Chip style */
        margin-right: 8px;
        margin-left: 0 !important; /* Fix btn-group overlap */
        font-size: 0.85rem;
        padding: 6px 16px;
    }
    
    /* Stack controls container */
    .card-body > .d-flex.flex-wrap.gap-2.mb-4 {
        flex-direction: column;
        align-items: stretch !important;
        gap: 15px !important;
    }
    
    /* Fix Month Input width */
    #filter-month-history {
        max-width: 100% !important;
        width: 100%;
    }

    /* Action buttons container (New Task, Sync) */
    .card-body > .d-flex.flex-wrap.gap-2.mb-4 > .d-flex.gap-2 {
        display: grid !important;
        grid-template-columns: 1fr 1fr; /* 2 columns grid */
        gap: 10px !important;
    }
    
    #btn-new-task-main {
        grid-column: 1 / -1; /* Full width */
        width: 100%;
    }

    /* === CASHFLOW MOBILE APPS (Mobills Style) === */
    .mobile-app-container {
        background-color: #f8f9fa;
        min-height: 100vh;
        padding-bottom: 80px; /* Space for bottom nav */
    }

    .mobile-header {
        border-radius: 0 0 30px 30px;
        box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    }

    .mt-n4 {
        margin-top: -1.5rem !important;
    }

    .rounded-4 {
        border-radius: 1.25rem !important;
    }

    .mob-bottom-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: #fff;
        display: flex;
        justify-content: space-around;
        align-items: center;
        height: 70px;
        box-shadow: 0 -2px 15px rgba(0,0,0,0.08);
        z-index: 1000;
        padding: 0 5px;
    }

    .mob-bottom-nav .nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        color: #adb5bd;
        text-decoration: none;
        font-size: 10px;
        flex: 1;
        transition: all 0.2s ease;
    }

    .mob-bottom-nav .nav-item i {
        font-size: 22px;
        margin-bottom: 2px;
    }

    .mob-bottom-nav .nav-item.active {
        color: #5156be;
        font-weight: 600;
    }

    .fab-container {
        position: relative;
        top: -25px;
        z-index: 1001;
    }

    .fab-container .btn-primary {
        width: 56px;
        height: 56px;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        border: 4px solid #fff;
    }

    /* Main FAB Button (Right Corner) */
    .mob-fab-btn {
        position: fixed;
        bottom: 90px;
        right: 20px;
        width: 60px;
        height: 60px;
        border-radius: 50%;
        background: linear-gradient(135deg, #556ee6 0%, #5156be 100%);
        border: none;
        box-shadow: 0 4px 20px rgba(81, 86, 190, 0.4);
        color: #fff;
        font-size: 28px;
        display: flex;
        align-items: center;
        justify-content: center;
        z-index: 1002;
        cursor: pointer;
        transition: all 0.3s ease;
    }

    .mob-fab-btn:hover,
    .mob-fab-btn:active {
        transform: scale(1.1);
        box-shadow: 0 6px 25px rgba(81, 86, 190, 0.5);
    }

    /* Bottom Nav FAB Center Button */
    .nav-item-fab {
        position: relative;
        top: -20px;
        z-index: 1001;
        flex: 0 0 60px !important;
        display: flex;
        justify-content: center;
    }

    .btn-fab-center {
        width: 56px;
        height: 56px;
        border-radius: 50%;
        background: linear-gradient(135deg, #556ee6 0%, #5156be 100%);
        border: 4px solid #fff;
        box-shadow: 0 4px 15px rgba(81, 86, 190, 0.3);
        color: #fff;
        font-size: 24px;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        transition: all 0.3s ease;
    }

    .btn-fab-center:hover,
    .btn-fab-center:active {
        transform: scale(1.05);
        box-shadow: 0 6px 20px rgba(81, 86, 190, 0.4);
    }




    /* List Item Styles */
    #mobile-transactions-list .list-group-item {
        border: none;
        margin-bottom: 2px;
        padding: 1rem 1.25rem;
    }

    .avatar-title.bg-success-subtle { background-color: rgba(52, 195, 143, 0.15) !important; color: #34c38f !important; }
    .avatar-title.bg-danger-subtle { background-color: rgba(244, 102, 102, 0.15) !important; color: #f46666 !important; }
    .avatar-title.bg-primary-subtle { background-color: rgba(81, 86, 190, 0.15) !important; color: #5156be !important; }

    /* See More Button Refined */
    .btn-link.text-primary {
        text-decoration: none;
        font-weight: 600;
        font-size: 13px;
        background: #fff;
        transition: background 0.2s;
    }

    .btn-link.text-primary:active {
        background: #f1f1f1;
    }

    /* Fixed alignment for amounts */
    #mobile-transactions-list .text-end {
        min-width: 80px;
    }

    /* === ANALYTICS MOBILE SPECIFIC === */
    .mob-category-filters {
        scrollbar-width: none; /* Hide scrollbar Firefox */
        -ms-overflow-style: none; /* Hide scrollbar IE/Edge */
    }
    .mob-category-filters::-webkit-scrollbar {
        display: none; /* Hide scrollbar Chrome/Safari */
    }

    .mob-category-filters .btn {
        flex: 0 0 auto;
        font-weight: 500;
        font-size: 13px;
        transition: all 0.2s ease;
    }

    .mob-category-filters .btn.active {
        box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    }

    .mobile-body canvas {
        max-width: 100% !important;
    }

    /* Tab Transitions */
    .mob-tab-pane {
        animation: fadeIn 0.3s ease;
    }

    @keyframes fadeIn {
        from { opacity: 0; }
        to { opacity: 1; }
    }

}

/* 
===========================================
  Central FAB Menu Styles (Mobile)
===========================================
*/
.mob-bottom-nav .nav-item-fab {
    position: relative;
    top: -25px; /* Lift the FAB out of the bar */
    z-index: 1001; /* Ensure above bar */
}

.mob-bottom-nav .fab-container {
    position: relative;
    width: 56px;
    height: 56px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.mob-bottom-nav .btn-fab-center {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #556ee6 0%, #34c38f 100%);
    border: none;
    color: white;
    font-size: 28px;
    box-shadow: 0 4px 10px rgba(85, 110, 230, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
    outline: none;
}

.mob-bottom-nav .btn-fab-center:active {
    transform: scale(0.95);
}

.mob-bottom-nav .fab-options {
    position: fixed;
    bottom: 110px; /* Mayor separación del botón principal para evitar toques accidentales */
    left: 50%;
    transform: translateX(-50%);
    display: none; 
    flex-direction: row; /* Horizontal */
    gap: 30px; /* Más espacio entre opciones */
    align-items: center;
    justify-content: center;
    z-index: 99999;
    width: auto;
}

.mob-bottom-nav .fab-options.show {
    display: flex !important; /* Force show */
    animation: fabBounceIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes fabBounceIn {
  0% {
    opacity: 0;
    transform: translate(-50%, 40px) scale(0.5);
  }
  100% {
    opacity: 1;
    transform: translate(-50%, 0) scale(1);
  }
}

.mob-bottom-nav .fab-options .btn-floating-action {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    border: none;
    color: white;
    font-size: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.2s ease;
    position: relative;
}

.mob-bottom-nav .fab-options .btn-floating-action:active {
    transform: scale(0.9);
}

.btn-fab-center.rotate {
    transform: rotate(45deg);
}
