/* Magnetic Light Glassy History Button Upload/js/medchathistory.css */
:root {
    /* Light Medical Palette - Matching your chat interface */
    --surface-primary: rgba(255, 255, 255, 0.95);
    --surface-secondary: rgba(250, 251, 252, 0.9);
    --glass-light: rgba(255, 255, 255, 0.25);
    --glass-border: rgba(255, 255, 255, 0.18);
    --text-primary: #2c3e50;
    --text-secondary: #546e7a;
    --text-light: #78909c;
    --accent-medical: #4fc3f7;
    --accent-warm: #81c784;
    --shadow-light: 0 8px 32px rgba(79, 195, 247, 0.12);
    --shadow-magnetic: 0 12px 40px rgba(79, 195, 247, 0.2);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
/* --- OVERRIDE FOR INITIAL VIEW PLACEMENT --- */

/* 
  This targets the button container ONLY when it's inside the initial view.
  It changes its positioning from 'fixed' to 'relative' to fit the layout flow.
*/
#initial-view .magnetic-container {
    position: relative !important; /* Change from fixed to relative */
    top: auto !important;
    right: auto !important;
    z-index: 10 !important;
    padding: 0 !important;
    margin-bottom: 2rem; /* Add space between button and input bar */
    display: flex;
    justify-content: center;
}

/* Ensure the button itself is centered within the container */
#initial-view .magnetic-button {
    margin: 0 auto;
}


body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-primary);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

/* Light Background Elements */
.light-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

.floating-bubble {
    position: absolute;
    background: linear-gradient(135deg, 
        rgba(255, 255, 255, 0.1) 0%, 
        rgba(79, 195, 247, 0.05) 50%, 
        rgba(129, 199, 132, 0.05) 100%);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    animation: floatBubble 15s ease-in-out infinite;
}

.bubble-1 {
    width: 120px;
    height: 120px;
    top: 20%;
    left: 15%;
    animation-delay: 0s;
}

.bubble-2 {
    width: 80px;
    height: 80px;
    top: 60%;
    right: 20%;
    animation-delay: -5s;
}

.bubble-3 {
    width: 60px;
    height: 60px;
    bottom: 30%;
    left: 25%;
    animation-delay: -10s;
}

/* Magnetic Container */
.magnetic-container {
    position: relative;
    z-index: 100;
    padding: 20px;
}

/* Magnetic Light Glassy Button */
.magnetic-button {
    position: relative;
    width: 160px;
    height: 60px;
    border-radius: 20px;
    cursor: pointer;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    transform-style: preserve-3d;
    perspective: 1000px;
}

/* Glass Layer - Light and Semi-transparent */
.glass-layer {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, 
        rgba(255, 255, 255, 0.4) 0%, 
        rgba(255, 255, 255, 0.1) 50%, 
        rgba(255, 255, 255, 0.2) 100%);
    backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 20px;
    box-shadow: var(--shadow-light);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Content Layer */
.content-layer {
    position: relative;
    z-index: 2;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: var(--text-secondary);
    font-size: 16px;
    font-weight: 500;
    transition: all 0.3s ease;
    transform: translateZ(0);
}

.content-layer i {
    font-size: 18px;
    color: var(--accent-medical);
    transition: all 0.3s ease;
}

/* Magnetic Ripple Effect */
.magnetic-ripple {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: radial-gradient(circle, 
        rgba(79, 195, 247, 0.3) 0%, 
        rgba(79, 195, 247, 0.1) 40%, 
        transparent 70%);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

/* Hover Effects */
.magnetic-button:hover .glass-layer {
    background: linear-gradient(135deg, 
        rgba(255, 255, 255, 0.6) 0%, 
        rgba(79, 195, 247, 0.1) 50%, 
        rgba(255, 255, 255, 0.4) 100%);
    border-color: rgba(79, 195, 247, 0.4);
    box-shadow: var(--shadow-magnetic);
    transform: translateY(-2px);
}

.magnetic-button:hover .content-layer {
    color: var(--text-primary);
    transform: translateZ(10px);
}

.magnetic-button:hover .content-layer i {
    color: var(--accent-medical);
    transform: scale(1.1) rotate(15deg);
}

.magnetic-button:hover .magnetic-ripple {
    width: 200px;
    height: 200px;
    opacity: 1;
}

/* Active/Click Effect */
.magnetic-button:active {
    transform: scale(0.98);
}

.magnetic-button:active .glass-layer {
    background: linear-gradient(135deg, 
        rgba(79, 195, 247, 0.3) 0%, 
        rgba(255, 255, 255, 0.2) 50%, 
        rgba(79, 195, 247, 0.1) 100%);
}

/* History Popup - Light Glassy */
.history-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(248, 249, 250, 0.3);
    backdrop-filter: blur(8px);
    /* WITH this corrected, higher z-index */
    z-index: 10003; /* Higher than the sidebar's 10002 */
    display: none;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

.history-popup.show {
    display: flex;
}

.history-popup-content {
    background: linear-gradient(135deg, 
        rgba(255, 255, 255, 0.7) 0%, 
        rgba(255, 255, 255, 0.5) 100%);
    backdrop-filter: blur(25px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 24px;
    width: 90%;
    max-width: 480px;
    max-height: 85vh;
    box-shadow: 0 20px 60px rgba(79, 195, 247, 0.15);
    overflow: hidden;
    animation: slideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

/* Header */
.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.1);
}

.header-info {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 600;
}

.header-info i {
    color: var(--accent-medical);
}

.close-button {
    background: rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    color: var(--text-light);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-button:hover {
    background: rgba(255, 255, 255, 0.5);
    color: var(--text-primary);
    transform: scale(1.1) rotate(90deg);
}

/* Search Bar */
.history-search {
    position: relative;
    padding: 16px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.history-search i {
    position: absolute;
    left: 40px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
}

.history-search input {
    width: 100%;
    background: rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    padding: 12px 16px 12px 40px;
    color: var(--text-primary);
    outline: none;
    transition: all 0.3s ease;
}

.history-search input:focus {
    border-color: var(--accent-medical);
    background: rgba(255, 255, 255, 0.6);
    box-shadow: 0 0 0 3px rgba(79, 195, 247, 0.1);
}

/* Sessions List */
.history-sessions {
    flex-grow: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.session-item {
    padding: 14px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    transition: all 0.3s ease;
}

.session-item:hover {
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
}

.session-preview {
    color: var(--text-primary);
    font-weight: 500;
    margin-bottom: 6px;
}

.session-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: var(--text-light);
}

.session-count {
    background: rgba(79, 195, 247, 0.15);
    color: var(--accent-medical);
    padding: 2px 8px;
    border-radius: 8px;
    font-weight: 500;
    backdrop-filter: blur(5px);
}

/* New Chat Section */
.new-chat-section {
    padding: 16px 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.1);
}

.new-chat-button {
    width: 100%;
    border: none;
    border-radius: 12px;
    padding: 12px;
    color: black;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.new-chat-button:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-magnetic);
}

/* Animations */
@keyframes floatBubble {
    0%, 100% { transform: translateY(0px) rotate(0deg); }
    25% { transform: translateY(-20px) rotate(90deg); }
    50% { transform: translateY(-15px) rotate(180deg); }
    75% { transform: translateY(-25px) rotate(270deg); }
}

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

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Responsive Design */
@media (max-width: 768px) {
    .magnetic-button {
        width: 140px;
        height: 50px;
    }
    
    .content-layer {
        font-size: 14px;
    }
    
    .history-popup-content {
        width: 95%;
        border-radius: 20px;
    }
    
    .floating-bubble {
        display: none;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}