/* ==========================================================================
   CI THEME: ปีกพัฒนาเมือง พรรคประชาชน (COMPACT LIGHT THEME)
   White Background (100%) + Bright Royal Blue (70%) + Orange (30%)
   Reduced Gaps & Padding by 50% for high data density
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Anuphun:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;1,400&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
    /* People's Party CI Orange (30%) */
    --pp-orange: #F47920;
    --pp-orange-hover: #FF8A38;
    --pp-orange-light: #FFF7ED;
    --pp-orange-border: #FDBA74;
    --pp-orange-glow: rgba(244, 121, 32, 0.22);
    --pp-orange-dark: #C25608;

    /* Brighter Royal Blue & Cobalt (70%) */
    --pp-blue-primary: #1E40AF;
    --pp-blue-vibrant: #2563EB;
    --pp-blue-bright: #3B82F6;
    --pp-blue-light: #EFF6FF;
    --pp-blue-border: #BFDBFE;
    --pp-blue-dark: #1E3A8A;

    /* Clean White / Light Backgrounds */
    --bg-page: #F8FAFC;
    --bg-white: #FFFFFF;
    --bg-subtle: #F1F5F9;
    --bg-card: #FFFFFF;
    --bg-card-hover: #FFFFFF;
    --bg-sidebar: #FFFFFF;
    --bg-header: #FFFFFF;

    /* Text Colors */
    --text-heading: #0F172A;
    --text-body: #334155;
    --text-muted: #64748B;
    --text-light: #94A3B8;

    /* Borders */
    --border-light: #E2E8F0;
    --border-subtle: #F1F5F9;
    --border-blue: #DBEAFE;
    --border-orange: #FDBA74;

    /* Shadows */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-sm: 0 2px 5px rgba(15, 23, 42, 0.05);
    --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.07);
    --shadow-lg: 0 8px 20px rgba(15, 23, 42, 0.09);
    --shadow-orange: 0 4px 14px rgba(244, 121, 32, 0.18);
    --shadow-blue: 0 4px 14px rgba(37, 99, 235, 0.14);

    /* Fonts */
    --font-main: 'Anuphun', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

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

body, button, input, select, textarea, h1, h2, h3, h4, h5, h6, p, span, a, label, table, th, td, div {
    font-family: var(--font-main);
}

/* Fix Font Awesome Icon Glyphs */
i, .fa, .fas, .far, .fal, .fab, .fa-solid, .fa-regular, .fa-brands {
    font-family: "Font Awesome 6 Free", "Font Awesome 6 Brands", "FontAwesome" !important;
    font-style: normal;
    display: inline-block;
    line-height: 1;
}

body {
    background-color: var(--bg-page);
    color: var(--text-body);
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   SIDEBAR (Compact Layout)
   ========================================================================== */
.sidebar {
    width: 250px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    box-shadow: var(--shadow-sm);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-header {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    gap: 0.65rem;
    background: linear-gradient(135deg, #1E3A8A 0%, #2563EB 100%);
    color: #FFFFFF;
}

.brand-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--pp-orange) 0%, var(--pp-orange-dark) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #FFFFFF;
    font-size: 1.15rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
}

.brand-text h1 {
    font-size: 0.95rem;
    font-weight: 700;
    color: #FFFFFF;
    line-height: 1.2;
}

.brand-text p {
    font-size: 0.68rem;
    color: #FED7AA;
    font-weight: 500;
    margin-top: 0.1rem;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem 0.65rem;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    background: #FFFFFF;
}

.sidebar-section-title {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.05em;
    padding: 0 0.4rem;
    margin-bottom: 0.3rem;
}

.nav-menu {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.nav-item a {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.48rem 0.65rem;
    border-radius: 8px;
    color: var(--text-body);
    text-decoration: none;
    font-size: 0.84rem;
    font-weight: 500;
    transition: all 0.18s ease;
}

.nav-item a:hover {
    background: var(--pp-blue-light);
    color: var(--pp-blue-vibrant);
    transform: translateX(2px);
}

.nav-item.active a {
    background: linear-gradient(90deg, #FFF7ED 0%, #FFFFFF 100%);
    color: var(--pp-orange);
    border-left: 3px solid var(--pp-orange);
    font-weight: 700;
}

.nav-item a i {
    font-size: 0.95rem;
    width: 20px;
    text-align: center;
    color: #94A3B8;
    transition: color 0.18s ease;
}

.nav-item a:hover i {
    color: var(--pp-blue-vibrant);
}

.nav-item.active a i {
    color: var(--pp-orange);
}

.org-badge {
    font-size: 0.62rem;
    font-weight: 600;
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
    background: var(--bg-subtle);
    color: var(--text-muted);
    margin-left: auto;
}

.org-badge.ready {
    background: #DCFCE7;
    color: #15803D;
    border: 1px solid #BBF7D0;
}

.sidebar-footer {
    padding: 0.65rem 0.85rem;
    border-top: 1px solid var(--border-light);
    background: #FAFAFA;
}

.btn-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.48rem;
    border-radius: 6px;
    background: #FEF2F2;
    color: #DC2626;
    border: 1px solid #FECACA;
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 600;
    transition: all 0.18s ease;
}

.btn-logout:hover {
    background: #DC2626;
    color: #FFFFFF;
}

/* ==========================================================================
   MAIN CONTENT (Compact Spacing)
   ========================================================================== */
.main-wrapper {
    flex: 1;
    margin-left: 250px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: var(--bg-page);
}

.top-navbar {
    height: 52px;
    background: var(--bg-header);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem;
    position: sticky;
    top: 0;
    z-index: 900;
    box-shadow: var(--shadow-xs);
}

.top-navbar .page-title h2 {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-heading);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--pp-blue-light);
    padding: 0.25rem 0.75rem;
    border-radius: 16px;
    border: 1px solid var(--pp-blue-border);
}

