/* ==========================================================================
   E-SAMMP (Solar Asset Management & Monitoring Platform)
   Stylesheet with No-Wrap Action Column Guarantee
   ========================================================================== */

@import url('https://cdnjs.cloudflare.net/ajax/libs/font-awesome/6.5.1/css/all.min.css');

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

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #eff6ff;
    --sidebar-bg: #ffffff;
    --sidebar-hover: #f8fafc;
    --sidebar-active: #2563eb;
    --white: #ffffff;
    --bg: #f8fafc;
    --border: #e2e8f0;
    --text: #0f172a;
    --muted: #64748b;
    --success: #16a34a;
    --success-bg: #dcfce7;
    --warning: #ea580c;
    --warning-bg: #ffedd5;
    --danger: #dc2626;
    --danger-bg: #fee2e2;
    --info: #0284c7;
    --info-bg: #e0f2fe;
    --shadow: 0 1px 3px rgba(0,0,0,0.04);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 11.5px;
    line-height: 1.35;
    -webkit-font-smoothing: antialiased;
}

/* ROBUST FONT AWESOME OVERRIDE SAFETY */
i.fa, i.fas, i.far, i.fal, i.fab, i.fa-solid, i.fa-regular, i.fa-brands,
.fa, .fas, .far, .fal, .fab, .fa-solid, .fa-regular, .fa-brands {
    font-family: "Font Awesome 6 Free", "Font Awesome 6 Brands", FontAwesome, sans-serif !important;
    display: inline-block;
    font-style: normal;
    font-variant: normal;
    text-rendering: auto;
    line-height: 1;
}

i.fa-solid, i.fas { font-weight: 900 !important; }
i.fa-regular, i.far { font-weight: 400 !important; }

a { text-decoration: none; color: inherit; }
button, input, select { font-family: inherit; }

/* LAYOUT */
.app {
    display: flex;
    min-height: 100vh;
}

/* SIDEBAR */
.sidebar {
    width: 235px;
    min-width: 235px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    overflow-y: auto;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.brand {
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid #f1f5f9;
}

.brand-icon-box {
    width: 36px;
    height: 36px;
    background: #ffffff;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: #eab308;
}

.brand-text h2 {
    font-size: 15px;
    font-weight: 800;
    color: #0f172a;
    letter-spacing: -0.2px;
}

.brand-text span {
    font-size: 9px;
    color: var(--muted);
    display: block;
    line-height: 1.15;
}

.sidebar-menu {
    padding: 8px 10px;
    flex: 1;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7.5px 10px;
    border-radius: 8px;
    color: #475569;
    font-size: 11px;
    font-weight: 500;
    margin-bottom: 2px;
    transition: 0.15s;
    cursor: pointer;
}

.menu-item:hover {
    background: var(--sidebar-hover);
    color: var(--text);
}

.menu-item.active {
    background: var(--sidebar-active);
    color: #ffffff;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.22);
}

.menu-item i {
    font-size: 13px;
    width: 16px;
    text-align: center;
}

.submenu-caret {
    margin-left: auto;
    font-size: 9px;
    transition: transform 0.2s;
}

/* SUBMENU */
.submenu {
    padding-left: 26px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin: 2px 0 6px;
}

.submenu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5.5px 8px;
    border-radius: 6px;
    font-size: 10px;
    color: #64748b;
    transition: 0.15s;
    cursor: pointer;
}

.submenu-item:hover {
    background: #f1f5f9;
    color: var(--text);
}

.submenu-item.active {
    color: var(--primary);
    font-weight: 700;
    background: #eff6ff;
}

.submenu-item i {
    font-size: 10px;
    width: 12px;
    text-align: center;
}

.sidebar-footer {
    padding: 10px;
    border-top: 1px solid #f1f5f9;
}

.user-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 7px 10px;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.user-card-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-avatar-circle {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #cbd5e1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #475569;
    font-size: 10px;
}

.user-card-info strong {
    display: block;
    font-size: 10.5px;
    color: var(--text);
}

