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

:root {
    --bg-dark: #0a0b1e;
    --accent-primary: #00f2ff;
    --accent-secondary: #7000ff;
    --text-main: #e0e0ff;
    --text-dim: #a0a0c0; /* Added missing variable */
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
}

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

body {
    font-family: 'Inter', sans-serif;
    background: radial-gradient(circle at top right, #1a1b3a, var(--bg-dark));
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
}

h1, h2, h3 {
    font-family: 'Orbitron', sans-serif;
    letter-spacing: 2px;
}

.auth-container {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    padding: 40px;
    border-radius: 20px;
    width: 400px;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5);
    text-align: center;
    animation: fadeIn 1s ease-out;
}

.auth-container h1 {
    margin-bottom: 25px;
    color: var(--accent-primary);
    text-shadow: 0 0 15px rgba(0, 242, 255, 0.5);
}

.input-group {
    margin-bottom: 20px;
    text-align: left;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.8rem;
    color: #a0a0ff;
}

input, textarea {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    padding: 12px;
    border-radius: 8px;
    color: white;
    outline: none;
    transition: 0.3s;
    font-family: inherit;
}

input:focus, textarea:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 10px rgba(0, 242, 255, 0.2);
}

#chat-input {
    height: 100px;
    resize: none;
    line-height: 1.5;
    background: rgba(255, 255, 255, 0.05);
}

.input-wrapper {
    align-items: flex-start !important;
}

button {
    width: 100%;
    padding: 14px;
    border-radius: 8px;
    border: none;
    background: linear-gradient(45deg, var(--accent-secondary), var(--accent-primary));
    color: white;
    font-family: 'Orbitron', sans-serif;
    font-weight: bold;
    cursor: pointer;
    transition: 0.3s;
    margin-top: 10px;
}

.chat-input-area button {
    padding: 10px 20px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    border: none;
    border-radius: 8px;
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.chart-container {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 20px;
    margin: 15px 0;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    max-width: 100%;
    animation: fadeIn 0.5s ease-out;
}

.chart-container canvas {
    max-height: 300px;
}

.study-sheet {
    background: #fffbe6; /* Light parchment color */
    color: #333;
    border-left: 5px solid #ffcc00;
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
    font-family: 'Handlee', 'Segoe UI', cursive, sans-serif;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    position: relative;
    overflow: hidden;
    animation: slideInLeft 0.5s ease-out;
}

.study-sheet h3 {
    margin-top: 0;
    color: #b38600;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.study-sheet h3::before {
    content: '✍️';
}

.study-item {
    margin: 10px 0;
    padding-left: 20px;
    position: relative;
    font-size: 1rem;
    line-height: 1.5;
}

.study-item::before {
    content: '□';
    position: absolute;
    left: 0;
    color: #ffaa00;
    font-weight: bold;
}

#mic-btn.recording {
    border-color: #ff4d4d !important;
    box-shadow: 0 0 15px rgba(255, 77, 77, 0.6);
    animation: mic-pulse 1.5s infinite;
}

@keyframes mic-pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.7; }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes slideInLeft {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}

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

.chat-input-area button:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(112, 0, 255, 0.4);
}

.link-btn {
    background: none;
    border: none;
    color: var(--accent-primary);
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    margin-top: 15px;
    text-decoration: underline;
}

/* Dashboard & Chat */
.dashboard-container {
    width: 90%;
    max-width: 1200px;
    height: 85vh;
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 20px;
}

.sidebar {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 20px;
}

.chat-area {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    padding: 20px;
}

#chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.message {
    max-width: 80%;
    padding: 12px 18px;
    border-radius: 15px;
    line-height: 1.5;
}

.user-msg {
    align-self: flex-end;
    background: var(--accent-secondary);
    color: white;
}

.ai-msg {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--glass-border);
}

.msg-content p {
    margin: 8px 0;
}

.msg-content ul, .msg-content ol {
    margin: 8px 0;
    padding-left: 20px;
}

.msg-content li {
    margin: 4px 0;
}

.error-msg {
    color: #ff4d4d;
    font-weight: bold;
}

.msg-telemetry {
    font-size: 0.7rem;
    opacity: 0.4;
    text-align: right;
    margin-top: 8px;
    font-family: 'Orbitron', sans-serif;
    letter-spacing: 0.5px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding-top: 5px;
    color: var(--text-dim);
}

