@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&display=swap');

:root {
    --primary: #00E676;
    --primary-dark: #00C853;
    --primary-light: rgba(0, 230, 118, 0.12);
    --bg-body: #f3f5f8;
    --sidebar-bg: #ffffff;
    --card-bg: #ffffff;
    --text-main: #111827;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 20px 35px -8px rgba(0, 0, 0, 0.12);
}

/* DARK MODE */
body.dark-mode {
    --primary: #00E676;
    --primary-dark: #00C853;
    --primary-light: rgba(0, 230, 118, 0.15);
    --bg-body: #0d1117;
    --sidebar-bg: #161b22;
    --card-bg: #161b22;
    --text-main: #f0f6fc;
    --text-muted: #8b949e;
    --border: #30363d;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 20px 35px -8px rgba(0, 0, 0, 0.6);
}

* { 
    box-sizing: border-box; 
    margin: 0; 
    padding: 0; 
    -webkit-tap-highlight-color: transparent; 
}

body { 
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif; 
    background: var(--bg-body); 
    height: 100dvh; 
    display: flex; 
    overflow: hidden; 
    color: var(--text-main);
    transition: background 0.25s ease, color 0.25s ease;
}

/* --- SIDEBAR --- */
#sidebar-container { 
    width: 290px; 
    background: var(--sidebar-bg); 
    border-right: 1px solid var(--border); 
    height: 100%; 
    display: flex; 
    flex-direction: column; 
    z-index: 2000; 
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
}

.new-chat-wrapper { 
    padding: 20px 18px 12px; 
}

.new-chat-btn { 
    width: 100%; 
    padding: 13px 18px; 
    background: var(--text-main); 
    color: var(--sidebar-bg); 
    border-radius: 14px; 
    font-weight: 700; 
    font-size: 14px;
    cursor: pointer; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    gap: 10px; 
    border: none;
    transition: transform 0.15s ease, opacity 0.15s ease;
    box-shadow: var(--shadow);
}
.new-chat-btn:hover { 
    opacity: 0.92; 
    transform: translateY(-1px);
}

.sidebar-section-title {
    padding: 14px 18px 8px; 
    font-size: 11px; 
    font-weight: 800; 
    letter-spacing: 0.8px;
    color: var(--text-muted);
    text-transform: uppercase;
}

.tools-grid { 
    display: grid; 
    grid-template-columns: 1fr 1fr; 
    gap: 8px; 
    padding: 0 18px; 
}

.tool-item { 
    background: var(--bg-body); 
    border: 1px solid var(--border); 
    border-radius: 12px; 
    padding: 12px 10px; 
    text-align: center; 
    font-size: 12px; 
    font-weight: 600; 
    cursor: pointer; 
    color: var(--text-main);
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    gap: 6px;
    transition: all 0.2s ease;
}
.tool-item i {
    font-size: 16px;
    color: var(--primary);
}
.tool-item:hover { 
    border-color: var(--primary); 
    background: var(--primary-light);
    transform: translateY(-2px);
}

#historyList {
    flex: 1; 
    overflow-y: auto; 
    padding: 6px 14px;
}

.history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-radius: 10px;
    margin-bottom: 4px;
    font-size: 13.5px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.history-item:hover, .history-item.active {
    background: var(--primary-light);
    color: var(--text-main);
    font-weight: 600;
}
.history-item i {
    font-size: 12px;
    margin-right: 8px;
    color: var(--primary);
}

.sidebar-bottom {
    padding: 16px 18px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.reset-app-btn {
    font-size: 12px;
    font-weight: 600;
    color: #ef4444;
    cursor: pointer;
    background: transparent;
    border: none;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: opacity 0.2s;
}
.reset-app-btn:hover {
    opacity: 0.7;
}

/* --- MAIN CONTAINER --- */
#main-container { 
    flex: 1; 
    display: flex; 
    flex-direction: column; 
    position: relative; 
    height: 100%;
    overflow: hidden;
}

#header-container { 
    height: 64px; 
    border-bottom: 1px solid var(--border); 
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
    padding: 0 24px; 
    background: var(--sidebar-bg); 
    z-index: 100;
    flex-shrink: 0;
}

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

