/* ==========================================================================
   VoteGuru AI — Premium Stylesheet v3.0
   ========================================================================== */

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

:root {
    --navy-base:     #0A1628;
    --navy-light:    #152642;
    --navy-lighter:  #1E3A5F;
    --navy-card:     #0F1E38;
    --saffron:       #FF9933;
    --saffron-deep:  #E67E00;
    --saffron-glow:  rgba(255,153,51,0.35);
    --green-india:   #138808;
    --green-light:   #1AAB0A;
    --white:         #FFFFFF;
    --off-white:     #F8FAFF;
    --text-primary:  #1A2035;
    --text-secondary:#4A5568;
    --text-muted:    #A0AEC0;
    --border:        #E2E8F0;
    --radius-xl:  20px; --radius-lg: 16px; --radius-md: 12px;
    --radius-sm:   8px; --radius-full: 9999px;
    --shadow-sm:  0 1px 3px rgba(0,0,0,0.12);
    --shadow-md:  0 4px 6px -1px rgba(0,0,0,0.15);
    --shadow-lg:  0 20px 40px -8px rgba(0,0,0,0.4);
    --shadow-saffron: 0 4px 15px rgba(255,153,51,0.4);
    --transition: 250ms ease;
}

body {
    font-family: 'Outfit', sans-serif;
    background: var(--navy-base);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex; justify-content: center; align-items: center;
    overflow: hidden;
    background-image:
        radial-gradient(ellipse at 15% 25%, rgba(255,153,51,0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 85% 75%, rgba(19,136,8,0.05) 0%, transparent 50%);
}

.visually-hidden {
    position: absolute; width: 1px; height: 1px; padding: 0;
    margin: -1px; overflow: hidden; clip: rect(0,0,0,0);
    white-space: nowrap; border: 0;
}

/* App Shell */
.app-container {
    width: 100%; max-width: 820px; height: 96vh; max-height: 900px;
    background: var(--off-white);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    display: flex; flex-direction: column;
    overflow: hidden;
}

/* ==========================================================================
   Header
   ========================================================================== */
.header {
    background: linear-gradient(135deg, var(--navy-card) 0%, var(--navy-light) 100%);
    color: var(--white); position: relative; overflow: hidden;
}
.header::before {
    content: ''; position: absolute; top: -40%; right: -10%;
    width: 180px; height: 180px; border-radius: 50%;
    background: radial-gradient(circle, rgba(255,153,51,0.08) 0%, transparent 70%);
    pointer-events: none;
}
.header-inner {
    display: flex; align-items: center;
    justify-content: space-between; padding: 18px 24px 16px;
}
.logo-group { display: flex; align-items: center; gap: 14px; }
.logo-icon-wrap {
    width: 48px; height: 48px; border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--saffron), var(--saffron-deep));
    display: flex; align-items: center; justify-content: center;
    font-size: 22px; color: var(--white);
    box-shadow: var(--shadow-saffron); flex-shrink: 0;
}
.logo { font-size: 22px; font-weight: 800; color: var(--white); line-height: 1.1; }
.logo-ai { color: var(--saffron); }
.subtitle { font-size: 12px; color: rgba(255,255,255,0.55); font-weight: 400; margin-top: 2px; }
.lang-badge { color: var(--saffron); font-weight: 500; }
.clear-btn {
    background: rgba(255,255,255,0.07); border: 1px solid rgba(255,255,255,0.12);
    color: rgba(255,255,255,0.6); width: 38px; height: 38px;
    border-radius: var(--radius-full); cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; transition: all var(--transition); flex-shrink: 0;
}
.clear-btn:hover {
    background: rgba(255,153,51,0.15); border-color: var(--saffron);
    color: var(--saffron); transform: rotate(180deg);
}
.tri-bar { display: flex; height: 4px; width: 100%; }
.bar-saffron { flex: 1; background: var(--saffron); }
.bar-white   { flex: 1; background: var(--white); }
.bar-green   { flex: 1; background: var(--green-india); }

/* ==========================================================================
   Tab Navigation
   ========================================================================== */
