/* ----------------------------------------------------
   GLOBAL RESET
---------------------------------------------------- */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    width: 100%;
    overflow-x: hidden;
}

body {
    font-family: "Poppins", Arial, sans-serif;
    background: #f3f5f9;
    color: #1b1b1b;
}

/* ----------------------------------------------------
   TOP NAVBAR
---------------------------------------------------- */

.topbar {
    width: 100%;
    background: #2f3e56;
    color: white;
    padding: 14px 22px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.topbar-right {
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 12px;
}

.logout-btn {
    padding: 7px 14px;
    background: #d35400;
    border-radius: 5px;
    color: white;
    text-decoration: none;
    white-space: nowrap;
}

.logout-btn:hover {
    background: #bf4800;
}

/* ----------------------------------------------------
   MAIN LAYOUT WRAPPER
---------------------------------------------------- */

.wrapper {
    display: flex;
    min-height: calc(100vh - 56px);
    width: 100%;
}

/* ----------------------------------------------------
   SIDEBAR
---------------------------------------------------- */

.sidebar {
    width: 220px;
    min-width: 220px;
    background: #f0f2f5;
    padding: 20px;
    border-right: 1px solid #c9c9c9;
    overflow-y: auto;
}

.sidebar a {
    display: block;
    padding: 10px 10px;
    color: #1b1b1b;
    text-decoration: none;
    margin-bottom: 4px;
    font-weight: 500;
    border-radius: 4px;
}

.sidebar a:hover {
    background: #e6e9ee;
}

/* ----------------------------------------------------
   CONTENT AREA
---------------------------------------------------- */

.content {
    flex: 1;
    padding: 25px 30px;
    min-width: 0; /* CRITICAL: prevents flex overflow */
}

/* ----------------------------------------------------
   PAGE HEADINGS
---------------------------------------------------- */

h1, h2, h3, h4 {
    margin-bottom: 15px;
    color: #2f3e56;
}

/* ----------------------------------------------------
   BUTTONS
---------------------------------------------------- */

.btn {
    display: inline-block;
    background: #364867;
    color: white;
    padding: 7px 14px;
    border-radius: 5px;
    text-decoration: none;
    font-size: 0.9rem;
}

.btn:hover {
    background: #2b3850;
}

/* ----------------------------------------------------
   FORMS
---------------------------------------------------- */

form label {
    display: block;
    margin-bottom: 4px;
    font-weight: 600;
}

form input,
form select,
form textarea {
    width: 100%;
    padding: 7px 10px;
    margin-bottom: 12px;
    border-radius: 5px;
    border: 1px solid #c7c7c7;
    background: white;
}

form textarea {
    min-height: 70px;
}

/* ----------------------------------------------------
   CRUD SEARCH BAR
---------------------------------------------------- */

.crud-search {
    margin-bottom: 12px;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.crud-search input[type="text"] {
    width: 250px;
    max-width: 100%;
}

/* ----------------------------------------------------
   UNIVERSAL CRUD TABLE
---------------------------------------------------- */

.crud-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
    font-size: 0.92rem;
    background: white;
}

.crud-table th,
.crud-table td {
    border: 1px solid #d0d0d0;
    padding: 8px 12px;
    text-align: left;
    white-space: nowrap;
}

.crud-table th {
    background: #eaedf1;
    color: #2f3e56;
    font-weight: 600;
}

.crud-table tr:nth-child(even) {
    background: #f7f8fa;
}

.crud-table tr:hover {
    background: #eef3f9;
}

/* ----------------------------------------------------
   PAGINATION
---------------------------------------------------- */

.pagination {
    margin-top: 15px;
}

.pagination a {
    padding: 6px 10px;
    border: 1px solid #bbb;
    margin-right: 5px;
    font-size: 0.9rem;
    border-radius: 4px;
    text-decoration: none;
    color: #364867;
}

.pagination a.active {
    background: #364867;
    color: white;
    border-color: #364867;
}

.pagination a:hover {
    background: #e1e7ee;
}

/* ----------------------------------------------------
   PLACEHOLDER CARD
---------------------------------------------------- */

.placeholder-card {
    background: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 0 5px rgba(0,0,0,0.15);
    text-align: center;
    margin-top: 20px;
}

/* ----------------------------------------------------
   TILE GRID
---------------------------------------------------- */

.tile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 15px;
    margin-bottom: 30px;
}

.tile {
    background: #fff;
    border-radius: 8px;
    padding: 14px;
    box-shadow: 0 0 5px rgba(0,0,0,0.15);
}

.tile .big {
    font-size: 1.25rem;
    font-weight: 600;
}

.tile .small {
    font-size: 0.85rem;
    color: #666;
}

/* ----------------------------------------------------
   MULTISELECT
---------------------------------------------------- */

.multiselect {
    position: relative;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 6px;
    cursor: pointer;
    padding: 6px 10px;
}

.multiselect .dropdown {
    position: absolute;
    left: 0;
    top: 100%;
    background: #fff;
    border: 1px solid #ccc;
    width: 100%;
    max-height: 180px;
    overflow-y: auto;
    border-radius: 4px;
    z-index: 999;
    display: none;
}

.multiselect.open .dropdown {
    display: block;
}

.multiselect .dropdown label {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    cursor: pointer;
}

.multiselect .dropdown label:hover {
    background: #f0f0f0;
}

/* ----------------------------------------------------
   CHART CARDS
---------------------------------------------------- */

.chart-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 25px;
    margin-bottom: 30px;
}

.chart-card {
    background: #fff;
    padding: 18px;
    border-radius: 8px;
    box-shadow: 0 0 5px rgba(0,0,0,0.15);
}

.chart-card h3 {
    margin-bottom: 10px;
}

.chart-card canvas {
    width: 100% !important;
    height: auto !important;
    max-height: 280px;
    display: block;
}

/* ----------------------------------------------------
   COLORED TILES
---------------------------------------------------- */

.tile-current { background: #6E86A3; color: white; }
.tile-30      { background: #DD8A4A; color: white; }
.tile-60      { background: #C15A50; color: white; }
.tile-90      { background: #B64048; color: white; }
.tile-late    { background: #8A2430; color: white; }

.tile-current .small,
.tile-30 .small,
.tile-60 .small,
.tile-90 .small,
.tile-late .small {
    color: rgba(255,255,255,0.85);
}

.tile-current .big,
.tile-30 .big,
.tile-60 .big,
.tile-90 .big,
.tile-late .big {
    color: white;
}

/* ----------------------------------------------------
   TABS
---------------------------------------------------- */

.tabs {
    margin: 20px 0;
    border-bottom: 2px solid #ddd;
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.tab {
    padding: 10px 16px;
    text-decoration: none;
    color: #444;
    font-weight: 600;
    border-bottom: 3px solid transparent;
}

.tab:hover {
    color: #000;
}

.tab.active {
    border-bottom: 3px solid #2a72de;
    color: #2a72de;
}

/* ----------------------------------------------------
   RESPONSIVE FIXES
---------------------------------------------------- */

@media (max-width: 1100px) {
    .chart-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 900px) {
    .wrapper {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #c9c9c9;
    }

    .content {
        padding: 20px;
    }
}