.user-msg .response-time {
    display: none; /* Only show for AI */
}

.achievement-unlock {
    background: rgba(255, 215, 0, 0.1);
    border: 2px solid gold !important;
    padding: 15px;
    border-radius: 12px;
    margin: 15px 0;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.3);
    animation: glow 2s infinite alternate;
}

@keyframes glow {
    from { box-shadow: 0 0 10px rgba(255, 215, 0, 0.2); }
    to { box-shadow: 0 0 25px rgba(255, 215, 0, 0.5); }
}

.sync-status {
    color: var(--accent-secondary);
    font-weight: bold;
    font-family: 'Orbitron', sans-serif;
    letter-spacing: 1px;
    text-shadow: 0 0 5px var(--accent-secondary);
}

#loading-indicator {
    background: rgba(255, 255, 255, 0.03);
    border: 1px dashed rgba(0, 242, 255, 0.2);
    font-style: italic;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 12px;
}

.thinking-mode .msg-content {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--accent-primary);
}

.dot-pulse {
    position: relative;
    width: 6px;
    height: 6px;
    border-radius: 5px;
    background-color: var(--accent-primary);
    color: var(--accent-primary);
    box-shadow: 12px 0 0 0 var(--accent-primary), -12px 0 0 0 var(--accent-primary);
    animation: dot-pulse 1.5s infinite linear;
    margin-left: 20px;
    margin-right: 20px;
}

@keyframes dot-pulse {
    0% { box-shadow: 12px 0 0 0 rgba(0, 242, 255, 0.2), -12px 0 0 0 var(--accent-primary); }
    50% { box-shadow: 12px 0 0 0 var(--accent-primary), -12px 0 0 0 var(--accent-primary); }
    100% { box-shadow: 12px 0 0 0 var(--accent-primary), -12px 0 0 0 rgba(0, 242, 255, 0.2); }
}

.chat-input-area {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

/* MIC RECORDING PULSE ANIMATION */
#mic-btn.recording {
    background: rgba(0, 210, 255, 0.2) !important;
    border: 1px solid #00d2ff !important;
    color: #00d2ff !important;
    animation: mic-glow 1.5s infinite ease-in-out;
    box-shadow: 0 0 15px rgba(0, 210, 255, 0.4);
}

@keyframes mic-glow {
    0% { transform: scale(1); box-shadow: 0 0 5px rgba(0, 210, 255, 0.2); }
    50% { transform: scale(1.08); box-shadow: 0 0 20px rgba(0, 210, 255, 0.6); }
    100% { transform: scale(1); box-shadow: 0 0 5px rgba(0, 210, 255, 0.2); }
}

}

/* NEURAL UPLINK STATUS BAR */
#uplink-status {
    background: rgba(0, 242, 255, 0.05);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(0, 242, 255, 0.2);
    border-radius: 8px;
    padding: 8px 15px;
    margin-bottom: 15px;
    font-size: 0.8rem;
    color: #00f2ff;
    font-family: 'Orbitron', sans-serif;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slide-up 0.3s ease-out, status-pulse 2s infinite ease-in-out;
    box-shadow: 0 0 10px rgba(0, 242, 255, 0.1);
}

#uplink-status.hidden {
    display: none !important;
}