.user-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--pp-blue-vibrant) 0%, var(--pp-blue-primary) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    color: #FFFFFF;
}

.user-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--pp-blue-primary);
}

.content-body {
    padding: 0.9rem 1.25rem;
    flex: 1;
}

/* ==========================================================================
   HERO BANNER (Compact)
   ========================================================================== */
.hero-banner {
    background: linear-gradient(135deg, #1E40AF 0%, #2563EB 55%, #3B82F6 100%);
    border-radius: 14px;
    padding: 1.2rem 1.5rem;
    margin-bottom: 0.85rem;
    position: relative;
    overflow: hidden;
    color: #FFFFFF;
    box-shadow: var(--shadow-sm);
}

.hero-banner::after {
    content: '';
    position: absolute;
    top: -50%;
    right: -10%;
    width: 350px;
    height: 200%;
    background: radial-gradient(circle, rgba(244, 121, 32, 0.2) 0%, transparent 65%);
    pointer-events: none;
}

.hero-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: rgba(255, 255, 255, 0.2);
    color: #FFFFFF;
    border: 1px solid rgba(255, 255, 255, 0.35);
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.2rem 0.65rem;
    border-radius: 14px;
    margin-bottom: 0.5rem;
}

.hero-title {
    font-size: 1.45rem;
    font-weight: 800;
    color: #FFFFFF;
    line-height: 1.2;
    margin-bottom: 0.35rem;
}

.hero-title span {
    color: #FED7AA;
}

.hero-desc {
    font-size: 0.86rem;
    color: #EFF6FF;
    max-width: 800px;
    line-height: 1.5;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.65rem;
}

.section-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-heading);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.section-title i {
    color: var(--pp-orange);
    font-size: 1.05rem;
}

/* ==========================================================================
   5-COLUMN ORG CARDS (Compact)
   ========================================================================== */
.org-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.65rem;
}

.org-card {
    background: #FFFFFF;
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 0.85rem 0.85rem;
    display: flex;
    flex-direction: column;
    text-decoration: none;
    position: relative;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-xs);
}

.org-card:hover {
    transform: translateY(-3px);
    border-color: var(--pp-orange);
    box-shadow: var(--shadow-orange);
}

.org-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 0.65rem;
}

.org-card-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: var(--pp-blue-light);
    border: 1px solid var(--pp-blue-border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: var(--pp-blue-vibrant);
    transition: all 0.2s ease;
}

.org-card:hover .org-card-icon {
    background: linear-gradient(135deg, var(--pp-orange) 0%, var(--pp-orange-dark) 100%);
    border-color: var(--pp-orange);
    color: #FFFFFF;
    box-shadow: 0 4px 10px var(--pp-orange-glow);
}

