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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    background: linear-gradient(135deg, #1e3a5f 0%, #2d1b4e 50%, #1a1a2e 100%);
    color: #ececf1;
    height: 100vh;
    overflow: hidden;
    margin: 0;
    padding: 0;
}

/* Sidebar Toggle Button */
.sidebar-toggle {
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 1001;
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.9) 0%, rgba(184, 134, 11, 0.9) 100%);
    border: none;
    border-radius: 8px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.5);
    transition: all 0.3s ease;
}

.sidebar-toggle:hover {
    background: linear-gradient(135deg, #ffd700 0%, #d4af37 100%);
    box-shadow: 0 0 25px rgba(212, 175, 55, 0.7);
    transform: scale(1.05);
}

.sidebar-toggle svg {
    color: #1a1a2e;
}

/* Sidebar */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 252px;
    background: linear-gradient(180deg, rgba(30, 58, 95, 0.95) 0%, rgba(45, 27, 78, 0.95) 100%);
    backdrop-filter: blur(10px);
    border-right: 2px solid rgba(212, 175, 55, 0.3);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    transform: translateX(0); /* Open by default */
}

.sidebar.closed {
    transform: translateX(-100%);
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 2px solid rgba(212, 175, 55, 0.2);
}

.sidebar-header h2 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, #ffd700 0%, #d4af37 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.new-chat-btn {
    width: 100%;
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, #ffd700 0%, #d4af37 100%);
    border: none;
    border-radius: 8px;
    color: #1a1a2e;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.4);
}

.new-chat-btn:hover {
    background: linear-gradient(135deg, #ffed4e 0%, #ffd700 100%);
    box-shadow: 0 0 25px rgba(212, 175, 55, 0.6);
    transform: translateY(-2px);
}

.chat-list {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.chat-list::-webkit-scrollbar {
    width: 6px;
}

.chat-list::-webkit-scrollbar-track {
    background: transparent;
}

.chat-list::-webkit-scrollbar-thumb {
    background: rgba(212, 175, 55, 0.3);
    border-radius: 3px;
}

.chat-list::-webkit-scrollbar-thumb:hover {
    background: rgba(212, 175, 55, 0.5);
}

.chat-item {
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}

.chat-item:hover {
    background: rgba(212, 175, 55, 0.1);
    border-left-color: #d4af37;
}

.chat-item.active {
    background: rgba(212, 175, 55, 0.2);
    border-left-color: #ffd700;
}

.chat-item-content {
    flex: 1;
    min-width: 0;
}

.chat-item-title {
    font-size: 0.9rem;
    font-weight: 500;
    color: #ececf1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-bottom: 0.25rem;
}

.chat-item-preview {
    font-size: 0.75rem;
    color: #8e8ea0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-item-delete {
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    color: #8e8ea0;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.chat-item-delete:hover {
    background: rgba(244, 67, 54, 0.2);
    color: #f44336;
}

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 2px solid rgba(212, 175, 55, 0.2);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.user-info {
    padding: 0.75rem;
    background: rgba(212, 175, 55, 0.1);
    border-radius: 8px;
    color: #ffd700;
    font-weight: 500;
    text-align: center;
    border: 1px solid rgba(212, 175, 55, 0.3);
}

/* Calendar Status Component */
.calendar-status {
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border: 1px solid rgba(212, 175, 55, 0.2);
}

.calendar-status-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    color: #8e8ea0;
    font-size: 0.85rem;
}

.calendar-status-connected,
.calendar-status-disconnected {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.calendar-status-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
}

.calendar-status-connected .calendar-status-info {
    color: #4caf50;
}

.calendar-status-disconnected .calendar-status-info {
    color: #ff9800;
}

.calendar-connect-btn {
    width: 100%;
    padding: 0.5rem;
    background: linear-gradient(135deg, rgba(76, 175, 80, 0.2) 0%, rgba(56, 142, 60, 0.2) 100%);
    border: 1px solid rgba(76, 175, 80, 0.4);
    border-radius: 6px;
    color: #4caf50;
    font-weight: 500;
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
}

.calendar-connect-btn:hover {
    background: linear-gradient(135deg, rgba(76, 175, 80, 0.3) 0%, rgba(56, 142, 60, 0.3) 100%);
    border-color: rgba(76, 175, 80, 0.6);
    box-shadow: 0 0 10px rgba(76, 175, 80, 0.3);
}

.calendar-disconnect-btn {
    width: 100%;
    padding: 0.5rem;
    background: rgba(244, 67, 54, 0.1);
    border: 1px solid rgba(244, 67, 54, 0.3);
    border-radius: 6px;
    color: #f44336;
    font-weight: 500;
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
}

.calendar-disconnect-btn:hover {
    background: rgba(244, 67, 54, 0.2);
    border-color: rgba(244, 67, 54, 0.5);
}

.logout-btn {
    width: 100%;
    padding: 0.75rem 1rem;
    background: rgba(100, 100, 255, 0.1);
    border: 1px solid rgba(100, 100, 255, 0.3);
    border-radius: 8px;
    color: #6464ff;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
}

.logout-btn:hover {
    background: rgba(100, 100, 255, 0.2);
    border-color: rgba(100, 100, 255, 0.5);
}

.clear-all-btn {
    width: 100%;
    padding: 0.75rem 1rem;
    background: rgba(244, 67, 54, 0.1);
    border: 1px solid rgba(244, 67, 54, 0.3);
    border-radius: 8px;
    color: #f44336;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
}

.clear-all-btn:hover {
    background: rgba(244, 67, 54, 0.2);
    border-color: rgba(244, 67, 54, 0.5);
}

.empty-chat-list {
    text-align: center;
    padding: 2rem 1rem;
    color: #8e8ea0;
    font-size: 0.9rem;
}


.container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 800px;
    margin: 0 auto;
}

