/* =====================================================
   District.co.in - Multi-tenant CSS
   ===================================================== */

/* CSS Variables - Default Theme (can be overridden per district) */
:root {
    --primary: #0d9488;
    --primary-light: #14b8a6;
    --primary-dark: #0f766e;
    --accent: #fbbf24;
    --accent-dark: #d97706;
    --background: #f8fafc;
    --surface: #ffffff;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --success: #22c55e;
    --error: #ef4444;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
    --radius: 12px;
    --radius-sm: 8px;
    --header-height: 56px;
    --bottom-nav-height: 64px;
    --transition: 0.2s ease;
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--background);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    inset: 0;
    background: var(--background);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    z-index: 1000;
    transition: opacity 0.3s ease;
}

.loading-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-screen p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* =====================================================
   Header
   ===================================================== */
.main-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--surface);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    box-shadow: var(--shadow);
    z-index: 100;
}

.hamburger {
    width: 44px;
    height: 44px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 10px;
}

.hamburger span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--primary);
    border-radius: 2px;
    transition: var(--transition);
}

.logo {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--primary);
}

.search-btn {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--primary);
}

/* =====================================================
   Side Menu
   ===================================================== */
.menu-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
    z-index: 200;
}

.menu-overlay.active {
    opacity: 1;
    visibility: visible;
}

.side-menu {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    height: 100vh;
    background: var(--surface);
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 201;
    display: flex;
    flex-direction: column;
}

.side-menu.active {
    transform: translateX(0);
}

.side-menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
}

.side-menu-header h2 {
    font-size: 1.125rem;
}

.close-menu {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    color: white;
}

.side-menu-items {
    list-style: none;
    flex: 1;
    overflow-y: auto;
    padding: 12px 0;
}

.side-menu-items li a {
    display: block;
    padding: 14px 24px;
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
}

.side-menu-items li a:hover,
.side-menu-items li a:active {
    background: var(--background);
    color: var(--primary);
}

.side-menu-items .divider {
    height: 1px;
    background: var(--border);
    margin: 8px 20px;
}

.side-menu-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
}

.side-menu-footer p {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* =====================================================
   Search Modal
   ===================================================== */
.search-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--surface);
    z-index: 300;
    transform: translateY(-100%);
    transition: transform 0.3s ease;
}

.search-modal.active {
    transform: translateY(0);
}

.search-container {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}

.search-container input {
    flex: 1;
    height: 44px;
    padding: 0 16px;
    border: 1px solid var(--border);
    border-radius: 22px;
    font-size: 1rem;
    outline: none;
    background: var(--background);
}

.search-container input:focus {
    border-color: var(--primary);
}

.search-close {
    background: none;
    border: none;
    color: var(--primary);
    font-weight: 500;
    cursor: pointer;
    padding: 8px;
}

.search-results {
    padding: 16px;
    overflow-y: auto;
    max-height: calc(100vh - 70px);
}

/* =====================================================
   Main Content
   ===================================================== */
.main-content {
    padding-top: var(--header-height);
    padding-bottom: var(--bottom-nav-height);
    min-height: 100vh;
}

.page {
    display: none;
    padding: 16px;
    animation: fadeIn 0.2s ease;
}

.page.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.page-header {
    margin-bottom: 20px;
}

.page-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 4px;
}

.page-header p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* =====================================================
   Home Page - Hero
   ===================================================== */
.hero-section {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-radius: var(--radius);
    padding: 24px 20px;
    color: white;
    margin-bottom: 20px;
    position: relative;
    overflow: hidden;
}

.hero-section::after {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 100%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
    pointer-events: none;
}

.hero-content {
    position: relative;
    z-index: 1;
}

.hero-badge {
    display: inline-block;
    background: rgba(255,255,255,0.2);
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    margin-bottom: 12px;
}

.hero-section h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.hero-section p {
    opacity: 0.9;
    font-size: 0.9375rem;
}

/* Metrics Card */
.metrics-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}

.metrics-card h3 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 16px;
    text-align: center;
}

.metrics-row {
    display: flex;
    justify-content: space-around;
}

.metric {
    text-align: center;
}

.metric-number {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

.metric-label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Section Block */
.section-block {
    margin-bottom: 24px;
}

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

.section-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.view-all {
    font-size: 0.875rem;
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

/* Sectors Scroll */
.sectors-scroll {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 8px;
    -webkit-overflow-scrolling: touch;
}

.sectors-scroll::-webkit-scrollbar {
    display: none;
}

.sector-card {
    flex-shrink: 0;
    width: 140px;
    background: var(--surface);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: var(--transition);
}

.sector-card:active {
    transform: scale(0.98);
}

.sector-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--background);
    border-radius: 50%;
    color: var(--primary);
    font-size: 1.5rem;
}

.sector-card h4 {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
}

/* Updates List */
.updates-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.update-item {
    display: flex;
    gap: 12px;
    padding: 12px;
    background: var(--surface);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
}

.update-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--background);
    border-radius: 50%;
    color: var(--primary);
    flex-shrink: 0;
}

