* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background: linear-gradient(135deg, #1a1c2c 0%, #4a4e69 100%);
    min-height: 100vh;
    color: #fff;
}

nav {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    color: white;
    padding: 1.2rem;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 1001;
}

nav h1 {
    font-size: 2.2rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    font-weight: 800;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.container {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.section-title {
    text-align: center;
    font-size: 1.8rem;
    margin-bottom: 1rem;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.tools-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.tool-section {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 2rem;
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
    transition: transform 0.3s ease;
}

.tool-section:hover {
    transform: translateY(-5px);
}

.tool-section h2 {
    color: #fff;
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.chat-messages {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    height: 400px;
    overflow-y: auto;
}

.message {
    margin: 1rem;
    padding: 1rem;
    border-radius: 10px;
}

.user-message {
    background: #4a90e2;
    color: white;
    margin-left: 20%;
}

.bot-message {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    margin-right: 20%;
}

.chat-input {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

.chat-input input {
    flex: 1;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 0.8rem;
    border-radius: 5px;
}

.chat-input input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

button, .upload-btn, .remove-bg-btn {
    background: #4a90e2;
    color: white;
    border: none;
    border-radius: 5px;
    padding: 0.8rem 1.2rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

button:hover, .upload-btn:hover, .remove-bg-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(74, 144, 226, 0.5);
}

.image-preview {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin: 1rem 0;
}

.image-preview img {
    max-width: 100%;
    border-radius: 5px;
    display: none;
}

.upload-container {
    text-align: center;
}

.divider {
    height: 2px;
    background: rgba(255, 255, 255, 0.1);
    margin: 2rem 0;
}

@media (max-width: 768px) {
    nav h1 {
        font-size: 1.6rem;
    }

    .container {
        margin: 1rem auto;
        padding: 0 0.8rem;
    }

    .section-title {
        font-size: 1.4rem;
        margin-bottom: 0.8rem;
    }

    .tools-container {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .tool-section {
        padding: 1rem;
        border-radius: 15px;
    }

    .tool-section h2 {
        font-size: 1.2rem;
        margin-bottom: 1rem;
    }

    .chat-messages {
        height: 350px;
    }

    .message {
        margin: 0.8rem;
        padding: 0.8rem;
        font-size: 0.95rem;
    }

    .user-message {
        margin-left: 10%;
        margin-right: 0.5rem;
    }

    .bot-message {
        margin-right: 10%;
        margin-left: 0.5rem;
    }

    .chat-input {
        gap: 0.5rem;
    }

    .chat-input input {
        padding: 0.6rem;
        font-size: 0.95rem;
    }

    button, .upload-btn, .remove-bg-btn {
        padding: 0.6rem 1rem;
        font-size: 0.95rem;
    }

    .image-preview {
        grid-template-columns: 1fr;
        gap: 0.8rem;
        margin: 0.8rem 0;
    }

    .divider {
        margin: 1.5rem 0;
    }
}

@media (max-width: 480px) {
    nav h1 {
        font-size: 1.4rem;
    }

    .container {
        padding: 0 0.5rem;
    }

    .section-title {
        font-size: 1.2rem;
    }

    .tool-section {
        padding: 0.8rem;
    }

    .message {
        margin: 0.6rem;
        padding: 0.6rem;
        font-size: 0.9rem;
    }

    .user-message {
        margin-left: 5%;
    }

    .bot-message {
        margin-right: 5%;
    }

    .chat-input input {
        padding: 0.5rem;
    }

    button, .upload-btn, .remove-bg-btn {
        padding: 0.5rem 0.8rem;
        font-size: 0.9rem;
    }
}

/* Add touch-friendly improvements */
@media (hover: none) {
    button, .upload-btn, .remove-bg-btn {
        -webkit-tap-highlight-color: transparent;
    }

    .tool-section:hover {
        transform: none;
    }

    .chat-input input:focus {
        font-size: 16px; /* Prevents zoom on iOS */
    }
}

/* Improve scrolling on mobile */
.chat-messages {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

/* Prevent text scaling */
html {
    -webkit-text-size-adjust: 100%;
}

/* Improve button touch targets */
button, 
.upload-btn, 
.remove-bg-btn {
    min-height: 44px;
    min-width: 44px;
}

/* Add safe area insets for modern mobile devices */
@supports (padding: max(0px)) {
    .container {
        padding-left: max(0.8rem, env(safe-area-inset-left));
        padding-right: max(0.8rem, env(safe-area-inset-right));
    }

    nav {
        padding-top: max(1.2rem, env(safe-area-inset-top));
    }
}

/* Add these new styles while keeping existing ones */

.app-layout {
    display: flex;
    min-height: 100vh;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    padding: 0.5rem;
    cursor: pointer;
}

.sidebar {
    width: 300px;
    background: rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(10px);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    height: calc(100vh - 60px);
    position: sticky;
    top: 60px;
}

.profile-section {
    text-align: center;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.profile-pic {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    margin-bottom: 1rem;
}

.profile-info h3 {
    color: white;
    font-size: 1.2rem;
}

.new-chat-btn {
    background: #4a90e2;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 0.8rem;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.chat-history {
    flex: 1;
    overflow-y: auto;
}

.chat-history h4 {
    color: white;
    margin-bottom: 1rem;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.history-item {
    padding: 0.8rem;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.history-item:hover {
    background: rgba(255, 255, 255, 0.2);
}

.main-content {
    flex: 1;
    padding-top: 1rem;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .menu-toggle {
        display: block;
    }

    .sidebar {
        position: fixed;
        left: -300px;
        top: 60px;
        z-index: 1000;
        transition: left 0.3s ease;
    }

    .sidebar.active {
        left: 0;
    }

    .main-content {
        margin-left: 0;
    }
}

/* Add these new styles */
.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.clear-history-btn {
    background: rgba(255, 0, 0, 0.2);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.clear-history-btn:hover {
    background: rgba(255, 0, 0, 0.3);
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.8rem;
}

.history-item-content {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
}

.delete-chat-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    padding: 0.2rem;
    visibility: hidden;
    transition: all 0.3s ease;
}

.history-item:hover .delete-chat-btn {
    visibility: visible;
}

.delete-chat-btn:hover {
    color: rgba(255, 0, 0, 0.8);
}

/* Add these new styles */
.username-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.edit-name-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    padding: 0.2rem;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.edit-name-btn:hover {
    color: #4a90e2;
}

.edit-name-container {
    margin-top: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    animation: fadeIn 0.3s ease;
}

.edit-name-container input {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    padding: 0.5rem;
    color: white;
    text-align: center;
    font-size: 0.9rem;
}

.edit-name-container input:focus {
    outline: none;
    border-color: #4a90e2;
}

.edit-name-buttons {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
}

.edit-name-buttons button {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 4px;
    padding: 0.4rem 0.8rem;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
}

.edit-name-buttons button:first-child {
    background: rgba(74, 144, 226, 0.3);
}

.edit-name-buttons button:last-child {
    background: rgba(255, 0, 0, 0.2);
}

.edit-name-buttons button:hover {
    transform: scale(1.05);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Add/Update these mobile-specific styles */

/* Base mobile adjustments */
@media (max-width: 768px) {
    .app-layout {
        position: relative;
        overflow-x: hidden;
    }

    .sidebar {
        position: fixed;
        left: -100%;
        width: 85%;
        max-width: 300px;
        z-index: 1000;
        transition: left 0.3s ease;
        height: calc(100% - 60px);
    }

    .sidebar.active {
        left: 0;
        box-shadow: 0 0 15px rgba(0, 0, 0, 0.5);
    }

    .main-content {
        width: 100%;
        padding: 0.5rem;
    }

    /* Improved nav for mobile */
    nav {
        padding: 0.8rem;
    }

    nav h1 {
        font-size: 1.4rem;
    }

    .menu-toggle {
        padding: 0.5rem;
        font-size: 1.2rem;
    }

    /* Chat container adjustments */
    .chat-container {
        height: calc(100vh - 180px);
    }

    .chat-messages {
        height: calc(100% - 60px);
    }

    .message {
        max-width: 90%;
        padding: 0.8rem;
        margin: 0.5rem;
        font-size: 0.95rem;
    }

    /* Input adjustments */
    .chat-input {
        padding: 0.5rem;
    }

    .chat-input input {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 0.8rem;
    }

    /* Profile section adjustments */
    .profile-section {
        padding: 1rem;
    }

    .profile-pic {
        width: 60px;
        height: 60px;
    }

    /* History items adjustments */
    .history-item {
        padding: 0.8rem;
        font-size: 0.9rem;
    }

    /* Background remover section */
    .image-preview {
        grid-template-columns: 1fr;
    }

    .upload-btn, .remove-bg-btn {
        width: 100%;
        padding: 0.8rem;
        margin: 0.5rem 0;
    }
}

/* Small mobile devices */
@media (max-width: 480px) {
    .sidebar {
        width: 95%;
    }

    nav h1 {
        font-size: 1.2rem;
    }

    .message {
        max-width: 95%;
        font-size: 0.9rem;
    }

    .edit-name-container input {
        font-size: 16px;
        padding: 0.8rem;
    }
}

/* Handle landscape mode */
@media (max-height: 500px) and (orientation: landscape) {
    .sidebar {
        height: calc(100% - 50px);
        padding: 0.8rem;
    }

    .profile-section {
        padding: 0.5rem;
    }

    .chat-container {
        height: calc(100vh - 120px);
    }

    .profile-pic {
        width: 40px;
        height: 40px;
    }
}

/* Touch device optimizations */
@media (hover: none) {
    .history-item .delete-chat-btn {
        visibility: visible;
        opacity: 0.7;
    }

    .edit-name-btn {
        opacity: 0.7;
    }

    button, .upload-btn, .remove-bg-btn {
        -webkit-tap-highlight-color: transparent;
    }
}

/* Add backdrop for mobile menu */
.menu-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.menu-backdrop.active {
    display: block;
    opacity: 1;
}

/* Safe area insets for modern devices */
@supports (padding: max(0px)) {
    .sidebar {
        padding-left: max(1.5rem, env(safe-area-inset-left));
        padding-right: max(1.5rem, env(safe-area-inset-right));
        padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
    }

    nav {
        padding-top: max(0.8rem, env(safe-area-inset-top));
    }
}