/* Dashboard Variables */
:root {
    --primary-green: #2ecc71;
    --dark-green: #27ae60;
    --text-dark: #333;
    --text-light: #888;
    --bg-body: #f8f9fa;
    --bg-white: #ffffff;
    --border-color: #eef0f2;
    --danger: #e74c3c;
}

body {
    overflow-x: hidden;
    overflow-y: auto;
    background-color: var(--bg-body);
    display: flex;
    min-height: 100vh;
    width: 100%;
    max-width: 100vw;
    box-sizing: border-box;
}

/* Hide top navbar on prospects page */
#top-navbar {
    display: none;
}

/* --- Sidebar --- */
/* Los estilos del sidebar están en css/includes/sidebar.css */

.logo {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 40px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo span {
    color: var(--primary-green);
}

.nav-links {
    list-style: none;
    padding: 0;
    margin: 0;
}

.nav-links li {
    margin-bottom: 10px;
}

.nav-links a {
    text-decoration: none;
    color: var(--text-light);
    font-size: 15px;
    padding: 12px 15px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.3s ease;
}

.nav-links a:hover, .nav-links a.active {
    background-color: #eafff3;
    color: var(--primary-green);
    font-weight: 500;
}

/* --- Main Content --- */
/* Los estilos del main-content con sidebar están en css/includes/sidebar.css */
.main-content {
    flex: 1;
    padding: 30px;
    overflow-y: auto;
    box-sizing: border-box;
}

/* Header */
.main-content > header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px var(--main-padding);
    background-color: var(--bg-white);
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 0;
    gap: 20px;
    position: fixed;
    top: 0;
    left: 0 !important;
    right: 0;
    z-index: 1300; /* Por encima del sidebar */
    height: 85px;
    box-sizing: border-box;
    width: 100% !important;
}


.header-logo {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.header-logo-img {
    max-height: 70px;
    height: auto;
    width: auto;
}

.header-logo .logo-link {
    display: flex;
    align-items: center;
    text-decoration: none;
}

.search-bar {
    background: var(--bg-white);
    padding: 10px 20px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    width: 300px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.02);
}

.search-bar input {
    border: none;
    outline: none;
    margin-left: 10px;
    width: 100%;
    color: var(--text-light);
    background: transparent;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 20px;
}

.user-profile-container {
    position: relative;
}

.user-profile-name {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-dark);
    white-space: nowrap;
}

.user-profile-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: white;
    border: 1px solid #eef0f2;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    min-width: 150px;
    z-index: 1000;
    overflow: hidden;
}

.user-menu-item {
    width: 100%;
    padding: 12px 16px;
    text-align: left;
    background: none;
    border: none;
    font-size: 14px;
    color: var(--text-dark);
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.user-menu-item:hover {
    background-color: var(--hover-bg);
    color: var(--primary-green);
}

.user-menu-item:active {
    background-color: #d4edda;
}

/* --- Dashboard Widgets --- */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
    gap: 25px;
    margin-bottom: 30px;
}

/* Contenedores de gráficas: se redimensionan con el viewport (Chart.js responsive) */
.chart-wrapper-bar-line {
    position: relative;
    width: 100%;
    min-height: 70px;
    max-height: 140px;
    height: clamp(70px, 15.4vw, 140px);
}

.chart-wrapper-doughnut {
    position: relative;
    width: 100%;
    max-width: 196px;
    aspect-ratio: 1;
    min-height: 0;
    min-width: 0;
}

.card {
    background: var(--bg-white);
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.03);
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.card .card-header,
.card > div {
    align-self: stretch;
}

.card .chart-wrapper-bar-line {
    align-self: stretch;
}

.card-header {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 15px;
    position: relative;
}

.card-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-dark);
    text-align: center;
}

.card-header .badge-green,
.card-header .badge-red {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
}

.badge-green {
    background: #d4edda;
    color: var(--primary-green);
    padding: 4px 8px;
    border-radius: 5px;
    font-size: 12px;
    font-weight: 600;
}