.update-icon.event { background: #ecfdf5; color: #059669; }
.update-icon.story { background: #fef3c7; color: #d97706; }
.update-icon.scheme { background: #ede9fe; color: #7c3aed; }

.update-content {
    flex: 1;
    min-width: 0;
}

.update-content h4 {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.update-content p {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* CTA Section */
.cta-section {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
    border-radius: var(--radius);
    padding: 24px 20px;
    text-align: center;
    color: var(--text-primary);
}

.cta-section h3 {
    font-size: 1.125rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.cta-section p {
    font-size: 0.875rem;
    margin-bottom: 16px;
    opacity: 0.9;
}

.cta-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.btn {
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: var(--transition);
}

.btn-primary {
    background: var(--text-primary);
    color: white;
}

.btn-secondary {
    background: rgba(255,255,255,0.9);
    color: var(--text-primary);
}

/* =====================================================
   Sectors Page
   ===================================================== */
.sectors-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.sector-card-large {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: var(--transition);
}

.sector-card-large:active {
    transform: scale(0.98);
}

.sector-card-large .sector-icon {
    width: 56px;
    height: 56px;
    margin-bottom: 12px;
    font-size: 1.75rem;
}

.sector-card-large h4 {
    font-size: 0.9375rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-primary);
}

.sector-card-large p {
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* =====================================================
   Filter Chips
   ===================================================== */
.filter-chips {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 12px;
    margin-bottom: 16px;
    -webkit-overflow-scrolling: touch;
}

.filter-chips::-webkit-scrollbar {
    display: none;
}

.chip {
    flex-shrink: 0;
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--surface);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.chip.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

/* =====================================================
   Events List
   ===================================================== */
.events-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.event-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow-sm);
}

.event-date {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    color: var(--accent-dark);
    font-weight: 600;
    margin-bottom: 8px;
}

.event-card h4 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-primary);
}

.event-card p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.event-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.event-organizer {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* =====================================================
   Directory
   ===================================================== */
.category-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.category-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 20px 16px;
    text-align: center;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: var(--transition);
}

.category-card:active {
    transform: scale(0.98);
}

.category-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--background);
    border-radius: 50%;
    color: var(--primary);
}

.category-card h4 {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.category-count {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.directory-listings {
    animation: fadeIn 0.2s ease;
}

.directory-listings.hidden {
    display: none;
}

.back-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: none;
    color: var(--primary);
    font-weight: 500;
    cursor: pointer;
    padding: 8px 0;
    margin-bottom: 16px;
}

.listings-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.listing-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow-sm);
}

.listing-card h4 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.listing-card p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.listing-contact {
    display: flex;
    gap: 12px;
    font-size: 0.75rem;
}

.listing-contact a {
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--primary);
    text-decoration: none;
}

/* =====================================================
   Opportunities
   ===================================================== */
.opportunities-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.opportunity-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow-sm);
}

.opportunity-type {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.opportunity-type.job { background: #dbeafe; color: #1d4ed8; }
.opportunity-type.tender { background: #ede9fe; color: #6d28d9; }
.opportunity-type.partnership { background: #dcfce7; color: #15803d; }

.opportunity-card h4 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.opportunity-company {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.opportunity-details {
    display: flex;
    gap: 16px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.opportunity-details span {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* =====================================================
   More Page
   ===================================================== */
.more-menu {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.more-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--surface);
    border-radius: var(--radius-sm);
    text-decoration: none;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.more-item:active {
    background: var(--background);
}

.more-icon {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--background);
    border-radius: var(--radius-sm);
    color: var(--primary);
    flex-shrink: 0;
}

.more-icon.pink { background: #fce7f3; color: #be185d; }
.more-icon.green { background: #dcfce7; color: #15803d; }

.more-text {
    flex: 1;
}

.more-text h4 {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.more-text p {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.more-item > svg {
    color: var(--text-muted);
    flex-shrink: 0;
}

/* =====================================================
   Bottom Navigation
   ===================================================== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-nav-height);
    background: var(--surface);
    display: flex;
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px 0;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    transition: var(--transition);
}

.nav-item svg {
    transition: var(--transition);
}

.nav-item span {
    font-size: 0.625rem;
    font-weight: 500;
}

.nav-item.active {
    color: var(--primary);
}

.nav-item.active svg {
    transform: scale(1.1);
}

/* =====================================================
   District Not Found
   ===================================================== */
.district-not-found {
    position: fixed;
    inset: 0;
    background: var(--background);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 500;
    padding: 24px;
}

.district-not-found.active {
    display: flex;
}

.not-found-content {
    text-align: center;
    max-width: 320px;
}

.not-found-content h2 {
    font-size: 1.5rem;
    color: var(--primary);
    margin-bottom: 12px;
}

.not-found-content p {
    color: var(--text-secondary);
    margin-bottom: 24px;
}

/* =====================================================
   Utility Classes
   ===================================================== */
.hidden {
    display: none !important;
}

/* =====================================================
   Responsive
   ===================================================== */
@media (min-width: 640px) {
    .main-content {
        max-width: 640px;
        margin: 0 auto;
    }

    .sectors-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .category-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) {
    .main-content {
        max-width: 800px;
    }

    .main-header {
        max-width: 800px;
        left: 50%;
        transform: translateX(-50%);
    }

    .bottom-nav {
        max-width: 800px;
        left: 50%;
        transform: translateX(-50%);
        border-radius: var(--radius) var(--radius) 0 0;
    }
}
