/* Custom styles for Life Analyzing app */

/* Loading animation */
.loading-spinner {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Message animations */
.message-enter {
    animation: slideInUp 0.3s ease-out;
}

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

/* Typing indicator animation */
.animate-bounce {
    animation: bounce 1s infinite;
}

@keyframes bounce {
    0%, 20%, 53%, 80%, 100% {
        animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000);
        transform: translate3d(0,0,0);
    }
    40%, 43% {
        animation-timing-function: cubic-bezier(0.755, 0.050, 0.855, 0.060);
        transform: translate3d(0, -8px, 0);
    }
    70% {
        animation-timing-function: cubic-bezier(0.755, 0.050, 0.855, 0.060);
        transform: translate3d(0, -4px, 0);
    }
    90% {
        transform: translate3d(0,-2px,0);
    }
}

/* Custom scrollbar */
.custom-scrollbar::-webkit-scrollbar {
    width: 6px;
}

.custom-scrollbar::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 3px;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Category Tree Styles */
.category-item {
    transition: all 0.2s ease;
}

.category-item:hover {
    transform: translateX(2px);
}

.category-item .group-hover\:opacity-100 {
    transition: opacity 0.2s ease;
}

/* Modal animations */
#category-modal {
    animation: fadeIn 0.2s ease-out;
}

#category-modal .bg-white {
    animation: slideInFromTop 0.3s ease-out;
}

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

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

/* Focus styles */
.focus-ring:focus {
    outline: none;
    ring: 2px;
    ring-color: #0ea5e9;
    ring-offset: 2px;
}

/* Button hover effects */
.btn-hover:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.2s ease;
}

/* Card hover effects */
.card-hover:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

/* Input focus effects */
.input-focus:focus {
    border-color: #0ea5e9;
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.1);
    transition: all 0.2s ease;
}

/* Status indicators */
.status-online {
    background-color: #10b981;
    animation: pulse 2s infinite;
}

.status-offline {
    background-color: #ef4444;
}

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

/* Category selection indicator */
.category-item.selected {
    background-color: rgb(240 249 255);
    border-color: rgb(191 219 254);
}

.category-item.selected .w-2.h-2 {
    background-color: rgb(14 165 233);
}

/* Loading states */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Error states */
.error {
    border-color: rgb(239 68 68);
    background-color: rgb(254 242 242);
}

/* Success states */
.success {
    border-color: rgb(34 197 94);
    background-color: rgb(240 253 244);
}

/* Calendar Styles */
.calendar-day {
    transition: all 0.2s ease;
}

.calendar-day:hover {
    background-color: rgb(249 250 251);
}

.calendar-day.today {
    background-color: rgb(240 249 255);
    border-color: rgb(191 219 254);
}

.calendar-day.has-events {
    position: relative;
}

.calendar-day.has-events::after {
    content: '';
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 6px;
    height: 6px;
    background-color: rgb(14 165 233);
    border-radius: 50%;
}

/* Event indicators */
.event-indicator {
    font-size: 10px;
    padding: 1px 4px;
    border-radius: 3px;
    margin-bottom: 1px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.event-indicator.general {
    background-color: rgb(219 234 254);
    color: rgb(30 64 175);
}

.event-indicator.work {
    background-color: rgb(220 252 231);
    color: rgb(22 101 52);
}

.event-indicator.personal {
    background-color: rgb(221 214 254);
    color: rgb(91 33 182);
}

/* Calendar navigation */
.calendar-nav-btn {
    transition: all 0.2s ease;
}

.calendar-nav-btn:hover {
    background-color: rgb(243 244 246);
    transform: scale(1.05);
}

/* Event modal */
.event-modal {
    animation: slideInFromTop 0.3s ease-out;
}

/* Month view grid */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
}

.calendar-day-cell {
    min-height: 96px;
    border: 1px solid rgb(229 231 235);
    padding: 4px;
    position: relative;
    cursor: pointer;
    transition: all 0.2s ease;
}

.calendar-day-cell:hover {
    background-color: rgb(249 250 251);
}

.calendar-day-cell.today {
    background-color: rgb(240 249 255);
    border-color: rgb(191 219 254);
}

.calendar-day-cell.other-month {
    background-color: rgb(249 250 251);
    color: rgb(156 163 175);
}

/* Event summary */
.events-summary-item {
    transition: all 0.2s ease;
}

.events-summary-item:hover {
    background-color: rgb(249 250 251);
    transform: translateX(2px);
}

/* ============================================
   MOBILE RESPONSIVE DESIGN
   ============================================ */

/* Mobile sidebar toggle button (in header) */
.mobile-sidebar-toggle {
    display: none;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background-color: #0284c7;
    color: white;
    border: none;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
    flex-shrink: 0;
}

.mobile-sidebar-toggle:hover {
    background-color: #0369a1;
}

.mobile-sidebar-toggle svg {
    width: 20px;
    height: 20px;
}

/* Mobile sidebar close button */
.mobile-sidebar-close {
    display: none;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background-color: #f3f4f6;
    color: #374151;
    border: none;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
}

.mobile-sidebar-close:hover {
    background-color: #e5e7eb;
}

.mobile-sidebar-close svg {
    width: 20px;
    height: 20px;
}

/* Mobile overlay for sidebar */
.mobile-sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 45;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mobile-sidebar-overlay.active {
    opacity: 1;
}

