/* Modern Theme - Premium Corporate Design Overrides (v7.4) */

/* -------------------------------------------------------------------------- */
/*  Global Variables & Resets                                                 */
/* -------------------------------------------------------------------------- */
:root {
    --bs-primary: #3b82f6;
    /* Vibrant Blue */
    --bs-primary-dark: #2563eb;
    --bs-secondary: #64748b;
    /* Slate */
    --bs-success: #10b981;
    /* Emerald */
    --bs-info: #0ea5e9;
    /* Sky */
    --bs-warning: #f59e0b;
    /* Amber */
    --bs-danger: #ef4444;
    /* Red */
    --bs-light: #f8fafc;
    /* Slate 50 */
    --bs-dark: #0f172a;
    /* Slate 900 */
    --bs-body-font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --bs-body-font-size: 0.875rem;
    --bs-body-font-weight: 400;
    --bs-body-line-height: 1.6;
    --bs-body-color: #334155;
    /* Slate 700 */
    --bs-body-bg: #f1f5f9;
    /* Slate 100 background */
}

body {
    /* background-color: var(--bs-body-bg) !important; REMOVED to allow native theme */
    /* color: var(--bs-body-color) !important; REMOVED to allow native theme */
    font-family: var(--bs-body-font-family) !important;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
    /* Prevent horizontal scroll */
}

a {
    color: var(--bs-primary);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.15s ease-in-out;
}

a:hover {
    color: var(--bs-primary-dark);
}

/* -------------------------------------------------------------------------- */
/*  Sidebar Styling                                                           */
/* -------------------------------------------------------------------------- */
.sidebar {
    /* background-color: #0f172a !important; REMOVED to allow theme color */
    border-right: none !important;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.02);
    z-index: 1040;
}

/* Target ONLY the main logo for centering */
.sidebar .sidebar-brand.brand-logo {
    background-color: transparent !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    height: 70px;
    display: flex !important;
    /* Only force flex on the main logo */
    align-items: center;
    justify-content: center !important;
    padding: 0 !important;
}

/* Ensure the mini logo doesn't get messed up if it appears */
.sidebar .sidebar-brand.brand-logo-mini {
    background-color: transparent !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    height: 70px;
    align-items: center;
    justify-content: center;
    padding: 0 !important;
    /* Do NOT force display:flex here globally, let sidebar JS handle visibility */
}

/* Dynamic Logo Visibility based on Sidebar Theme (Set via JS) */
body[data-sidebar-theme="dark"] .sidebar-brand img,
body[data-sidebar-theme="dark"] .sidebar-brand .brand-logo {
    filter: brightness(0) invert(1);
    opacity: 0.9;
}

body[data-sidebar-theme="light"] .sidebar-brand img,
body[data-sidebar-theme="light"] .sidebar-brand .brand-logo {
    filter: none;
    opacity: 1;
}

.sidebar-brand img,
.sidebar-brand .brand-logo {
    transition: all 0.2s ease;
    max-height: 45px !important;
    /* Control Height */
    max-width: 80%;
    /* Prevent overflow */
    object-fit: contain;
}

/* -------------------------------------------------------------------------- */
/*  Sidebar Toggled (Collapsed) State Fix                                     */
/* -------------------------------------------------------------------------- */
body.sidebar-toggled .sidebar .sidebar-brand.brand-logo {
    display: none !important;
}

body.sidebar-toggled .sidebar .sidebar-brand.brand-logo-mini {
    display: flex !important;
    justify-content: center;
    align-items: center;
    width: 70px !important;
    /* Strict width matching sidebar */
    height: 70px !important;
    position: absolute !important;
    /* Force position */
    top: 0;
    left: 0;
    margin: 0 !important;
    padding: 0 !important;
    background: transparent;
}