.badge-red {
    background: #fadbd8;
    color: var(--danger);
    padding: 4px 8px;
    border-radius: 5px;
    font-size: 12px;
    font-weight: 600;
}

/* Widget 1: Customers */
.customer-stats {
    display: flex;
    gap: 20px;
    margin-bottom: 10px;
}

.stat-box h3 {
    font-size: 24px;
    color: var(--text-dark);
}

.stat-box p {
    font-size: 12px;
    color: var(--text-light);
}

.chart-container-sm {
    height: 70px;
    max-height: 70px;
    width: 100%;
}

/* Widget 2: Orders */
.orders-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.orders-info h2 {
    font-size: 28px;
    margin-bottom: 5px;
    color: var(--text-dark);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-light);
    margin-top: 5px;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.dot-green { background-color: var(--primary-green); }
.dot-gray { background-color: #ddd; }

/* Widget 3: Sales */
.sales-header h2 {
    font-size: 28px;
    display: inline-block;
    margin-right: 10px;
    color: var(--text-dark);
}

/* --- Table Section --- */
.table-section {
    background: var(--bg-white);
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.03);
    position: relative;
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.table-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-dark);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn-primary {
    background-color: var(--primary-green);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: background 0.3s;
    font-size: 14px;
}

.btn-primary:hover {
    background-color: var(--dark-green);
}

.table-wrapper {
    overflow-x: auto;
}

main {
    overflow-y: scroll;
}

.section-panel {
    overflow-y: auto;
}

.table-container {
    width: 100%;
}

table {
    width: 100%;
    border-collapse: collapse;
}

tr,
th {
    background-color: var(--primary-background-color);
}

tr:nth-child(odd) {
    background-color: var(--secondary-background-color);
}

th,
td {
    padding: 15px 10px;
    text-wrap: nowrap;
    overflow: hidden;
    -o-text-overflow: ellipsis;
    text-overflow: ellipsis;
}

th {
    text-align: left;
    font-size: 12px;
    color: var(--text-light);
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
}

td {
    text-align: start;
    vertical-align: top;
    max-width: 15rem;
    font-size: 13px;
    color: var(--text-dark);
    border-bottom: 1px solid var(--border-color);
}

tr:hover {
    background-color: #fafafa;
}

.check-icon {
    color: var(--primary-green);
    background: #eafff3;
    padding: 5px;
    border-radius: 50%;
    font-size: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
}

td:first-child {
    vertical-align: middle;
}

/* lead name column */
td:nth-child(2) {
    max-width: 20rem;
}

/* email column */
td:nth-child(3) {
    max-width: 30rem;
}

.two-icons {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: baseline;
    -ms-flex-align: baseline;
    align-items: baseline;
    gap: 0.25rem;
}

.edit-row-button {
    padding: 0;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    border: none;
    background-color: unset;
    position: relative;
}

.edit-row-button>img {
    height: 1rem;
}

.hover-ic {
    position: absolute;
    opacity: 0;
}

.edit-row-button:hover>.bg-ic {
    opacity: 0;
}

.edit-row-button:hover>.hover-ic {
    opacity: 1;
}

.remove-row-button {
    padding: 0;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    border: none;
    background-color: unset;
}

.remove-row-button>span {
    color: var(--company-color1);
    font-family: var(--bold-font);
}

.filter-options-container {
    display: none;
    width: 100%;
    max-width: 300px;
    margin: 0;
    padding: 1rem;
    padding-bottom: 0;
    position: absolute;
    top: 60px;
    right: 0;
    z-index: 100;
    -webkit-box-shadow: 5px 5px 5px var(--boxshadow-color);
    box-shadow: 5px 5px 5px var(--boxshadow-color);
    background-color: var(--primary-background-color);
    border-radius: 8px;
    -webkit-transform-origin: top right;
    -ms-transform-origin: top right;
    transform-origin: top right;
    -webkit-animation: closeFilterAnimation 0.2s forwards;
    animation: closeFilterAnimation 0.2s forwards;
}

.show-filter-options {
    display: block;
    -webkit-animation: openFilterAnimation 0.5s forwards;
    animation: openFilterAnimation 0.5s forwards;
}