.tab-bar {
    display: flex; background: var(--white);
    border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.tab {
    flex: 1; padding: 12px 16px;
    background: none; border: none; border-bottom: 3px solid transparent;
    color: var(--text-secondary); font-family: inherit; font-size: 14px;
    font-weight: 500; cursor: pointer;
    display: flex; align-items: center; justify-content: center; gap: 8px;
    transition: all var(--transition);
}
.tab:hover { color: var(--navy-lighter); background: var(--off-white); }
.tab.active {
    color: var(--navy-lighter);
    border-bottom-color: var(--saffron);
    background: var(--off-white); font-weight: 600;
}
.tab i { font-size: 15px; }
.tab.active i { color: var(--saffron); }

/* ==========================================================================
   Panels (Chat + Booth Finder)
   ========================================================================== */
.panel {
    flex: 1; overflow-y: auto; display: none;
    flex-direction: column;
}
.panel.active { display: flex; }

/* ==========================================================================
   Chat Panel
   ========================================================================== */
.chat-panel {
    padding: 24px 24px 12px;
    gap: 8px; scroll-behavior: smooth;
}
.chat-panel::-webkit-scrollbar { width: 5px; }
.chat-panel::-webkit-scrollbar-track { background: transparent; }
.chat-panel::-webkit-scrollbar-thumb { background: var(--border); border-radius: var(--radius-full); }

.chat-box { display: flex; flex-direction: column; gap: 20px; flex: 1; }

/* Messages */
.message {
    display: flex; gap: 12px; max-width: 88%;
    animation: messageIn 0.3s cubic-bezier(0.34,1.56,0.64,1) forwards; opacity: 0;
}
@keyframes messageIn {
    from { opacity: 0; transform: translateY(12px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
.ai-message   { align-self: flex-start; }
.user-message { align-self: flex-end; flex-direction: row-reverse; }

.avatar {
    width: 38px; height: 38px; border-radius: var(--radius-full);
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; flex-shrink: 0;
}
.avatar.small { width: 30px; height: 30px; font-size: 13px; }
.ai-avatar {
    background: linear-gradient(135deg, var(--navy-lighter), var(--navy-card));
    color: var(--saffron); border: 1.5px solid rgba(255,153,51,0.3);
}
.user-avatar {
    background: linear-gradient(135deg, var(--green-india), var(--green-light));
    color: var(--white); border: 1.5px solid rgba(255,255,255,0.2);
}

.message-content {
    padding: 14px 18px; border-radius: var(--radius-lg);
    font-size: 14.5px; line-height: 1.65; box-shadow: var(--shadow-sm);
}
.ai-message .message-content {
    background: var(--white); color: var(--text-primary);
    border: 1px solid var(--border); border-top-left-radius: 4px;
}
.user-message .message-content {
    background: linear-gradient(135deg, var(--navy-lighter), var(--navy-light));
    color: var(--white); border-top-right-radius: 4px;
    border: 1px solid rgba(255,255,255,0.06);
}
.ai-message .message-content p   { margin-bottom: 10px; }
.ai-message .message-content p:last-child { margin-bottom: 0; }
.ai-message .message-content ul,
.ai-message .message-content ol  { margin: 8px 0 10px 20px; }
.ai-message .message-content li  { margin-bottom: 4px; }
.ai-message .message-content strong { color: var(--navy-base); font-weight: 600; }
.user-message .message-content strong { color: var(--saffron); }
.error-text { color: #C53030; }

/* Suggestions */
.suggestions-container { padding-left: 50px; animation: fadeIn 0.4s ease forwards 0.2s; opacity: 0; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.suggestions-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 10px; }
.chips-wrapper { display: flex; flex-wrap: wrap; gap: 8px; }
.suggestion-chip {
    background: var(--white); border: 1.5px solid var(--border);
    color: var(--text-primary); padding: 8px 14px;
    border-radius: var(--radius-full); font-size: 13px; font-weight: 500;
    cursor: pointer; transition: all var(--transition); font-family: inherit;
    display: flex; align-items: center; gap: 6px; box-shadow: var(--shadow-sm);
}
.suggestion-chip:hover {
    background: var(--saffron); border-color: var(--saffron);
    color: var(--white); transform: translateY(-2px); box-shadow: var(--shadow-saffron);
}
.chip-icon { font-size: 14px; }

/* Loading dots */
.loading-indicator { display: flex; align-items: center; gap: 12px; padding: 4px 0 8px; }
.loading-indicator.hidden { display: none; }
.typing-bubble {
    background: var(--white); border: 1px solid var(--border);
    border-radius: var(--radius-lg); border-top-left-radius: 4px;
    padding: 12px 18px; display: flex; align-items: center; gap: 6px;
    box-shadow: var(--shadow-sm);
}
.dot {
    width: 7px; height: 7px; background: var(--saffron);
    border-radius: 50%; animation: pulse 1.4s infinite ease-in-out both; opacity: 0.7;
}
.dot:nth-child(1) { animation-delay: -0.32s; }
.dot:nth-child(2) { animation-delay: -0.16s; }
@keyframes pulse {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40%           { transform: scale(1);   opacity: 1; }
}

/* ==========================================================================
   Input Area (Chat)
   ========================================================================== */
.input-area {
    background: var(--white); padding: 16px 20px;
    border-top: 1px solid var(--border); flex-shrink: 0;
}
.input-area.hidden { display: none; }
.input-wrapper { display: flex; gap: 10px; align-items: center; }
#user-input {
    flex: 1; padding: 14px 20px;
    border: 1.5px solid var(--border); border-radius: var(--radius-full);
    font-size: 14.5px; font-family: inherit; outline: none;
    transition: all var(--transition); background: var(--off-white); color: var(--text-primary);
}
#user-input::placeholder { color: var(--text-muted); }
#user-input:focus {
    border-color: var(--navy-lighter); background: var(--white);
    box-shadow: 0 0 0 3px rgba(30,58,95,0.1);
}
#user-input:disabled { opacity: 0.6; cursor: not-allowed; }
.send-btn {
    width: 50px; height: 50px; border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--saffron), var(--saffron-deep));
    color: var(--white); border: none; cursor: pointer; font-size: 17px;
    display: flex; align-items: center; justify-content: center;
    transition: all var(--transition); box-shadow: var(--shadow-saffron); flex-shrink: 0;
}
.send-btn:hover:not(:disabled) { transform: scale(1.08) rotate(-8deg); box-shadow: 0 6px 20px rgba(255,153,51,0.5); }
.send-btn:active:not(:disabled) { transform: scale(0.94); }
.send-btn:disabled, .send-btn.sending { opacity: 0.5; cursor: not-allowed; transform: none; }
.input-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }
.disclaimer { font-size: 11px; color: var(--text-muted); opacity: 0.8; }
.char-count { font-size: 11px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.char-count.near-limit { color: #C53030; font-weight: 600; }

/* ==========================================================================
   Booth Finder Panel
   ========================================================================== */
.booth-panel { padding: 0; background: var(--off-white); }
.booth-panel::-webkit-scrollbar { width: 5px; }
.booth-panel::-webkit-scrollbar-thumb { background: var(--border); border-radius: var(--radius-full); }

.booth-finder-wrap { padding: 28px 24px 32px; display: flex; flex-direction: column; gap: 24px; }

/* Hero */
.booth-hero { text-align: center; }
.booth-hero-icon { font-size: 40px; margin-bottom: 10px; display: block; }
.booth-hero-title { font-size: 20px; font-weight: 700; color: var(--navy-base); margin-bottom: 8px; }
.booth-hero-subtitle { font-size: 13.5px; color: var(--text-secondary); line-height: 1.6; max-width: 480px; margin: 0 auto; }

/* PIN Form */
.pincode-form { display: flex; flex-direction: column; gap: 8px; }
.pincode-input-group { display: flex; gap: 10px; }
.pincode-input-wrap {
    flex: 1; position: relative;
    display: flex; align-items: center;
}
.pincode-icon {
    position: absolute; left: 16px; color: var(--text-muted); font-size: 15px; pointer-events: none;
}
.pincode-input {
    width: 100%; padding: 14px 16px 14px 42px;
    border: 1.5px solid var(--border); border-radius: var(--radius-full);
    font-size: 15px; font-family: inherit; outline: none;
    transition: all var(--transition); background: var(--white);
    color: var(--text-primary); letter-spacing: 2px; font-weight: 600;
}
.pincode-input::placeholder { letter-spacing: 0; font-weight: 400; color: var(--text-muted); font-size: 13px; }
.pincode-input:focus { border-color: var(--saffron); box-shadow: 0 0 0 3px var(--saffron-glow); }
.pincode-search-btn {
    padding: 14px 22px; border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--saffron), var(--saffron-deep));
    color: var(--white); border: none; cursor: pointer;
    font-size: 14px; font-weight: 600; font-family: inherit;
    display: flex; align-items: center; gap: 8px;
    transition: all var(--transition); box-shadow: var(--shadow-saffron);
    white-space: nowrap; flex-shrink: 0;
}
.pincode-search-btn:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(255,153,51,0.5); }
.pincode-search-btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
.pincode-hint { font-size: 12px; color: var(--text-muted); padding-left: 6px; }
.pincode-error {
    font-size: 13px; color: #C53030; background: #FFF5F5;
    border: 1px solid #FEB2B2; border-radius: var(--radius-sm);
    padding: 10px 14px; border-radius: var(--radius-md);
}
.pincode-error.hidden { display: none; }