/* Sidebar Menu Items */
.sidebar-menu>ul>li>a {
    color: #94a3b8 !important;
    border-left: none !important;
    padding: 10px 16px !important;
    margin: 4px 12px;
    border-radius: 6px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    font-weight: 500;
    font-size: 0.825rem !important;
    /* Slightly smaller for style */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-menu>ul>li>a i,
.sidebar-menu>ul>li>a svg,
.sidebar-menu>ul>li>a svg.feather {
    font-size: 13px !important;
    width: 13px !important;
    height: 13px !important;
    min-width: 13px !important;
    max-width: 13px !important;
    margin-right: 12px;
    opacity: 0.8;
    text-align: center;
    vertical-align: middle;
}

/* -------------------------------------------------------------------------- */
/*  Global Icon Sizing Override (User Request)                                */
/* -------------------------------------------------------------------------- */
.icon-14,
.icon-16 {
    width: 13px !important;
    height: 13px !important;
    font-size: 13px !important;
    margin-top: 0px !important;
}

/* Hover State */
.sidebar-menu>ul>li>a:hover {
    color: #ffffff !important;
    background-color: rgba(255, 255, 255, 0.08) !important;
}

/* Active State - High Contrast Pill */
.sidebar-menu>ul>li.active>a {
    color: #ffffff !important;
    background-color: var(--bs-primary) !important;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* Submenus */
.sidebar-menu li ul {
    background-color: transparent !important;
    padding-left: 12px;
}

.sidebar-menu li ul li a {
    color: #64748b !important;
    padding: 8px 16px 8px 48px !important;
    font-size: 0.8rem !important;
    /* Even smaller for submenu */
    border-radius: 6px;
    margin: 2px 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-menu li ul li a:hover {
    color: #f8fafc !important;
    background-color: rgba(255, 255, 255, 0.05) !important;
}

.sidebar-menu li ul li.active>a {
    color: var(--bs-primary) !important;
    background: transparent !important;
    font-weight: 600;
}

/* -------------------------------------------------------------------------- */
/*  Inputs & Forms                                                            */
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
/*  Inputs & Forms                                                            */
/* -------------------------------------------------------------------------- */
.form-control,
.select2-container--default .select2-selection--single {
    border-radius: 8px !important;
    border: 1px solid #cbd5e1 !important;
    padding: 0.625rem 1rem !important;
    background-color: #ffffff !important;
    color: #1e293b !important;
    font-size: 0.825rem !important;
    /* Stylized inputs */
    min-height: 40px !important;
    /* Slightly more compact */
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05) !important;
    transition: all 0.2s ease-in-out;
}

/* Dark Mode for Inputs */
[data-theme="dark"] .form-control,
[data-theme="dark"] .select2-container--default .select2-selection--single,
[data-theme="dark"] input[type="search"] {
    background-color: #1e293b !important;
    /* Dark Slate */
    border-color: #334155 !important;
    color: #f1f5f9 !important;
    /* Light text */
}

[data-theme="dark"] .form-control::placeholder,
[data-theme="dark"] input::placeholder {
    color: #94a3b8 !important;
}

.form-control:focus,
.select2-container--default.select2-container--open .select2-selection--single {
    border-color: var(--bs-primary) !important;
    box-shadow: 0 0 0 3px rgba(var(--bs-primary-rgb), 0.15) !important;
    outline: none;
}

/* Fix: Search inputs with icons overlapping text */
input[type="search"],
.search-box input,
.form-group.has-feedback .form-control {
    padding-left: 2.75rem !important;
}

.form-control-feedback,
.search-box .search-icon {
    color: #94a3b8 !important;
    /* Visible gray */
    z-index: 5;
    width: 2.5rem;
    text-align: center;
    line-height: 40px !important;
}

/* -------------------------------------------------------------------------- */
/*  Buttons & Icons                                                           */
/* -------------------------------------------------------------------------- */
.btn {
    border-radius: 8px !important;
    padding: 0.5rem 1.15rem !important;
    /* Compact padding */
    font-weight: 500 !important;
    font-size: 0.825rem !important;
    /* Stylized button text */
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    letter-spacing: 0.01em;
    border: 1px solid transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

/* Fix: Ensure icons inside buttons are visible */
.btn i,
.btn svg {
    color: inherit !important;
    opacity: 0.9;
}

.btn-primary {
    background: var(--bs-primary) !important;
    /* Use detected theme color */
    color: #ffffff !important;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.btn-primary:hover {
    background: var(--bs-primary-dark) !important;
    /* Use darker variant */
    transform: translateY(-1px);
}

.btn-default,
.btn-secondary,
.btn-light {
    background-color: #ffffff !important;
    border: 1px solid #e2e8f0 !important;
    color: #334155 !important;
}

.btn-default:hover,
.btn-secondary:hover,
.btn-light:hover {
    background-color: #f8fafc !important;
    border-color: #cbd5e1 !important;
    color: #0f172a !important;
}

/* Fix: Invisible icons in general */
a.text-muted i {
    color: #94a3b8 !important;
}

a.text-muted:hover i {
    color: var(--bs-primary) !important;
}

/* FIX: Remove text from 'Clear Filter' button (Eliminar) */
.smart-filter-dropdown-container .clear-filter-button,
.smart-filter-dropdown-container .clear-filter-button:hover {
    font-size: 0 !important;
    padding: 0.5rem 0.75rem !important;
    /* Smaller padding for icon oly */
    line-height: 1;
}

.smart-filter-dropdown-container .clear-filter-button i {
    font-size: 1rem !important;
    /* Restore icon size (16px) */
    margin-right: 0 !important;
}

/* -------------------------------------------------------------------------- */
/*  Tables & Overflow                                                         */
/* -------------------------------------------------------------------------- */
.table {
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
}

.table thead th {
    background-color: #f8fafc !important;
    color: #475569 !important;
    font-weight: 600 !important;
    text-transform: uppercase;
    font-size: 0.725rem !important;
    /* Smaller headers */
    padding: 0.85rem 1.25rem !important;
    border-bottom: 2px solid #e2e8f0 !important;
    white-space: nowrap;
}

.table td {
    padding: 0.85rem 1.25rem !important;
    border-bottom: 1px solid #f1f5f9 !important;
    color: #334155 !important;
    vertical-align: middle;
    font-size: 0.825rem !important;
    /* Stylized table data */
}

.text-truncate {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    max-width: 100%;
}

/* -------------------------------------------------------------------------- */
/*  Modals & Page Title                                                        */
/* -------------------------------------------------------------------------- */
.modal-content {
    border: none !important;
    border-radius: 16px !important;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25) !important;
}

.modal-header {
    border-bottom: 1px solid #f1f5f9 !important;
    padding: 1.5rem !important;
}

.page-title h4 {
    font-size: 1.875rem !important;
    font-weight: 700 !important;
    color: #0f172a !important;
    margin-bottom: 0.5rem;
}

/* -------------------------------------------------------------------------- */
/*  Comments & Logo Visibility (v7.2)                                         */
/* -------------------------------------------------------------------------- */

/* Comments Bubble Style */
.comment-container {
    border-bottom: none !important;
    margin-bottom: 1.5rem;
    position: relative;
    padding: 0 !important;
    background: transparent !important;
}

.comment-avatar .avatar img {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    border: 2px solid #fff;
    width: 40px;
    height: 40px;
}

/* Bubble Container (Default Light) */
.comment-container .d-flex .w-100 {
    background-color: #ffffff;
    border-radius: 0 16px 16px 16px;
    padding: 1.25rem;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.03);
    border: 1px solid #f1f5f9;
    margin-left: 0.8rem;
    position: relative;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

/* Triangle Tip (Default Light) */
.comment-container .d-flex .w-100::before {
    content: '';
    position: absolute;
    top: 0;
    left: -8px;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 10px 10px 0;
    border-color: transparent #ffffff transparent transparent;
    transition: border-color 0.3s ease;
}

/* DARK MODE OVERRIDES */
body[data-theme="dark"] .comment-container .d-flex .w-100 {
    background-color: #1e293b !important;
    /* Slate 800 */
    border-color: #334155 !important;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
}

body[data-theme="dark"] .comment-container .d-flex .w-100::before {
    border-color: transparent #1e293b transparent transparent;
}

body[data-theme="dark"] .comment-container p {
    color: #e2e8f0 !important;
    /* Slate 200 */
}

body[data-theme="dark"] .comment-container .dark.strong {
    color: #ffffff !important;
}

body[data-theme="dark"] .comment-container small .text-off {
    background: #0f172a !important;
    /* Slate 900 */
    color: #94a3b8 !important;
}

body[data-theme="dark"] .comment-like-top {
    background: #0f172a !important;
    border-color: #334155 !important;
}

/* Header (User & Time) */
.comment-container .mb5 {
    display: flex;
    align-items: center;
    position: relative;
    /* Context for interactions */
    margin-bottom: 1rem !important;
    flex-wrap: nowrap;
    /* Prevent wrapping */
}

.comment-container .dark.strong {
    font-weight: 700 !important;
    color: #0f172a !important;
    font-size: 0.95rem;
    margin-right: 0.75rem;
}

/* Timestamp */
.comment-container small .text-off {
    color: #94a3b8 !important;
    font-size: 0.75rem;
    background: #f8fafc;
    padding: 2px 8px;
    border-radius: 12px;
}

/* Text */
.comment-container p {
    color: #334155;
    line-height: 1.6;
    margin-bottom: 0;
    font-size: 0.95rem;
}

/* Dropdown alignment */
.comment-container .comment-dropdown {
    margin-left: auto;
    /* Push to right */
    position: relative;
    top: -2px;
}

/* Images in comments */
.comment-image-box .timeline-images {
    margin-top: 1rem;
}

/* Like button - Fixed Floating Issue */
.comment-like-top {
    font-size: 0.75rem;
    color: #94a3b8;
    position: absolute;
    /* Take out of flow */
    bottom: -35px;
    /* Move to bottom of bubble */
    right: 15px;
    /* Align right */
    background: #fff;
    padding: 2px 8px;
    border-radius: 12px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    border: 1px solid #f1f5f9;
    opacity: 0;
    /* Hidden by default */
    transition: all 0.2s ease;
    width: auto !important;
    /* Reset width */
    margin-top: 0 !important;
    /* Reset margin */
    border-top: none !important;
    /* Reset border */
    padding-top: 2px !important;
}

/* Show Like interaction on hover */
.comment-container:hover .comment-like-top {
    opacity: 1;
    bottom: -20px;
    /* Slide up slightly */
}

/* Like Icon style */
.comment-like-top a {
    color: #64748b !important;
    display: flex;
    align-items: center;
    gap: 4px;
}

.comment-like-top a:hover {
    color: var(--bs-primary) !important;
}

/* -------------------------------------------------------------------------- */
/*  File Previews (v7.6 - Rich Card Design)                                   */
/* -------------------------------------------------------------------------- */

/* Target links that are NOT images (files) */
.timeline-images a:not([data-type="image"]) {
    display: inline-flex !important;
    flex-direction: column;
    width: 160px;
    height: auto;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    background-color: #ffffff;
    margin-right: 12px;
    margin-bottom: 12px;
    text-decoration: none !important;
    transition: all 0.2s ease;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    vertical-align: top;
}

/* Hover Effect for Card */
.timeline-images a:not([data-type="image"]):hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    border-color: var(--bs-primary);
}

/* Icon Area (Top Part) */
.timeline-images a:not([data-type="image"]) .file-mockup {
    width: 100% !important;
    height: 90px !important;
    background-color: #f8fafc !important;
    border: none !important;
    border-radius: 0 !important;
    border-bottom: 1px solid #f1f5f9 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 !important;
    box-shadow: none !important;
}

.timeline-images a:not([data-type="image"]) .file-mockup svg,
.timeline-images a:not([data-type="image"]) .file-mockup i {
    width: 32px !important;
    height: 32px !important;
    color: #64748b;
    /* Slate 500 */
    margin: 0 !important;
}

/* Filename Area (Bottom Part) - reveal using data-title */
.timeline-images a:not([data-type="image"])::after {
    content: attr(data-title);
    display: block;
    padding: 10px 12px;
    font-size: 0.8rem;
    color: #334155;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: left;
    background: #fff;
    width: 100%;
}

/* Dark Mode for File Cards */
body[data-theme="dark"] .timeline-images a:not([data-type="image"]) {
    background-color: #1e293b;
    border-color: #334155;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

body[data-theme="dark"] .timeline-images a:not([data-type="image"]) .file-mockup {
    background-color: #0f172a !important;
    /* Darker header */
    border-bottom-color: #334155 !important;
}

body[data-theme="dark"] .timeline-images a:not([data-type="image"])::after {
    background-color: #1e293b;
    color: #e2e8f0;
}

body[data-theme="dark"] .timeline-images a:not([data-type="image"]) .file-mockup svg,
body[data-theme="dark"] .timeline-images a:not([data-type="image"]) .file-mockup i {
    color: #94a3b8;
}

/* Hide the default hover overlay in timeline which might interfere */
.timeline-images a:not([data-type="image"]) .overlay {
    display: none !important;
}

/* -------------------------------------------------------------------------- */
/*  Fix Intl Tel Input (Phone Number) alignment                               */
/* -------------------------------------------------------------------------- */
.iti {
    display: block !important;
    width: 100%;
}

.iti__flag-container {
    z-index: 10;
}

.iti input.form-control {
    padding-left: 90px !important;
    height: 40px !important;
}

.iti__selected-flag {
    background-color: transparent !important;
    border-right: 1px solid #e0e0e0;
    padding: 0 12px !important;
}

/* Dark Mode tweaks for inputs */
[data-theme="dark"] .iti__selected-flag {
    border-color: #444;
}

[data-theme="dark"] .iti input.form-control {
    background-color: #2b2b2b;
    color: #fff;
    border-color: #444;
}