:root {
    --primary: #1e3a8a; /* Deep Royal Blue */
    --secondary: #d4af37; /* Gold Accent */
    --bg-color: #f8fafc;
    --glass-bg: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(255, 255, 255, 0.4);
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --sidebar-width: 300px;
}

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

body {
    font-family: 'Inter', 'Noto Sans Tamil', sans-serif;
    background: linear-gradient(135deg, #e0e7ff 0%, #f8fafc 100%);
    color: var(--text-primary);
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    line-height: 1.6;
}

.app-layout {
    display: flex;
    height: 100vh;
    height: 100dvh;
    width: 100vw;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: #f1f5f9;
    border-right: 1px solid #e2e8f0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 2px 0 10px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--glass-border);
}

/* Sidebar Tools */
.sidebar-tools {
    padding: 15px;
    border-bottom: 1px solid var(--glass-border);
    max-height: 50%;
    overflow-y: auto;
}

.tool-category h4 {
    margin: 5px 0;
    cursor: pointer;
    color: var(--primary);
    font-size: 0.95rem;
    padding: 8px 10px;
    border-radius: 8px;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tool-category h4:hover {
    background: #f1f5f9;
}

.tool-list {
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding-left: 25px;
    margin-bottom: 10px;
}

.tool-list button {
    background: white;
    border: 1px solid #e2e8f0;
    padding: 6px 12px;
    text-align: left;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.tool-list button:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.new-chat-btn {
    width: 100%;
    padding: 12px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 20px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: background 0.2s;
}

.new-chat-btn:hover {
    background: #152c6b;
}

.sidebar-content {
    padding: 20px;
    flex: 1;
    overflow-y: auto;
}

.sidebar-banner {
    padding: 15px;
    border-top: 1px solid #e2e8f0;
    background: white;
    text-align: center;
}

.sidebar-banner img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    object-fit: contain;
}

.sidebar-content h3 {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 15px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.history-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 15px;
    background: white;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.history-item:hover {
    background: #e2e8f0;
}

.history-item.active {
    background: #e0e7ff;
    border-color: #c7d2fe;
}

.history-title {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.delete-chat-btn {
    background: none;
    border: none;
    color: #ef4444;
    cursor: pointer;
    padding: 5px;
    border-radius: 5px;
    opacity: 0;
    transition: opacity 0.2s;
}

.history-item:hover .delete-chat-btn {
    opacity: 1;
}

.delete-chat-btn:hover {
    background: #fee2e2;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    background: #f8fafc;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Header */
.glass-header {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--glass-border);
    padding: 15px 30px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.install-btn {
    background: var(--secondary);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.install-btn:hover {
    background: #b8982e;
}

.menu-toggle {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: var(--primary);
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: background 0.2s;
}

.menu-toggle:hover {
    background: #f1f5f9;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 15px;
}

.app-logo {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    object-fit: cover;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.logo-container h1 {
    font-size: 1.5rem;
    color: var(--primary);
    margin-bottom: 2px;
    font-weight: 700;
}

.logo-container p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Chat Area */
.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 30px;
    scroll-behavior: smooth;
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-width: 1000px;
    margin: 0 auto;
    width: 100%;
}

/* Welcome Card */
.welcome-card {
    text-align: center;
    background: white;
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05);
    margin: auto;
    width: 100%;
    max-width: 600px;
    animation: fadeIn 0.8s ease-out;
}

.welcome-icon {
    color: var(--secondary);
    margin-bottom: 20px;
}

.welcome-card h2 {
    font-size: 1.8rem;
    color: var(--primary);
    margin-bottom: 10px;
}

.welcome-card p {
    color: var(--text-secondary);
    margin-bottom: 25px;
}

.suggestion-chips {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}

.suggestion-chips button {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9rem;
    color: var(--primary);
    transition: all 0.2s;
}

.suggestion-chips button:hover {
    background: var(--primary);
    color: white;
}

/* Messages */
.message {
    max-width: 85%;
    padding: 15px 20px;
    border-radius: 18px;
    animation: slideIn 0.3s ease-out;
    line-height: 1.8;
}

.message.user {
    align-self: flex-end;
    background: var(--primary);
    color: white;
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 10px rgba(30, 58, 138, 0.2);
}

.message.ai {
    align-self: flex-start;
    background: white;
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    border: 1px solid #e2e8f0;
    position: relative;
    padding-top: 40px; /* Space for copy button */
}

.copy-btn {
    position: absolute;
    top: 8px;
    right: 12px;
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-family: inherit;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all 0.2s;
}

.copy-btn:hover {
    background: #e2e8f0;
    color: var(--primary);
}

/* TTS Button */
.tts-btn {
    position: absolute;
    top: 8px;
    right: 85px; /* Position it next to the copy button */
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-family: inherit;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all 0.2s;
}

.tts-btn:hover {
    background: #e2e8f0;
    color: var(--primary);
}

.tts-btn.playing {
    color: white;
    background: var(--primary);
    border-color: var(--primary);
}

/* Formatting markdown in AI message */
.message.ai strong { color: var(--primary); }
.message.ai h2, .message.ai h3 { margin-top: 15px; margin-bottom: 10px; color: var(--primary); }
.message.ai p { margin-bottom: 10px; }
.message.ai ul, .message.ai ol { margin-left: 20px; margin-bottom: 10px; }
.message.ai blockquote { border-left: 4px solid var(--secondary); padding-left: 10px; color: var(--text-secondary); font-style: italic; }

/* Typing Indicator */
.typing-indicator-container {
    display: flex;
    flex-direction: column;
    align-self: flex-start;
    gap: 8px;
    margin-bottom: 10px;
}

.typing-indicator {
    display: flex;
    gap: 5px;
    padding: 15px 20px;
    background: white;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

.loading-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-style: italic;
    padding-left: 10px;
    animation: pulseText 1.5s infinite;
}

@keyframes pulseText {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--primary);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out both;
}

.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }

/* Input Area */
.input-area {
    width: 100%;
    padding: 15px 30px;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.file-preview-container {
    width: 100%;
    max-width: 1000px;
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.file-preview {
    position: relative;
    background: white;
    padding: 5px 10px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.file-preview img {
    height: 30px;
    width: 30px;
    object-fit: cover;
    border-radius: 4px;
}

.remove-file-btn {
    background: none;
    border: none;
    color: #ef4444;
    cursor: pointer;
    padding: 2px;
}

#ask-form {
    width: 100%;
    max-width: 1000px;
}

.input-wrapper {
    display: flex;
    gap: 10px;
    background: white;
    padding: 5px 10px;
    border-radius: 30px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    border: 1px solid #e2e8f0;
    align-items: center;
    flex-wrap: nowrap;
}

.icon-btn {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    color: var(--primary);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 12px;
    border-radius: 50%;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.icon-btn:hover {
    background: #e2e8f0;
    transform: scale(1.05);
}

.icon-btn.recording {
    color: #ef4444;
    animation: pulse 1.5s infinite;
}

#query-input {
    flex: 1;
    border: none;
    outline: none;
    padding: 12px 10px;
    font-size: 1rem;
    font-family: inherit;
    background: transparent;
}

#send-btn {
    background: var(--primary);
    color: white;
    border: none;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

#send-btn:hover {
    background: #152c6b;
    transform: scale(1.05);
}

#send-btn:disabled {
    background: #94a3b8;
    cursor: not-allowed;
    transform: none;
}

/* Fallback for cached HTML */
.fixed-banner {
    display: none !important;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes typing {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

@keyframes pulse {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
    70% { transform: scale(1.1); box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* Responsive */
.sidebar-overlay {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 15;
    opacity: 0;
    transition: opacity 0.3s;
}

@media (max-width: 768px) {
    .sidebar {
        position: absolute;
        height: 100%;
        transform: translateX(-100%);
    }
    
    .sidebar.open {
        transform: translateX(0);
        box-shadow: 5px 0 15px rgba(0,0,0,0.1);
    }
    
    .sidebar-overlay.show {
        display: block;
        opacity: 1;
    }

    .glass-header {
        padding: 10px 15px;
    }

    .logo-container h1 {
        font-size: 1.1rem;
        white-space: nowrap;
    }

    .install-text {
        display: none;
    }

    .install-btn {
        padding: 8px;
        border-radius: 50%;
        width: 35px;
        height: 35px;
        justify-content: center;
    }

    .welcome-card {
        padding: 20px;
    }

    .welcome-card h2 {
        font-size: 1.4rem;
    }

    .message {
        max-width: 95%;
        padding: 10px 15px;
        font-size: 0.95rem;
    }

    .input-area {
        padding: 12px 15px;
    }

    .input-wrapper {
        padding: 5px 8px 5px 5px;
        gap: 5px;
    }

    #query-input {
        padding: 8px 5px;
        font-size: 0.95rem;
        min-width: 0;
    }

    .icon-btn {
        padding: 8px;
        font-size: 1.1rem;
    }

    #send-btn {
        width: 40px;
        height: 40px;
        font-size: 1rem;
        flex-shrink: 0;
    }
    
    .header-left {
        gap: 10px;
    }
}

/* Root Map Modal CSS */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    background-color: #fff;
    margin: 5% auto;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    width: 80%;
    max-width: 800px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-header {
    padding: 15px 20px;
    background: var(--primary);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.2rem;
}

.close-btn {
    color: white;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close-btn:hover {
    color: #ddd;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    background: #f8fafc;
}

.root-map-section {
    background: white;
    border-radius: 8px;
    margin-bottom: 15px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    border: 1px solid #e2e8f0;
    overflow: hidden;
}

.root-map-header {
    padding: 15px;
    background: #f1f5f9;
    cursor: pointer;
    font-weight: bold;
    color: var(--primary);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.root-map-header:hover {
    background: #e2e8f0;
}

.root-map-content {
    padding: 15px;
    display: none;
    border-top: 1px solid #e2e8f0;
}

.root-map-list {
    list-style: none;
    padding-left: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
}

.root-map-list li {
    background: #f8fafc;
    padding: 10px;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
    font-size: 0.9rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Toggle Switch CSS */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.switch input { 
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: .4s;
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: .4s;
}

input:checked + .slider {
  background-color: #3b82f6;
}

input:focus + .slider {
  box-shadow: 0 0 1px #3b82f6;
}

input:checked + .slider:before {
  transform: translateX(20px);
}

.slider.round {
  border-radius: 24px;
}

.slider.round:before {
  border-radius: 50%;
}

/* Reader View Styles */
.content-display-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.reader-view-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: white;
    overflow: hidden;
}

.reader-header {
    padding: 15px 25px;
    background: var(--primary);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.reader-header h2 {
    font-size: 1.2rem;
    margin: 0;
    font-weight: 600;
}

.close-reader-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    transition: opacity 0.2s;
}

.close-reader-btn:hover {
    opacity: 0.8;
}

.reader-content {
    flex: 1;
    padding: 30px;
    overflow-y: auto;
    font-size: 1.05rem;
    line-height: 1.8;
    color: var(--text-primary);
}

.reader-content h1, .reader-content h2, .reader-content h3 {
    color: var(--primary);
    margin-bottom: 15px;
    margin-top: 25px;
}
.reader-content h1:first-child, .reader-content h2:first-child {
    margin-top: 0;
}

.reader-content p {
    margin-bottom: 15px;
}

/* Verse Selector Box */
.verse-selector-box {
    background: #f8fafc;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.verse-dropdown, .verse-input {
    width: 100%;
    padding: 8px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 0.9rem;
    margin-bottom: 5px;
    background: white;
}

.verse-input {
    width: 50%;
}

.verse-search-btn {
    width: 100%;
    background: var(--primary);
    color: white;
    border: none;
    padding: 8px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s;
}

.verse-search-btn:hover {
    background: #152c6b;
}

/* Document Item */
.doc-item {
    cursor: pointer;
    padding: 8px 10px;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
    background: white;
    margin-bottom: 5px;
    font-size: 0.85rem;
    transition: all 0.2s;
    color: var(--text-secondary);
}

.doc-item:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.folder-item {
    font-weight: 600;
    color: var(--primary);
    margin-top: 10px;
    margin-bottom: 5px;
    font-size: 0.9rem;
    padding-bottom: 3px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}

.folder-item:hover {
    color: var(--secondary);
}

.folder-docs-container {
    padding-left: 10px;
}

.commentary-item {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
}

.commentary-source {
    font-weight: 600;
    color: var(--primary);
    font-size: 0.9rem;
    margin-bottom: 8px;
    text-transform: uppercase;
}

.hebrew-word {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--secondary);
    margin-bottom: 10px;
}