@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        max-width: 252px;
    }
}

.header {
    padding: 1.5rem 1.5rem 1rem;
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.15) 0%, rgba(139, 69, 19, 0.15) 100%);
    border-bottom: 2px solid #d4af37;
    text-align: center;
    backdrop-filter: blur(10px);
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.logo-container {
    position: relative;
    width: 60px;
    height: 60px;
}

.logo {
    width: 60px;
    height: 60px;
    object-fit: contain;
    filter: drop-shadow(0 0 15px rgba(93, 173, 226, 0.6)) drop-shadow(0 0 5px rgba(212, 175, 55, 0.4));
    animation: float 3s ease-in-out infinite;
}

.logo-fallback {
    width: 60px;
    height: 60px;
    font-size: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    filter: drop-shadow(0 0 10px rgba(212, 175, 55, 0.5));
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-10px);
    }
}

.header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    background: linear-gradient(135deg, #ffd700 0%, #d4af37 50%, #ffed4e 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 30px rgba(212, 175, 55, 0.5);
}

.tagline {
    font-size: 0.9rem;
    color: #d4af37;
    font-style: italic;
    opacity: 0.9;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(212, 175, 55, 0.2);
}

.username {
    font-size: 0.9rem;
    color: #ececf1;
    background: rgba(212, 175, 55, 0.1);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    border: 1px solid rgba(212, 175, 55, 0.3);
}

.logout-btn {
    padding: 0.5rem 0.75rem;
    background: rgba(244, 67, 54, 0.1);
    border: 1px solid rgba(244, 67, 54, 0.3);
    border-radius: 6px;
    color: #f44336;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.logout-btn:hover {
    background: rgba(244, 67, 54, 0.2);
    border-color: rgba(244, 67, 54, 0.5);
    transform: scale(1.05);
}

.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

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

.chat-container::-webkit-scrollbar-track {
    background: transparent;
}

.chat-container::-webkit-scrollbar-thumb {
    background: #4d4d4f;
    border-radius: 4px;
}

.chat-container::-webkit-scrollbar-thumb:hover {
    background: #5d5d5f;
}

.welcome-message {
    text-align: center;
    margin-top: 4rem;
}

.genie-lamp {
    font-size: 4rem;
    margin-bottom: 1rem;
    animation: glow 2s ease-in-out infinite;
}

@keyframes glow {
    0%, 100% {
        filter: drop-shadow(0 0 10px rgba(255, 215, 0, 0.6));
        transform: scale(1);
    }
    50% {
        filter: drop-shadow(0 0 20px rgba(255, 215, 0, 0.9));
        transform: scale(1.05);
    }
}

.welcome-message h2 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, #ffd700 0%, #d4af37 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.welcome-message p {
    font-size: 1.1rem;
    color: #c5c5d2;
}

.message {
    display: flex;
    gap: 1rem;
    padding: 1.5rem;
    border-radius: 8px;
    animation: fadeIn 0.3s ease-in;
}

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

.message.user {
    background: linear-gradient(135deg, rgba(138, 43, 226, 0.2) 0%, rgba(75, 0, 130, 0.2) 100%);
    border-right: 3px solid #9b59b6;
    flex-direction: row-reverse;
}

.message.assistant {
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.1) 0%, rgba(184, 134, 11, 0.1) 100%);
    border-left: 3px solid #d4af37;
    flex-direction: row;
}

