* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
    background-color: #ffffff;
    color: #202123;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    display: flex;
    height: 100vh;
}

/* Sidebar Styles */
.sidebar {
    width: 260px;
    background-color: #f9f9f9;
    border-right: 1px solid #e5e5e5;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    transition: transform 0.3s ease;
    z-index: 1000;
}

/* Mobile sidebar toggle using checkbox */
#sidebar-toggle {
    display: none;
}

#sidebar-toggle:checked ~ .container .sidebar {
    transform: translateX(0);
}

#sidebar-toggle:checked ~ .sidebar-overlay {
    display: block;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100vh;
        transform: translateX(-100%);
        box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
    }
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid #e5e5e5;
}

.logo {
    display: flex;
    align-items: center;
    color: #202123;
}

.toggle-btn {
    color: #8e8e8e;
    cursor: pointer;
    display: none;
}

@media (max-width: 768px) {
    .toggle-btn {
        display: block;
    }
}

.sidebar-nav {
    padding: 8px;
    border-bottom: 1px solid #e5e5e5;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    color: #202123;
    text-decoration: none;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 2px;
    transition: background-color 0.2s;
}

.nav-item.active {
    background-color: #ececec;
}

.nav-item:hover {
    background-color: #ececec;
}

.nav-item svg {
    color: #8e8e8e;
}

.chat-section {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.chat-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    font-size: 12px;
    color: #8e8e8e;
    font-weight: 500;
    cursor: pointer;
}

.chat-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.chat-item {
    padding: 10px 12px;
    font-size: 14px;
    color: #202123;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    justify-content: space-between;
    text-decoration: none;
}

.chat-item:hover {
    background-color: #ececec;
}

.chat-menu {
    background: none;
    border: none;
    color: #8e8e8e;
    cursor: pointer;
    font-size: 18px;
    opacity: 0;
    transition: opacity 0.2s;
}

.chat-item:hover .chat-menu {
    opacity: 1;
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid #e5e5e5;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
    font-weight: 600;
}

.user-info {
    display: flex;
    flex-direction: column;
}

.username {
    font-size: 13px;
    font-weight: 500;
    color: #202123;
}

.plan {
    font-size: 11px;
    color: #8e8e8e;
}

.upgrade-btn-footer {
    padding: 6px 12px;
    background-color: #202123;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.upgrade-btn-footer:hover {
    background-color: #000000;
}

/* Main Content Styles */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: #ffffff;
}

.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    border-bottom: 1px solid #e5e5e5;
}

.toggle-sidebar {
    background: none;
    border: none;
    color: #8e8e8e;
    cursor: pointer;
    padding: 4px;
    display: none;
    align-items: center;
}

@media (max-width: 768px) {
    .toggle-sidebar {
        display: flex;
    }
}

.model-selector {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 16px;
    font-weight: 500;
    color: #202123;
    cursor: pointer;
}

.upgrade-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background-color: #f4f0ff;
    color: #8B5CF6;
    border: none;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
}

.upgrade-btn:hover {
    background-color: #ede5ff;
}

.star-btn {
    background: none;
    border: none;
    color: #8e8e8e;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
}

.star-btn:hover {
    color: #202123;
}

.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow-y: auto;
    padding: 40px 20px;
}

.welcome-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    text-align: center;
}

.welcome-section h1 {
    font-size: 32px;
    font-weight: 600;
    color: #202123;
    text-align: center;
    margin-bottom: 0;
}

.input-container {
    position: relative;
    width: 100%;
    max-width: 768px;
    padding: 0;
    display: flex;
    justify-content: center;
}

.input-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background-color: #f4f4f4;
    border: 1px solid #d1d1d1;
    border-radius: 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    width: 100%;
    transition: box-shadow 0.2s, border-color 0.2s;
}

.input-wrapper:focus-within {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    border-color: #b4b4b4;
}

.add-btn,
.voice-btn,
.settings-btn {
    background: none;
    border: none;
    color: #8e8e8e;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    transition: color 0.2s;
}

.add-btn:hover,
.voice-btn:hover,
.settings-btn:hover {
    color: #202123;
}

.chat-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 16px;
    color: #202123;
    background: transparent;
    font-weight: 400;
}

.chat-input::placeholder {
    color: #8e8e8e;
}

