/* ========================================================
   THED NGO - Main Stylesheet
   Tribal Health and Education for Development
   Official Brand Palette: Royal Blue, Gold, Emerald Green & Saffron
   ======================================================== */

:root {
    --primary-color: #0b3b95;      /* Official THED Royal Blue */
    --primary-dark: #072663;       /* Deep Navy */
    --primary-light: #eff6ff;      /* Soft Royal Blue Tint */
    --secondary-color: #07193b;    /* Midnight Navy */
    --accent-gold: #f59e0b;        /* Official THED Gold */
    --accent-gold-dark: #d97706;
    --accent-green: #15803d;       /* THED Emerald Tribal Green */
    --accent-saffron: #ea580c;     /* THED Saffron Orange */
    --accent-color: #f59e0b;       /* Warm Gold */
    --bg-light: #f8fafc;
    --card-bg: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --sidebar-width: 260px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-light);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Sidebar & Layout */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #07193b 0%, #0a2558 50%, #061533 100%);
    color: #e2e8f0;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1030;
    overflow-y: auto;
    transition: all 0.3s ease;
    border-right: 1.5px solid rgba(245, 158, 11, 0.25); /* Elegant Gold trim */
}

.sidebar-brand {
    padding: 1.25rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid rgba(245, 158, 11, 0.2);
    text-decoration: none;
    color: #fff;
    background: rgba(0, 0, 0, 0.15);
}

.sidebar-brand:hover {
    color: #fbbf24;
}

.sidebar-brand-icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #ffffff;
    border: 2px solid #f59e0b; /* Metallic Gold border like logo rim */
    display: flex;
    align-items: center;
    justify-content: center;
    color: #0b3b95;
    font-size: 1.25rem;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.35);
    overflow: hidden;
    flex-shrink: 0;
}

.sidebar-brand-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.sidebar-menu {
    list-style: none;
    padding: 1rem 0.75rem;
    margin: 0;
}

.sidebar-header {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #93c5fd; /* Soft Blue */
    padding: 0.85rem 0.75rem 0.35rem;
    font-weight: 700;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0.85rem;
    color: #cbd5e1;
    text-decoration: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
    margin-bottom: 3px;
}

.sidebar-link i {
    width: 20px;
    text-align: center;
    font-size: 1rem;
    color: #94a3b8;
    transition: color 0.2s ease;
}

.sidebar-link:hover {
    background: rgba(11, 59, 149, 0.4);
    color: #ffffff;
}

.sidebar-link:hover i {
    color: #fbbf24;
}

.sidebar-link.active {
    background: linear-gradient(90deg, rgba(11, 59, 149, 0.9) 0%, rgba(2, 71, 158, 0.75) 100%);
    color: #fbbf24; /* Gold active text */
    font-weight: 600;
    box-shadow: inset 3.5px 0 0 #f59e0b; /* Gold left accent bar */
}

.sidebar-link.active i {
    color: #fbbf24;
}

.sidebar-badge {
    margin-left: auto;
    font-size: 0.75rem;
    padding: 0.2rem 0.5rem;
    border-radius: 20px;
    background: #f59e0b !important;
    color: #07193b !important;
    font-weight: 700;
}

.main-content {
    margin-left: var(--sidebar-width);
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    transition: margin-left 0.3s ease;
}

/* Top Navbar */
.top-navbar {
    background: #ffffff;
    border-bottom: 2px solid #e2e8f0;
    padding: 0.75rem 1.5rem;
    position: sticky;
    top: 0;
    z-index: 1020;
}

/* Brand Button Overrides to Royal Blue */
.btn-teal,
.btn-primary-thed,
[style*="background:#0d9488"],
[style*="background: #0d9488"],
[style*="background:#0d9488;"],
[style*="background: #0d9488;"] {
    background: #0b3b95 !important;
    border-color: #0b3b95 !important;
    color: #ffffff !important;
    font-weight: 600;
    transition: all 0.2s ease;
}

.btn-teal:hover,
.btn-primary-thed:hover,
[style*="background:#0d9488"]:hover,
[style*="background: #0d9488"]:hover {
    background: #072663 !important;
    border-color: #072663 !important;
    color: #ffffff !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(11, 59, 149, 0.35);
}

.btn-outline-teal,
[style*="border-color:#0d9488"],
[style*="border-color: #0d9488"] {
    border-color: #0b3b95 !important;
    color: #0b3b95 !important;
    font-weight: 600;
}

.btn-outline-teal:hover,
[style*="border-color:#0d9488"]:hover {
    background: #0b3b95 !important;
    color: #ffffff !important;
}

.btn-gold {
    background: #f59e0b !important;
    border-color: #f59e0b !important;
    color: #07193b !important;
    font-weight: 700;
}

.btn-gold:hover {
    background: #d97706 !important;
    border-color: #d97706 !important;
    color: #ffffff !important;
}