@keyframes slide-up {
    from { transform: translateY(10px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes status-pulse {
    0% { border-color: rgba(0, 242, 255, 0.2); box-shadow: 0 0 5px rgba(0, 242, 255, 0.1); }
    50% { border-color: rgba(0, 242, 255, 0.5); box-shadow: 0 0 15px rgba(0, 242, 255, 0.2); }
    100% { border-color: rgba(0, 242, 255, 0.2); box-shadow: 0 0 5px rgba(0, 242, 255, 0.1); }
}

/* NEURAL REFINEMENT UI */
.neural-overlay {
    position: absolute;
    top: -25px; /* Moved above the textarea */
    right: 15px;
    font-size: 0.75rem;
    color: var(--accent-primary);
    font-style: italic;
    font-family: 'Orbitron', sans-serif;
    letter-spacing: 1px;
    pointer-events: none;
    animation: refine-pulse 1.5s infinite ease-in-out;
    text-shadow: 0 0 8px rgba(0, 242, 255, 0.5);
}

@keyframes refine-pulse {
    0% { opacity: 0.4; transform: translateX(0); }
    50% { opacity: 1; transform: translateX(-3px); }
    100% { opacity: 0.4; transform: translateX(0); }
}

.suggestion-toast {
    position: absolute;
    bottom: 150px; /* Moved up to clear 100px textarea */
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    background: rgba(10, 11, 30, 0.95);
    border: 1px solid var(--accent-primary);
    border-radius: 12px;
    padding: 12px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), 0 0 20px rgba(0, 242, 255, 0.1);
    z-index: 500;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.suggestion-toast.hidden {
    bottom: 120px; /* Adjusted hidden position */
    opacity: 0;
    pointer-events: none;
}

.suggestion-content {
    flex: 1;
    font-size: 0.85rem;
    color: var(--text-main);
    line-height: 1.4;
}

.suggestion-content strong {
    color: var(--accent-primary);
    display: block;
    font-size: 0.7rem;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.suggestion-actions {
    display: flex;
    gap: 8px;
}

.suggest-btn {
    padding: 6px 12px !important;
    font-size: 0.7rem !important;
    margin: 0 !important;
    white-space: nowrap;
}

.suggest-btn.accept {
    background: var(--accent-primary) !important;
    color: #000 !important;
}

.suggest-btn.ignore {
    background: rgba(255, 255, 255, 0.1) !important;
    border: 1px solid var(--glass-border) !important;
}

/* Polished Text Flash Effect */
.refined-flash {
    animation: text-polish-flash 0.6s ease-out;
}

@keyframes text-polish-flash {
    0% { color: #fff; text-shadow: 0 0 20px #00f2ff; }
    100% { color: inherit; text-shadow: none; }
}

/* Fixed Modal Popup Overlay */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000; /* Ensure it stays above EVERYTHING */
    backdrop-filter: blur(15px);
    transition: opacity 0.3s ease;
}

.modal.hidden {
    display: none !important;
}

.modal-content.profile-layout {
    max-width: 1000px;
    width: 90%;
    height: 85vh;
    display: flex;
    flex-direction: column;
    padding: 35px; /* Added extra padding for safety */
    background: rgba(10, 11, 30, 0.98);
    backdrop-filter: blur(30px);
    border: 1px solid rgba(0, 242, 255, 0.3);
    box-shadow: 0 0 60px rgba(0, 0, 0, 0.8), 0 0 30px rgba(0, 242, 255, 0.1);
    animation: modalPop 0.4s cubic-bezier(0.18, 0.89, 0.32, 1.28);
    position: relative;
    overflow: hidden;
}

@keyframes modalPop {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.close-btn {
    position: absolute;
    top: 20px;
    right: 25px;
    font-size: 1.8rem;
    color: var(--text-dim);
    cursor: pointer;
    transition: 0.3s;
    z-index: 100; /* Force to top */
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
}

.close-btn:hover {
    color: #ff4d4d;
    background: rgba(255, 77, 77, 0.1);
}

/* User Header - Circular Icon Parity */
.profile-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 25px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 20px;
}

.profile-user {
    display: flex;
    align-items: center;
    gap: 25px;
}

.icon-circle {
    width: 80px;
    height: 80px;
    background: rgba(0, 242, 255, 0.1);
    border: 2px solid var(--accent-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 20px rgba(0, 242, 255, 0.3);
}

.icon-circle i {
    font-size: 3.5rem;
    color: var(--accent-primary);
}

.profile-user h2 {
    font-size: 2rem;
    background: linear-gradient(to right, #fff, var(--accent-primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 4px;
}

.profile-stats {
    display: flex;
    gap: 15px;
}

.p-stat {
    background: rgba(255, 255, 255, 0.03);
    padding: 15px 25px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    text-align: center;
    min-width: 120px;
}

.p-stat h4 {
    font-size: 1.8rem;
    color: var(--accent-primary);
}

.p-stat span {
    font-size: 0.7rem;
    color: #a0a0c0;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.profile-main {
    display: flex;
    gap: 30px;
    flex: 1;
    min-height: 0;
}

.profile-chart-section {
    width: 350px;
    display: flex;
    flex-direction: column;
}

.canvas-container {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 15px;
    padding: 15px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.profile-timeline-section {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.profile-timeline-container {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    flex: 1;
    overflow-y: auto;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.profile-timeline-container::-webkit-scrollbar {
    width: 8px;
}

/* HIGH VISIBILITY NEON SCROLLBAR */
.profile-timeline-container::-webkit-scrollbar-thumb {
    background: linear-gradient(to bottom, var(--accent-primary), var(--accent-secondary));
    border-radius: 10px;
}

.profile-timeline-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed; /* Keep layout stable */
}

.profile-timeline-table th {
    position: sticky;
    top: 0;
    background: #141932;
    z-index: 10;
    text-align: left;
    font-size: 0.75rem;
    color: var(--accent-primary);
    padding: 15px;
    border-bottom: 2px solid rgba(0, 242, 255, 0.2);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.profile-timeline-table td {
    padding: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 0.9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Explicitly allow buttons to be visible in the last cell */
.profile-timeline-table td:last-child {
    overflow: visible;
}

.profile-timeline-table td:nth-child(1) {
    font-weight: 600;
}

/* Action Button Styles */
.btn-mini {
    transition: all 0.2s ease;
    text-transform: uppercase;
    font-family: 'Orbitron', sans-serif;
    letter-spacing: 1px;
}

.btn-mini:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 242, 255, 0.2);
    filter: brightness(1.2);
}

/* --- COLLAPSIBLE THINKING UI --- */
.thinking-box {
    margin-bottom: 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(0, 242, 255, 0.1);
    border-radius: 10px;
    overflow: hidden;
    font-size: 0.85rem;
    transition: all 0.3s ease;
}

.thinking-box details {
    padding: 0;
}

.thinking-box summary {
    padding: 8px 12px;
    background: rgba(0, 242, 255, 0.05);
    color: var(--accent-primary);
    cursor: pointer;
    font-family: 'Orbitron', sans-serif;
    font-size: 0.75rem;
    letter-spacing: 1px;
    list-style: none; /* Hide default arrow */
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.2s;
}

.thinking-box summary::before {
    content: '🧠';
    font-size: 0.9rem;
}

.thinking-box summary:hover {
    background: rgba(0, 242, 255, 0.1);
}

.thinking-box summary::-webkit-details-marker {
    display: none;
}

.thinking-content {
    padding: 12px;
    color: var(--text-dim);
    line-height: 1.4;
    font-style: italic;
    border-top: 1px solid rgba(0, 242, 255, 0.1);
    max-height: 200px;
    overflow-y: auto;
}

.thinking-content blockquote {
    border-left: 2px solid var(--accent-secondary);
    margin: 10px 0;
    padding-left: 10px;
    color: var(--text-dim);
}

/* --- VOICE SENTINEL STYLES --- */
.sentinel-toast {
    position: absolute;
    bottom: 145px; /* Moved up to clear 100px textarea */
    left: 50%;
    transform: translateX(-50%);
    background: rgba(40, 30, 10, 0.85);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 180, 0, 0.3);
    border-radius: 12px;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    z-index: 1000;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 15px rgba(255, 180, 0, 0.1);
    animation: slideUp 0.3s ease, gentle-pulse 2s infinite ease-in-out;
    color: #ffd400;
    font-size: 0.85rem;
    font-weight: 500;
}

.sentinel-toast .sentinel-actions {
    display: flex;
    gap: 8px;
}

.sentinel-btn {
    background: rgba(255, 212, 0, 0.1);
    border: 1px solid rgba(255, 212, 0, 0.4);
    color: #ffd400;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
    text-transform: uppercase;
    font-family: 'Orbitron', sans-serif;
    transition: all 0.2s ease;
}

.sentinel-btn:hover {
    background: rgba(255, 212, 0, 0.2);
    transform: translateY(-1px);
}

@keyframes gentle-pulse {
    0% { box-shadow: 0 0 0 0 rgba(255, 180, 0, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(255, 180, 0, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 180, 0, 0); }
}

@keyframes slideUp {
    from { transform: translate(-50%, 20px); opacity: 0; }
    to { transform: translate(-50%, 0); opacity: 1; }
}