/* Results */
.booth-results { display: flex; flex-direction: column; gap: 16px; }
.booth-results.hidden { display: none; }

.state-badge {
    display: inline-flex; align-items: center; gap: 8px;
    background: linear-gradient(135deg, var(--navy-light), var(--navy-lighter));
    color: var(--white); padding: 8px 16px; border-radius: var(--radius-full);
    font-size: 13px; font-weight: 600; align-self: flex-start;
    box-shadow: var(--shadow-md);
}
.state-badge i { color: var(--saffron); }

/* Map */
.map-frame-wrap {
    width: 100%; border-radius: var(--radius-lg);
    overflow: hidden; box-shadow: var(--shadow-md);
    border: 1px solid var(--border); background: var(--white);
    min-height: 280px;
}
.map-iframe { width: 100%; height: 280px; border: none; display: block; }
.map-iframe.hidden { display: none; }

.map-fallback {
    min-height: 280px; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #f0f4ff 0%, #e8f4fd 100%);
}
.map-fallback.hidden { display: none; }
.map-fallback-inner { text-align: center; padding: 32px; }
.map-fallback-icon { font-size: 48px; display: block; margin-bottom: 12px; }
.map-fallback-title { font-size: 17px; font-weight: 700; color: var(--navy-base); margin-bottom: 6px; }
.map-fallback-text { font-size: 13px; color: var(--text-secondary); margin-bottom: 20px; line-height: 1.6; }
.maps-open-btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 12px 24px; border-radius: var(--radius-full);
    background: #4285F4; color: var(--white);
    text-decoration: none; font-size: 14px; font-weight: 600;
    transition: all var(--transition); box-shadow: 0 4px 12px rgba(66,133,244,0.4);
}
.maps-open-btn:hover { background: #3367D6; transform: translateY(-2px); box-shadow: 0 6px 20px rgba(66,133,244,0.5); }

/* Action Buttons */
.booth-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.booth-action-btn {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    padding: 12px 16px; border-radius: var(--radius-md);
    font-size: 13px; font-weight: 600; text-decoration: none;
    transition: all var(--transition); font-family: inherit;
    border: none; cursor: pointer; text-align: center;
    box-shadow: var(--shadow-sm);
}
.btn-eci     { background: var(--navy-lighter); color: var(--white); }
.btn-voters  { background: var(--green-india);  color: var(--white); }
.btn-helpline{ background: var(--saffron);      color: var(--white); }
.btn-state   { background: var(--white); color: var(--navy-lighter); border: 1.5px solid var(--border); }

.booth-action-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); filter: brightness(1.08); }

.booth-note {
    font-size: 12.5px; color: var(--text-secondary); line-height: 1.6;
    background: var(--white); border: 1px solid var(--border);
    border-radius: var(--radius-md); padding: 12px 16px;
    display: flex; gap: 8px; align-items: flex-start;
}
.booth-note i { color: var(--saffron); flex-shrink: 0; margin-top: 2px; }
.booth-note a { color: var(--navy-lighter); font-weight: 600; }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 640px) {
    .app-container { height: 100vh; max-height: 100vh; border-radius: 0; }
    .header-inner  { padding: 14px 16px 12px; }
    .chat-panel    { padding: 16px 12px 8px; }
    .booth-finder-wrap { padding: 20px 16px 24px; }
    .pincode-input-group { flex-direction: column; }
    .pincode-search-btn  { width: 100%; justify-content: center; }
    .booth-actions { grid-template-columns: 1fr; }
    .message       { max-width: 95%; }
    .suggestions-container { padding-left: 0; }
    .input-area    { padding: 12px 16px; }
    .tab span      { font-size: 12px; }
}