.text-teal,
[style*="color:#0d9488"],
[style*="color: #0d9488"] {
    color: #0b3b95 !important;
}

.bg-teal-subtle,
[style*="background:#ccfbf1"] {
    background: #eff6ff !important;
    color: #0b3b95 !important;
}

.border-teal {
    border-color: #0b3b95 !important;
}

/* Stat Cards & KPI widgets */
.stat-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.25rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    position: relative;
    overflow: hidden;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px -5px rgba(11, 59, 149, 0.08);
}

.stat-card .icon-box {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
}

.icon-teal { background: #eff6ff; color: #0b3b95; }
.icon-blue { background: #dbeafe; color: #02479e; }
.icon-purple { background: #f3e8ff; color: #7e22ce; }
.icon-amber, .icon-gold { background: #fef3c7; color: #b45309; }
.icon-emerald { background: #d1fae5; color: #15803d; }
.icon-rose, .icon-saffron { background: #ffedd5; color: #ea580c; }

.stat-title {
    font-size: 0.82rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.stat-value {
    font-size: 1.65rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.2;
}

/* Custom Table Styles */
.custom-table-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
}

.table > :not(caption) > * > * {
    padding: 0.85rem 1rem;
    vertical-align: middle;
}

.table th {
    background-color: #f8fafc;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #475569;
    border-bottom: 1px solid var(--border-color);
}

/* Status Badges */
.badge-role {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.35rem 0.65rem;
    border-radius: 6px;
    text-transform: capitalize;
}

.badge-superadmin { background: #fee2e2; color: #991b1b; }
.badge-admin      { background: #ede9fe; color: #5b21b6; }
.badge-district   { background: #e0e7ff; color: #3730a3; }
.badge-block      { background: #cffafe; color: #155e75; }
.badge-panchayat  { background: #dcfce7; color: #166534; }
.badge-volunteer  { background: #fef3c7; color: #92400e; }

.badge-status-active { background: #dcfce7; color: #166534; }
.badge-status-pending { background: #fef3c7; color: #92400e; }
.badge-status-expired { background: #fee2e2; color: #991b1b; }
.badge-status-distributed { background: #dcfce7; color: #166534; }
.badge-status-approved { background: #e0e7ff; color: #3730a3; }
.badge-status-paid { background: #dcfce7; color: #166534; }

/* Interactive Hierarchy Tree */
.tree-container {
    padding: 1.5rem;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 12px;
}

.tree, .tree ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

.tree ul {
    margin-left: 1.5rem;
    position: relative;
    padding-left: 1rem;
    border-left: 2px dashed #cbd5e1;
}

.tree li {
    margin: 0.75rem 0;
    position: relative;
}

.tree-node {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.85rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.88rem;
    font-weight: 500;
    transition: all 0.2s;
    cursor: pointer;
}

.tree-node:hover {
    background: #f1f5f9;
    border-color: #0b3b95;
    transform: translateX(3px);
}

.tree-toggle {
    cursor: pointer;
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    color: #64748b;
    border-radius: 4px;
    background: #e2e8f0;
}

.tree-toggle:hover {
    background: #cbd5e1;
    color: #0f172a;
}

/* Interactive Role Appointment Cards */
.role-select-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.85rem;
}

.role-select-card {
    background: #ffffff;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 1rem 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none !important;
}

.role-select-card:hover {
    border-color: #0b3b95;
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(11, 59, 149, 0.12);
}

.role-select-card.active {
    border-color: #0b3b95;
    background: #eff6ff;
    box-shadow: 0 0 0 3px rgba(11, 59, 149, 0.2);
}

.role-select-card .role-icon-box {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    margin-bottom: 0.65rem;
}

.role-select-card .check-icon {
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 0.85rem;
    color: #0b3b95;
    display: none;
}

.role-select-card.active .check-icon {
    display: block;
}

.role-select-card .role-title {
    font-size: 0.88rem;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 2px;
}

.role-select-card .role-id-pill {
    font-size: 0.68rem;
    font-family: monospace;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    background: #e2e8f0;
    color: #475569;
}

.role-select-card.active .role-id-pill {
    background: #eff6ff;
    color: #0b3b95;
}

/* Benefit 12 Month Progress Matrix */
.benefit-month-card {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 0.75rem;
    background: #ffffff;
    transition: all 0.2s;
    text-align: center;
}

.benefit-month-card.distributed {
    border-color: #86efac;
    background: #f0fdf4;
}

.benefit-month-card.pending {
    border-color: #fde68a;
    background: #fffbeb;
}

/* Responsive adjustments */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.show {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
    }
}

/* Print Styles */
@media print {
    .sidebar, .top-navbar, .no-print, .btn, .flash-messages-container {
        display: none !important;
    }
    .main-content {
        margin-left: 0 !important;
        padding: 0 !important;
    }
    body {
        background: #ffffff !important;
    }
}