.message-icon {
    width: 30px;
    height: 30px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.message.user .message-icon {
    background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
    box-shadow: 0 0 15px rgba(139, 92, 246, 0.5);
}

.message.assistant .message-icon {
    background: linear-gradient(135deg, #ffd700 0%, #d4af37 100%);
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.5);
}

.message-content {
    flex: 1;
    line-height: 1.6;
    word-wrap: break-word;
    white-space: pre-wrap;
}

/* RTL Support for Persian and other RTL languages */
.message-content.rtl {
    direction: rtl;
    text-align: right;
}

.message-content.rtl ul,
.message-content.rtl ol {
    padding-right: 1.5em;
    padding-left: 0;
}

.message-content.rtl blockquote {
    border-left: none;
    border-right: 3px solid #d4af37;
    padding-left: 0;
    padding-right: 1em;
}

.message-content.rtl pre {
    border-left: none;
    border-right: 3px solid #d4af37;
}

/* Markdown Styling in Messages */
.message-content h1,
.message-content h2,
.message-content h3,
.message-content h4,
.message-content h5,
.message-content h6 {
    margin: 0.5em 0 0.3em 0;
    font-weight: 600;
    color: #d4af37;
}

.message-content h1 { font-size: 1.5em; }
.message-content h2 { font-size: 1.3em; }
.message-content h3 { font-size: 1.1em; }

.message-content p {
    margin: 0.5em 0;
}

.message-content a {
    color: #60a5fa;
    text-decoration: none;
    border-bottom: 1px solid rgba(96, 165, 250, 0.3);
    transition: all 0.2s ease;
}

.message-content a:hover {
    color: #93c5fd;
    border-bottom-color: #93c5fd;
}

.message-content ul,
.message-content ol {
    margin: 0.5em 0;
    padding-left: 1.5em;
}

.message-content li {
    margin: 0.3em 0;
}

.message-content code {
    background: rgba(212, 175, 55, 0.1);
    padding: 0.2em 0.4em;
    border-radius: 3px;
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 0.9em;
    color: #d4af37;
}

.message-content pre {
    background: rgba(26, 26, 46, 0.8);
    padding: 1em;
    border-radius: 6px;
    overflow-x: auto;
    border-left: 3px solid #d4af37;
}

.message-content pre code {
    background: none;
    padding: 0;
    color: #ececf1;
}

.message-content blockquote {
    border-left: 3px solid #d4af37;
    padding-left: 1em;
    margin: 0.5em 0;
    color: rgba(236, 236, 241, 0.8);
    font-style: italic;
}

.message-content strong {
    font-weight: 600;
    color: #d4af37;
}

.message-content em {
    font-style: italic;
    color: rgba(236, 236, 241, 0.9);
}

.message-content hr {
    border: none;
    border-top: 1px solid rgba(212, 175, 55, 0.3);
    margin: 1em 0;
}

.message-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 0.5em 0;
}

.message-content th,
.message-content td {
    border: 1px solid rgba(212, 175, 55, 0.3);
    padding: 0.5em;
    text-align: left;
}

.message-content th {
    background: rgba(212, 175, 55, 0.1);
    font-weight: 600;
    color: #d4af37;
}

.typing-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    background-color: #ececf1;
    border-radius: 50%;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 0.4;
    }
    50% {
        opacity: 1;
    }
}

.tool-info {
    font-size: 0.85em;
    color: #d4af37;
    font-style: italic;
    margin: 0.25rem 0;
    padding: 0.25rem 0.5rem;
    background: rgba(212, 175, 55, 0.1);
    border-left: 2px solid #d4af37;
    border-radius: 4px;
}

.warning-message {
    font-size: 0.9em;
    color: #ff9800;
    margin: 0.5rem 0;
    padding: 0.5rem 0.75rem;
    background: rgba(255, 152, 0, 0.1);
    border-left: 3px solid #ff9800;
    border-radius: 4px;
}

.error-message {
    font-size: 0.9em;
    color: #f44336;
    margin: 0.5rem 0;
    padding: 0.5rem 0.75rem;
    background: rgba(244, 67, 54, 0.1);
    border-left: 3px solid #f44336;
    border-radius: 4px;
}

.input-container {
    padding: 1rem 1.5rem;
    background: linear-gradient(180deg, transparent 0%, rgba(26, 26, 46, 0.8) 50%);
    border-top: 2px solid rgba(212, 175, 55, 0.3);
    backdrop-filter: blur(10px);
}

.input-wrapper {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
    background: rgba(64, 65, 79, 0.5);
    border-radius: 12px;
    padding: 0.75rem;
    border: 2px solid rgba(212, 175, 55, 0.3);
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.input-wrapper:focus-within {
    border-color: #d4af37;
    box-shadow: 0 0 20px rgba(212, 175, 55, 0.3);
}

#messageInput {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: #ececf1;
    font-size: 1rem;
    font-family: inherit;
    resize: none;
    max-height: 200px;
    line-height: 1.5;
}

#messageInput::placeholder {
    color: #8e8ea0;
}

.send-button {
    background: linear-gradient(135deg, #ffd700 0%, #d4af37 100%);
    border: none;
    border-radius: 8px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    flex-shrink: 0;
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.4);
}

.send-button:hover:not(:disabled) {
    background: linear-gradient(135deg, #ffed4e 0%, #ffd700 100%);
    box-shadow: 0 0 25px rgba(212, 175, 55, 0.6);
    transform: scale(1.05);
}

.send-button:disabled {
    background: rgba(64, 65, 79, 0.5);
    cursor: not-allowed;
    opacity: 0.5;
    box-shadow: none;
}

.send-button svg {
    color: #1a1a2e;
}

.error-message {
    background-color: #f44336;
    color: white;
    padding: 1rem;
    border-radius: 8px;
    margin: 0.5rem 0;
    text-align: center;
}

.warning-message {
    background-color: #ff9800;
    color: white;
    padding: 1rem;
    border-radius: 8px;
    margin: 0.5rem 0;
    text-align: center;
}