/* Scrollbar Styles */
.sidebar::-webkit-scrollbar,
.chat-section::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track,
.chat-section::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb,
.chat-section::-webkit-scrollbar-thumb {
    background: #d1d1d1;
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover,
.chat-section::-webkit-scrollbar-thumb:hover {
    background: #b1b1b1;
}

/* Search Modal Styles */
.search-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    max-width: 700px;
    width: 90%;
    max-height: 600px;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translate(-50%, -48%);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

.search-modal-content {
    position: relative;
    padding: 20px;
}

.search-input {
    width: 100%;
    padding: 16px 50px 16px 20px;
    font-size: 16px;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    outline: none;
    margin-bottom: 16px;
}

.close-search {
    position: absolute;
    top: 28px;
    right: 32px;
    background: none;
    border: none;
    font-size: 28px;
    color: #8e8e8e;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-search:hover {
    color: #202123;
}

.search-results {
    max-height: 450px;
    overflow-y: auto;
}

.search-result-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: none;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    color: #202123;
    cursor: pointer;
    text-align: left;
    transition: background-color 0.2s;
}

.search-result-item:hover {
    background-color: #f5f5f5;
}

.search-section-title {
    font-size: 12px;
    color: #8e8e8e;
    font-weight: 500;
    padding: 12px 16px 8px;
    margin-top: 8px;
}

/* Library View Styles */
.library-view {
    padding: 40px;
    max-width: 1200px;
    margin: 0 auto;
}

.library-title {
    font-size: 24px;
    font-weight: 500;
    color: #202123;
    margin-bottom: 24px;
    padding-bottom: 12px;
    border-bottom: 2px solid #202123;
    display: inline-block;
}

.library-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
}

.library-item {
    aspect-ratio: 1;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
}

.library-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.library-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: bold;
    color: white;
}

/* Chat Content Styles */
.chat-content {
    flex: 1;
    overflow-y: auto;
    padding: 40px 20px;
    max-width: 768px;
    margin: 0 auto;
    width: 100%;
}

.chat-message {
    margin-bottom: 24px;
    padding: 16px;
    border-radius: 8px;
}

.chat-message.user {
    background-color: #f7f7f7;
    text-align: right;
}

.chat-message.assistant {
    background-color: #ffffff;
}

/* Mobile Responsive */
@media (max-width: 1024px) {
    .container {
        flex-direction: column;
    }
    
    .main-content {
        width: 100%;
    }
}

@media (max-width: 768px) {
    body {
        overflow-x: hidden;
    }

    .header {
        padding: 12px 16px;
        gap: 8px;
        flex-wrap: wrap;
    }

    .model-selector {
        font-size: 14px;
        flex: 1;
    }

    .upgrade-btn {
        padding: 6px 12px;
    }

    .upgrade-btn span {
        display: none;
    }

    .upgrade-btn svg {
        margin: 0;
    }

    .star-btn {
        padding: 6px;
    }

    .welcome-section h1 {
        font-size: 24px;
        padding: 0 16px;
    }

    .input-container {
        padding: 0 16px;
    }

    .input-wrapper {
        padding: 10px 12px;
    }

    .chat-section {
        font-size: 13px;
    }

    .sidebar-footer {
        padding: 10px;
    }

    .username {
        font-size: 12px;
    }

    .plan {
        font-size: 10px;
    }

    .upgrade-btn-footer {
        padding: 5px 10px;
        font-size: 11px;
    }

    .chat-area {
        padding: 20px 16px 100px 16px;
    }

    .library-view {
        padding: 20px 16px;
    }

    .library-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 12px;
    }

    .search-modal {
        width: 95%;
        max-height: 80vh;
    }
}

@media (max-width: 480px) {
    .header {
        padding: 10px 12px;
    }

    .model-selector {
        font-size: 13px;
    }

    .star-btn {
        display: none;
    }

    .upgrade-btn {
        padding: 4px 8px;
        font-size: 11px;
    }

    .welcome-section h1 {
        font-size: 20px;
    }

    .input-container {
        padding: 12px;
    }

    .input-wrapper {
        padding: 8px 10px;
        gap: 6px;
    }

    .chat-input {
        font-size: 14px;
    }

    .add-btn svg,
    .voice-btn svg,
    .settings-btn svg {
        width: 18px;
        height: 18px;
    }

    .sidebar {
        width: 280px;
    }

    .nav-item {
        font-size: 13px;
        padding: 9px 10px;
    }

    .chat-item {
        font-size: 13px;
        padding: 9px 10px;
    }

    .library-grid {
        grid-template-columns: 1fr;
    }

    .chat-area {
        padding: 16px 12px 100px 12px;
    }
}