.user-card-info span {
    display: block;
    font-size: 8.5px;
    color: var(--muted);
}

.collapse-btn-bar {
    margin-top: 6px;
    background: var(--primary);
    color: #ffffff;
    padding: 5px;
    border-radius: 6px;
    text-align: center;
    font-size: 10px;
    cursor: pointer;
}

/* MAIN CONTENT AREA */
.main {
    margin-left: 235px;
    width: calc(100% - 235px);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* TOP HEADER NAVIGATION BAR */
.top-header-nav {
    height: 56px;
    background: #ffffff;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 900;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.hamburger {
    display: none;
    font-size: 16px;
    cursor: pointer;
    color: var(--muted);
}

.global-search-box {
    position: relative;
    width: 320px;
}

.global-search-box .search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 11px;
    color: var(--muted);
}

.global-search-box input {
    width: 100%;
    height: 32px;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0 10px 0 30px;
    font-size: 11px;
    color: var(--text);
    outline: none;
    transition: 0.15s;
}

.global-search-box input:focus {
    background: #ffffff;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-status-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 10.5px;
    font-weight: 600;
    color: var(--success);
    background: var(--success-bg);
    padding: 4px 10px;
    border-radius: 12px;
}

.notification-wrapper {
    position: relative;
    font-size: 15px;
    color: var(--muted);
    cursor: pointer;
}

.notification-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 14px;
    height: 14px;
    background: var(--danger);
    color: #ffffff;
    border-radius: 50%;
    font-size: 8px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.help-icon {
    font-size: 15px;
    color: var(--muted);
    cursor: pointer;
}

.user-profile-dropdown {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: 0.15s;
}

.user-profile-dropdown:hover {
    background: #f1f5f9;
}

.avatar-circle {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--primary);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 11px;
}

.user-text-info strong {
    display: block;
    font-size: 11px;
    color: var(--text);
}

.user-text-info span {
    display: block;
    font-size: 9px;
    color: var(--muted);
}

.caret-icon {
    font-size: 9px;
    color: var(--muted);
}

/* PAGE CONTAINER */
.page-container {
    padding: 16px 20px 30px;
    flex: 1;
}

.top-bar-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.top-bar-title h1 {
    font-size: 18px;
    font-weight: 700;
    color: #0f172a;
}

.top-bar-title p {
    font-size: 10.5px;
    color: var(--muted);
    margin-top: 1px;
}

.last-updated {
    font-size: 9.5px;
    color: var(--muted);
    display: flex;
    align-items: center;
    gap: 4px;
}

/* FILTERS BAR */
.filter-bar {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
    box-shadow: var(--shadow);
    flex-wrap: wrap;
}

.filter-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 110px;
}

.filter-item label {
    font-size: 9px;
    color: var(--muted);
    font-weight: 600;
}

.filter-item select, .filter-item input {
    height: 30px;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0 8px;
    font-size: 10.5px;
    color: var(--text);
    background: #ffffff;
    outline: none;
}

.btn {
    height: 30px;
    padding: 0 14px;
    border-radius: 6px;
    font-size: 10.5px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    transition: 0.15s;
}

.btn-primary { background: var(--primary); color: #ffffff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: #ffffff; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { background: #f8fafc; }

/* 8 KPI CARDS ROW */
.kpi-row {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 8px;
    margin-bottom: 14px;
}

.kpi-card {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 9px 10px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.kpi-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.kpi-label { font-size: 9.5px; color: var(--muted); font-weight: 600; }

.kpi-icon-box {
    width: 22px;
    height: 22px;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
}

.kpi-val {
    font-size: 16px;
    font-weight: 700;
    color: #0f172a;
    margin: 3px 0 1px;
}

.kpi-sub { font-size: 8.5px; display: flex; align-items: center; gap: 2px; }
.sub-up { color: var(--success); }
.sub-down { color: var(--danger); }

/* GRID ROWS & CARDS */
.grid-row-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 14px;
}

.grid-row-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
    margin-bottom: 14px;
}