.brand-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    cursor: pointer;
}
.brand-icon {
    font-size: 22px;
    color: var(--primary);
}
.brand-name {
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -0.5px;
    color: var(--text-main);
}
.brand-badge {
    font-size: 10px;
    font-weight: 800;
    background: var(--primary-light);
    color: var(--primary-dark);
    padding: 2px 8px;
    border-radius: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 14px;
}

.sos-btn {
    background: #ef4444;
    color: #ffffff;
    padding: 7px 16px;
    border-radius: 50px;
    font-weight: 800;
    font-size: 12px;
    letter-spacing: 1px;
    border: none;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(239, 68, 68, 0.4);
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}
.sos-btn:hover {
    background: #dc2626;
    transform: scale(1.04);
}

.nav-icon-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 15px;
    transition: all 0.2s;
}
.nav-icon-btn:hover {
    color: var(--primary);
    border-color: var(--primary);
    background: var(--primary-light);
}

.mobile-menu-btn {
    font-size: 20px;
    cursor: pointer;
    color: var(--text-muted);
    display: none;
}

/* --- CHAT AREA --- */
#chat-box { 
    flex: 1; 
    padding: 24px 20px 130px; 
    overflow-y: auto; 
    display: flex; 
    flex-direction: column; 
    gap: 20px; 
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
}

/* Welcome Hero */
.welcome-hero {
    margin: auto 0;
    text-align: center;
    padding: 30px 15px;
}
.welcome-badge-icon {
    width: 64px;
    height: 64px;
    border-radius: 20px;
    background: var(--primary-light);
    color: var(--primary);
    font-size: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    box-shadow: 0 8px 20px rgba(0, 230, 118, 0.2);
}
.welcome-hero h1 {
    font-size: 28px;
    font-weight: 800;
    margin-bottom: 8px;
    color: var(--text-main);
}
.welcome-hero p {
    font-size: 15px;
    color: var(--text-muted);
    max-width: 520px;
    margin: 0 auto 24px;
    line-height: 1.5;
}
.suggestion-chips {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    max-width: 680px;
    margin: 0 auto;
}
.chip {
    background: var(--card-bg);
    border: 1px solid var(--border);
    padding: 10px 16px;
    border-radius: 30px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 8px;
}
.chip i {
    color: var(--primary);
}
.chip:hover {
    border-color: var(--primary);
    background: var(--primary-light);
    transform: translateY(-2px);
}

/* Message bubbles */
.message { 
    display: flex; 
    gap: 12px; 
    max-width: 88%; 
    width: fit-content; 
    animation: fadeIn 0.2s ease-out;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.user-msg { 
    align-self: flex-end; 
    flex-direction: row-reverse; 
}
.ai-msg { 
    align-self: flex-start; 
}

.msg-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
    margin-top: 4px;
}
.user-msg .msg-avatar {
    background: #111827;
    color: #fff;
}
.ai-msg .msg-avatar {
    background: var(--primary);
    color: #0b2e1b;
    box-shadow: 0 2px 8px rgba(0, 230, 118, 0.3);
}

.msg-body-wrapper {
    display: flex;
    flex-direction: column;
    max-width: 100%;
}

.msg-content { 
    padding: 16px 20px; 
    border-radius: 18px; 
    font-size: 15px; 
    line-height: 1.65; 
    box-shadow: var(--shadow); 
    word-wrap: break-word; 
    max-width: 100%;
}
.user-msg .msg-content { 
    background: var(--text-main); 
    color: var(--sidebar-bg); 
    border-top-right-radius: 4px; 
}
.ai-msg .msg-content { 
    background: var(--card-bg); 
    color: var(--text-main); 
    border: 1px solid var(--border); 
    border-top-left-radius: 4px; 
}

.msg-content h1, .msg-content h2, .msg-content h3, .msg-content h4 {
    margin: 12px 0 6px;
    color: var(--text-main);
}
.msg-content h3 { font-size: 16px; font-weight: 700; color: var(--primary-dark); }
.msg-content ul, .msg-content ol {
    margin: 8px 0 8px 20px;
}
.msg-content li {
    margin-bottom: 4px;
}
.msg-content p {
    margin-bottom: 8px;
}
.msg-content p:last-child {
    margin-bottom: 0;
}