.org-card-type {
    font-size: 0.65rem;
    font-weight: 600;
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
    background: var(--bg-subtle);
    color: var(--text-muted);
}

.org-card-name {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-heading);
    margin-bottom: 0.2rem;
    line-height: 1.25;
}

.org-card-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.65rem;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.org-card-footer {
    margin-top: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 0.55rem;
    border-top: 1px solid var(--border-subtle);
}

.status-pill {
    font-size: 0.68rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.status-pill.active {
    color: #059669;
}

.status-pill.active::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #10B981;
}

.status-pill.pending {
    color: #94A3B8;
}

.status-pill.pending::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #CBD5E1;
}

.arrow-icon {
    font-size: 0.8rem;
    color: #94A3B8;
    transition: transform 0.2s ease, color 0.2s ease;
}

.org-card:hover .arrow-icon {
    color: var(--pp-orange);
    transform: translateX(3px);
}

/* ==========================================================================
   TABS (Compact Layout)
   ========================================================================== */
.tab-nav {
    display: flex;
    gap: 0.35rem;
    background: #FFFFFF;
    padding: 0.25rem;
    border-radius: 10px;
    border: 1px solid var(--border-light);
    margin-bottom: 0.75rem;
    box-shadow: var(--shadow-xs);
}

.tab-btn {
    padding: 0.48rem 0.95rem;
    border-radius: 7px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.45rem;
    transition: all 0.18s ease;
}

.tab-btn:hover {
    color: var(--text-heading);
    background: var(--bg-subtle);
}

.tab-btn.active {
    background: linear-gradient(135deg, var(--pp-orange) 0%, var(--pp-orange-dark) 100%);
    color: #FFFFFF;
    box-shadow: var(--shadow-orange);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Embedded Dashboard Container */
.dashboard-frame-container {
    width: 100%;
    background: #FFFFFF;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
}

.dashboard-iframe {
    width: 100%;
    height: 1200px;
    border: none;
    display: block;
}

/* ==========================================================================
   BUTTONS
   ========================================================================== */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.55rem 1.1rem;
    border-radius: 8px;
    border: none;
    background: linear-gradient(135deg, var(--pp-orange) 0%, var(--pp-orange-dark) 100%);
    color: #FFFFFF;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.18s ease;
    box-shadow: var(--shadow-orange);
}

.btn-primary:hover {
    transform: translateY(-2px);
}

/* ==========================================================================
   LOGIN PAGE
   ========================================================================== */
.login-container {
    min-height: 100vh;
    width: 100vw;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #EFF6FF 0%, #F8FAFC 50%, #FFF7ED 100%);
    padding: 1.25rem;
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: #FFFFFF;
    border: 1px solid var(--border-light);
    border-radius: 16px;
    padding: 2.25rem 1.85rem;
    box-shadow: 0 16px 36px rgba(15, 23, 42, 0.08);
    text-align: center;
}

.login-logo {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--pp-orange) 0%, var(--pp-orange-dark) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #FFFFFF;
    font-size: 1.8rem;
    margin: 0 auto 1rem;
    box-shadow: var(--shadow-orange);
}

.login-title {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--text-heading);
    margin-bottom: 0.25rem;
}

.login-subtitle {
    font-size: 0.8rem;
    color: var(--pp-orange);
    font-weight: 600;
    margin-bottom: 1.5rem;
}

.form-group {
    text-align: left;
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-heading);
    margin-bottom: 0.35rem;
}

.form-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.form-input-wrap i {
    position: absolute;
    left: 0.85rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.form-input {
    width: 100%;
    padding: 0.65rem 0.85rem 0.65rem 2.4rem;
    background: #F8FAFC;
    border: 1.5px solid var(--border-light);
    border-radius: 8px;
    color: var(--text-heading);
    font-size: 0.88rem;
    transition: all 0.18s ease;
    outline: none;
}

.form-input:focus {
    border-color: var(--pp-orange);
    background: #FFFFFF;
    box-shadow: 0 0 0 2.5px rgba(244, 121, 32, 0.15);
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */
@media (max-width: 1400px) {
    .org-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 1100px) {
    .org-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .main-wrapper {
        margin-left: 0;
    }
    .top-navbar {
        padding: 0 1rem;
    }
    .content-body {
        padding: 0.75rem 1rem;
    }
    .org-grid {
        grid-template-columns: repeat(1, 1fr);
    }
}