@-webkit-keyframes openFilterAnimation {
    from {
        -webkit-transform: scale(0);
        transform: scale(0);
        display: none;
    }

    to {
        -webkit-transform: scale(1);
        transform: scale(1);
        display: block;
    }
}

@keyframes openFilterAnimation {
    from {
        -webkit-transform: scale(0);
        transform: scale(0);
        display: none;
    }

    to {
        -webkit-transform: scale(1);
        transform: scale(1);
        display: block;
    }
}

@-webkit-keyframes closeFilterAnimation {
    from {
        -webkit-transform: scale(1);
        transform: scale(1);
        display: block;
    }

    to {
        -webkit-transform: scale(0);
        transform: scale(0);
        display: none;
    }
}

@keyframes closeFilterAnimation {
    from {
        -webkit-transform: scale(1);
        transform: scale(1);
        display: block;
    }

    to {
        -webkit-transform: scale(0);
        transform: scale(0);
        display: none;
    }
}

.filter-option-li {
    margin-bottom: 1rem;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -ms-flex-direction: column;
    flex-direction: column;
    gap: 0.5rem;
}

.filter-option-group {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    gap: 1rem;
}

.filter-input-group {
    height: 2rem;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    position: relative;
}

.filter-input-group>img {
    height: 100%;
    padding: 0.5rem;
    position: absolute;
    left: 0;
    top: 50%;
    -webkit-transform: translateY(-50%);
    -ms-transform: translateY(-50%);
    transform: translateY(-50%);
}

.filter-input-group>input {
    height: 100%;
    width: 100%;
    padding: 0.5rem 1rem 0.5rem 1.7rem;
}

#company-input:focus+#company-options {
    opacity: 1;
    visibility: visible;
}

#company-options {
    width: 400px;
    max-height: 8rem;
    margin: 0;
    padding: 0;
    position: absolute;
    overflow-y: scroll;

    background-color: white;
    -webkit-box-shadow: 2px 2px 2px var(--boxshadow-color);
    box-shadow: 2px 2px 2px var(--boxshadow-color);
    opacity: 0;
    visibility: hidden;
    -webkit-transition: opacity 0.1s, visibility 0.1s;
    -o-transition: opacity 0.1s, visibility 0.1s;
    transition: opacity 0.1s, visibility 0.1s;
}

.company-input {
    border: none;
    width: 100%;
    border-bottom: solid 1px var(--input-color);
    margin-bottom: 0.5em;
    color: var(--input-color);
}

.custom-placeholder::-webkit-input-placeholder {
    color: #EAECF0;
}

.custom-placeholder::-moz-placeholder {
    color: #EAECF0;
    opacity: 1;
}

.custom-placeholder::-moz-placeholder {
    color: #EAECF0;
    opacity: 1;
}

.custom-placeholder::-ms-input-placeholder {
    color: #EAECF0;
}

.account-li-option {
    padding: 0.25em 0;
    border: none;
    border-bottom: solid 1px var(--input-color);
}

.account-li-option>a {
    width: 100%;
    display: block;
    /* text-wrap: nowrap; */
    overflow: hidden;
    -o-text-overflow: ellipsis;
    text-overflow: ellipsis;
    color: var(--input-color);
}


@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    /* Los estilos del sidebar responsive están en css/includes/sidebar.css */
    .nav-links a span {
        display: none;
    }
    .logo span { 
        display: none; 
    }
    .main-content {
        margin-left: 70px;
        width: calc(100% - 70px);
        max-width: calc(100% - 70px);
        padding-top: 110px; /* Espacio para el header fijo */
    }
}

@media (width>=1024px) {
    .section-panel {
        overflow-x: hidden;
    }

    .section-panel:hover {
        overflow-x: auto;
    }

    .filter-options-container {
        position: absolute;
        top: 60px;
        right: 0;
        max-width: 400px;

        -webkit-transform-origin: top right;
        -ms-transform-origin: top right;
        transform-origin: top right;
    }
}