.grid-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 14px;
}

.card {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.card-header {
    padding: 9px 12px;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header h3 {
    font-size: 11px;
    font-weight: 700;
    color: #0f172a;
}

.card-header span { font-size: 9px; color: var(--muted); }
.card-body { padding: 10px 12px; flex: 1; }

/* PORTFOLIO HEALTH GAUGE */
.health-wrapper { display: flex; flex-direction: column; align-items: center; }
.gauge-canvas-box { position: relative; width: 125px; height: 65px; }

.gauge-center-text {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
}

.gauge-center-text strong { font-size: 17px; font-weight: 800; color: #0f172a; }
.gauge-center-text span { display: block; font-size: 8px; color: var(--muted); }

.health-legend-list {
    width: 100%;
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 9.5px;
}

.health-legend-item { display: flex; justify-content: space-between; }
.legend-dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; margin-right: 4px; }

/* SITE STATUS PILLS (12 COLUMNS - FULL PAGE WIDTH 4-COLUMN HORIZONTAL ROW) */
.site-status-grid-12col {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    width: 100%;
}

.status-pill {
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.status-pill.st-op { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.status-pill.st-up { background: #fff7ed; border-color: #fed7aa; color: #9a3412; }
.status-pill.st-sd { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.status-pill.st-ct { background: #f0f9ff; border-color: #bae6fd; color: #075985; }

.status-pill-title {
    font-size: 10.5px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.status-pill-val {
    font-size: 20px;
    font-weight: 800;
    margin: 2px 0;
}

.status-pill-pct {
    font-size: 9.5px;
    opacity: 0.85;
}

/* TABLES & ACTIONS NO-WRAP GUARANTEE */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 9.5px; }

th {
    background: #f8fafc;
    color: var(--muted);
    font-size: 8.5px;
    text-transform: uppercase;
    letter-spacing: 0.2px;
    font-weight: 700;
    text-align: left;
    padding: 6.5px 8px;
    border-bottom: 1px solid var(--border);
}

td { padding: 7px 8px; border-bottom: 1px solid #f1f5f9; color: var(--text); }
tr:last-child td { border-bottom: none; }

/* LOCK ACTIONS COLUMN TO SINGLE HORIZONTAL LINE (NO-WRAP) */
td:last-child, th:last-child, .action-cell {
    white-space: nowrap !important;
    text-align: center;
}

td:last-child .btn, th:last-child .btn, .action-cell .btn {
    display: inline-flex !important;
    vertical-align: middle;
}

.badge { display: inline-flex; align-items: center; padding: 2px 5px; border-radius: 4px; font-size: 8px; font-weight: 700; }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }

.badge-sev-critical { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }
.badge-sev-high { background: #fff7ed; color: #ea580c; border: 1px solid #fed7aa; }
.badge-sev-medium { background: #fefce8; color: #ca8a04; border: 1px solid #fef08a; }
.badge-sev-low { background: #f0f9ff; color: #0284c7; border: 1px solid #bae6fd; }

/* INDIA MAP CONTAINER */
.map-canvas-container {
    height: 230px;
    position: relative;
    background: #f8fafc;
    border-radius: 6px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.india-svg-replica { width: 100%; height: 100%; }

.map-legend-box {
    position: absolute;
    bottom: 6px;
    left: 6px;
    background: rgba(255,255,255,0.92);
    padding: 5px 7px;
    border-radius: 4px;
    border: 1px solid var(--border);
    font-size: 8px;
}

/* RESPONSIVE CONTROL */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .main { margin-left: 0; width: 100%; }
    .hamburger { display: block; }
    .global-search-box { width: 180px; }
    .header-status-badge { display: none; }
    .kpi-row { grid-template-columns: repeat(2, 1fr); }
    .grid-row-4 { grid-template-columns: 1fr; }
    .grid-row-3 { grid-template-columns: 1fr; }
    .grid-row-2 { grid-template-columns: 1fr; }
    .site-status-grid-12col { grid-template-columns: repeat(2, 1fr); }
}