/* Tool buttons beneath AI message */
.msg-tools { 
    display: flex; 
    gap: 8px; 
    margin-top: 8px; 
    flex-wrap: wrap; 
}
.tool-pill { 
    padding: 5px 12px; 
    background: var(--card-bg); 
    border: 1px solid var(--border); 
    border-radius: 20px; 
    font-size: 11.5px; 
    font-weight: 600;
    color: var(--text-muted); 
    cursor: pointer; 
    display: flex; 
    align-items: center; 
    gap: 5px; 
    transition: all 0.2s;
}
.tool-pill:hover { 
    border-color: var(--primary); 
    color: var(--primary-dark); 
    background: var(--primary-light);
}

/* Video link card */
.video-card {
    display: inline-flex; 
    align-items: center; 
    gap: 10px; 
    margin-top: 10px; 
    padding: 10px 16px; 
    background: #fef2f2; 
    border: 1px solid #fecaca; 
    border-radius: 12px; 
    text-decoration: none; 
    color: #dc2626; 
    font-weight: 600;
    font-size: 13.5px;
    transition: transform 0.2s;
}
.video-card:hover {
    transform: translateY(-2px);
    background: #fee2e2;
}
.video-card i {
    font-size: 18px;
}

/* Typing Indicator */
.typing-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 12px 18px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 18px;
    width: fit-content;
}
.typing-dot {
    width: 7px;
    height: 7px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: typingPulse 1.4s infinite ease-in-out;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingPulse {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* --- INPUT AREA --- */
.input-area { 
    position: absolute; 
    bottom: 0; 
    left: 0; 
    width: 100%; 
    padding: 18px 24px 22px; 
    background: linear-gradient(to top, var(--bg-body) 75%, transparent); 
    z-index: 90;
}
.input-wrapper { 
    max-width: 820px; 
    margin: 0 auto; 
    background: var(--sidebar-bg); 
    border-radius: 50px; 
    border: 1px solid var(--border); 
    display: flex; 
    align-items: center; 
    padding: 6px 10px 6px 20px; 
    box-shadow: var(--shadow-lg); 
    gap: 10px;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.input-wrapper:focus-within {
    border-color: var(--primary);
    box-shadow: 0 10px 30px rgba(0, 230, 118, 0.15);
}
input#userInput { 
    flex: 1; 
    padding: 12px 0; 
    border: none; 
    background: transparent; 
    outline: none; 
    font-size: 15px; 
    font-family: inherit;
    color: var(--text-main); 
}
input#userInput::placeholder {
    color: var(--text-muted);
}

.mic-btn { 
    font-size: 17px; 
    color: var(--text-muted); 
    cursor: pointer; 
    padding: 10px; 
    border-radius: 50%;
    transition: all 0.2s;
}
.mic-btn:hover { 
    color: var(--primary); 
    background: var(--primary-light);
}
.mic-btn.active {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.15);
    animation: micPulse 1s infinite alternate;
}
@keyframes micPulse {
    from { transform: scale(1); }
    to { transform: scale(1.15); }
}

.send-btn { 
    width: 42px; 
    height: 42px; 
    border-radius: 50%; 
    background: var(--primary); 
    color: #0b2e1b; 
    border: none; 
    cursor: pointer; 
    display: flex; 
    align-items: center; 
    justify-content: center;
    font-size: 15px;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(0, 230, 118, 0.35);
}
.send-btn:hover {
    background: var(--primary-dark);
    color: #ffffff;
    transform: scale(1.05);
}