@media (max-width: 768px) {
    /* Show mobile toggle button and close button */
    .mobile-sidebar-toggle,
    .mobile-sidebar-close {
        display: flex;
    }

    /* Chat page layout */
    #chat-page {
        flex-direction: column;
    }

    #chat-page > main {
        flex: 1;
        height: calc(100vh - 56px);
    }

    /* Hide left sidebar (dialogs) by default on mobile */
    .mobile-dialogs-sidebar {
        position: fixed;
        top: 0;
        left: -100%;
        width: 85%;
        max-width: 280px;
        height: 100vh;
        z-index: 50;
        transition: left 0.3s ease;
        box-shadow: 4px 0 12px rgba(0, 0, 0, 0.15);
    }

    .mobile-dialogs-sidebar.mobile-open {
        left: 0;
    }

    /* Hide right sidebar (categories) by default on mobile */
    .mobile-categories-sidebar {
        position: fixed;
        top: 0;
        right: -100%;
        width: 85%;
        max-width: 320px;
        height: 100vh;
        z-index: 50;
        transition: right 0.3s ease;
        box-shadow: -4px 0 12px rgba(0, 0, 0, 0.15);
    }

    .mobile-categories-sidebar.mobile-open {
        right: 0;
    }

    /* Show overlay when sidebar is open */
    .mobile-sidebar-overlay.active {
        display: block;
    }

    /* Chat input area - make it more mobile friendly */
    #chat-page .bg-white.border-t {
        padding: 12px;
    }

    #chat-page .bg-white.border-t .flex {
        flex-wrap: wrap;
        gap: 8px;
    }

    #chat-page #message-input {
        flex: 1;
        min-width: 0;
        font-size: 16px; /* Prevents iOS zoom on focus */
    }

    #chat-page #send-btn {
        padding: 8px 16px;
        font-size: 14px;
    }

    #chat-page #voice-btn {
        padding: 8px 12px;
    }

    /* Messages container */
    #messages-container {
        padding: 12px;
    }

    #messages-container .max-w-md,
    #messages-container .max-w-xs {
        max-width: 85%;
    }

    /* Chat header */
    #chat-page .bg-white.border-b {
        padding: 12px;
    }

    #current-category-title {
        font-size: 14px;
    }

    /* Calendar page layout */
    #calendar-page {
        flex-direction: column;
    }

    #calendar-page > main {
        flex: 1;
        height: auto;
        min-height: 60vh;
    }

    #calendar-page > aside {
        width: 100%;
        max-height: 40vh;
        border-left: none;
        border-top: 1px solid rgb(229 231 235);
    }

    /* Calendar grid */
    .calendar-day-cell {
        min-height: 60px;
        padding: 2px;
        font-size: 12px;
    }

    /* Onboarding page */
    #onboarding-page > div {
        margin: 16px;
        padding: 24px 16px;
    }

    #onboarding-category-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    #onboarding-page h1 {
        font-size: 24px;
    }

    #onboarding-page p {
        font-size: 14px;
    }

    /* Auth pages */
    #auth-page > div,
    #forgot-password-page > div,
    #reset-password-page > div {
        margin: 16px;
        padding: 24px 16px;
    }

    /* Modals */
    #category-modal .bg-white,
    #custom-category-modal .bg-white {
        margin: 16px;
        max-height: 90vh;
        overflow-y: auto;
    }

    /* Navbar */
    #navbar .max-w-7xl {
        padding-left: 12px;
        padding-right: 12px;
    }

    #navbar .flex.space-x-4 {
        display: none;
    }

    #user-email {
        display: none;
    }

    /* Mobile utility classes */
    .mobile-hidden {
        display: none !important;
    }

    .mobile-full {
        width: 100% !important;
    }

    /* Mobile category tree */
    .category-item {
        padding: 12px;
    }

    .category-item .group-hover\:opacity-100 {
        opacity: 1 !important;
    }

    /* Hide voice status text on very small screens */
    #voice-status {
        display: none;
    }

    /* Model selector on mobile */
    #model-selector {
        flex-wrap: wrap;
    }

    #model-input {
        width: 100px;
    }
}

/* Small mobile screens */
@media (max-width: 480px) {
    #onboarding-category-grid {
        grid-template-columns: 1fr;
    }

    #chat-page #send-btn span {
        display: none;
    }

    #chat-page #send-btn::after {
        content: '→';
        font-size: 18px;
    }

    #chat-page #send-btn {
        padding: 8px 12px;
    }

    /* Make voice button and send button same row */
    #chat-page .bg-white.border-t .flex {
        display: grid;
        grid-template-columns: auto 1fr auto;
        gap: 8px;
    }

    #chat-page .flex.items-center.space-x-2 {
        order: 1;
    }

    #chat-page #message-input {
        order: 2;
    }

    #chat-page #send-btn {
        order: 3;
    }
}

/* Drag and Drop styles for categories */
.category-item {
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.category-item.dragging {
    opacity: 0.4;
}

.category-item.drag-over-top {
    border-top: 3px solid #3b82f6;
    margin-top: -3px;
}

.category-item.drag-over-bottom {
    border-bottom: 3px solid #3b82f6;
    margin-bottom: -3px;
}

.category-content {
    user-select: none;
}

.drag-handle {
    opacity: 0.3;
    transition: opacity 0.2s ease;
}

.category-item:hover .drag-handle {
    opacity: 0.6;
}

.drag-handle:hover {
    opacity: 1 !important;
}

.drag-handle:active {
    cursor: grabbing;
}

/* Dark mode support (optional) */
@media (prefers-color-scheme: dark) {
    .dark-mode {
        background-color: #1f2937;
        color: #f9fafb;
    }
}

/* Print styles */
@media print {
    .no-print {
        display: none !important;
    }
}

/* Chat header styles */
#current-category-title {
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
    max-width: 100%;
    line-height: 1.5;
}

#chat-header-actions {
    min-width: fit-content;
}