/* --- MODAL SYSTEM --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(6px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 20px;
    box-sizing: border-box;
}

.modal-overlay.active {
    display: flex !important;
}

.modal-box {
    background: var(--sidebar-bg);
    color: var(--text-main);
    width: 100%;
    max-width: 540px;
    max-height: 88vh;
    overflow-y: auto;
    border-radius: 20px;
    padding: 28px 24px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35);
    border: 1px solid var(--border);
    position: relative;
    animation: modalSlide 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalSlide {
    from { opacity: 0; transform: scale(0.96) translateY(14px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-close {
    position: absolute;
    top: 18px;
    right: 20px;
    font-size: 24px;
    line-height: 1;
    color: var(--text-muted);
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}
.modal-close:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

.modal-box h3 {
    font-size: 20px;
    font-weight: 800;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-main);
}
.modal-box h3 i {
    color: var(--primary);
}
.modal-desc {
    font-size: 13.5px;
    color: var(--text-muted);
    margin-bottom: 20px;
    line-height: 1.4;
}

.modal-input, .modal-textarea, select.modal-input {
    width: 100%;
    padding: 13px 16px;
    margin-bottom: 14px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--bg-body);
    color: var(--text-main);
    font-family: inherit;
    font-size: 14.5px;
    outline: none;
    transition: border-color 0.2s;
    box-sizing: border-box;
}
.modal-input:focus, .modal-textarea:focus, select.modal-input:focus {
    border-color: var(--primary);
}

.modal-btn {
    width: 100%;
    padding: 14px;
    background: var(--primary);
    color: #0b2e1b;
    font-weight: 700;
    font-size: 15px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(0, 230, 118, 0.25);
}
.modal-btn:hover {
    background: var(--primary-dark);
    color: #ffffff;
}

.modal-result {
    margin-top: 18px;
    padding: 16px;
    background: var(--bg-body);
    border: 1px solid var(--border);
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.6;
    display: none;
    animation: fadeIn 0.2s ease-out;
}

/* Lawyer cards inside modal */
.lawyer-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 14px;
    margin-bottom: 10px;
    background: var(--bg-body);
    transition: all 0.2s;
}
.lawyer-card:hover {
    border-color: var(--primary);
}
.lawyer-img {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    object-fit: cover;
}
.lawyer-info h4 {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-main);
}
.lawyer-info p {
    font-size: 12px;
    color: var(--text-muted);
}
.lawyer-call-btn {
    padding: 8px 14px;
    background: var(--primary);
    color: #0b2e1b;
    font-weight: 700;
    font-size: 12px;
    border-radius: 20px;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}
.lawyer-call-btn:hover {
    background: var(--primary-dark);
    color: #ffffff;
}

/* Video embed cards inside modal */
.video-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
}
.video-item {
    background: var(--bg-body);
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
}
.video-item iframe {
    width: 100%;
    height: 190px;
    display: block;
}
.video-item-info {
    padding: 12px 14px;
}
.video-item-info b {
    font-size: 14px;
    color: var(--text-main);
}
.video-item-info span {
    font-size: 12px;
    color: var(--text-muted);
    display: block;
    margin-top: 3px;
}

/* SOS OVERLAY */
.sos-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(185, 28, 28, 0.95);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 20px;
    color: white;
    text-align: center;
    box-sizing: border-box;
}

.sos-overlay.active {
    display: flex !important;
}

.sos-box {
    background: #7f1d1d;
    border: 2px solid #ef4444;
    border-radius: 24px;
    padding: 40px 30px;
    max-width: 480px;
    width: 100%;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.6);
    animation: sosPulse 1.2s infinite alternate;
}

@keyframes sosPulse {
    from { transform: scale(0.98); box-shadow: 0 0 25px rgba(239, 68, 68, 0.5); }
    to { transform: scale(1.02); box-shadow: 0 0 50px rgba(239, 68, 68, 0.8); }
}

.sos-box h1 {
    font-size: 30px;
    font-weight: 900;
    letter-spacing: 2px;
    margin-bottom: 14px;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.sos-box p {
    font-size: 15px;
    margin-bottom: 10px;
    line-height: 1.5;
    color: #fee2e2;
}

.sos-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 24px;
}

.sos-call-btn {
    padding: 13px 24px;
    font-size: 15px;
    font-weight: 800;
    background: #ffffff;
    color: #991b1b;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: transform 0.2s;
}
.sos-call-btn:hover {
    transform: scale(1.05);
}

.sos-stop-btn {
    padding: 13px 24px;
    font-size: 15px;
    font-weight: 800;
    background: transparent;
    color: #ffffff;
    border: 2px solid #ffffff;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.2s;
}
.sos-stop-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* Overlay Backdrop for mobile drawer */
.overlay-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1999;
}
.overlay-backdrop.active {
    display: block;
}

/* --- MOBILE RESPONSIVE --- */
@media (max-width: 768px) {
    #sidebar-container { 
        position: fixed; 
        left: -100%; 
        height: 100%; 
        box-shadow: 10px 0 50px rgba(0,0,0,0.3); 
    }
    #sidebar-container.active { 
        left: 0; 
    }
    .mobile-menu-btn { 
        display: block; 
    }
    .input-area { 
        padding: 12px 14px 16px; 
    }
    #chat-box { 
        padding: 16px 14px 120px; 
    }
    .message { 
        max-width: 95%; 
    }
    .brand-name {
        font-size: 18px;
    }
}
