/* Modern Gemini Chat Interface Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Light theme colors */
    --primary-color: #4285f4;
    --primary-hover: #3367d6;
    --secondary-color: #34a853;
    --accent-color: #ea4335;
    --background-color: #f8f9fa;
    --surface-color: #ffffff;
    --surface-hover: #f1f3f4;
    --text-primary: #202124;
    --text-secondary: #5f6368;
    --border-color: #dadce0;
    --shadow: 0 1px 3px rgba(60,64,67,0.3);
    --shadow-hover: 0 4px 8px rgba(60,64,67,0.3);
    --border-radius: 8px;
    --font-family: 'Google Sans', 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

[data-theme="dark"] {
    /* Dark theme colors */
    --primary-color: #8ab4f8;
    --primary-hover: #669df6;
    --secondary-color: #81c995;
    --accent-color: #f28b82;
    --background-color: #202124;
    --surface-color: #303134;
    --surface-hover: #3c4043;
    --text-primary: #e8eaed;
    --text-secondary: #9aa0a6;
    --border-color: #5f6368;
}

body {
    background: var(--background-color);
    color: var(--text-primary);
    font-family: var(--font-family);
    line-height: 1.6;
    transition: all 0.3s ease;
    font-size: 14px;
}

body.dark {
    --primary-color: #8ab4f8;
    --primary-hover: #669df6;
    --secondary-color: #81c995;
    --accent-color: #f28b82;
    --background-color: #202124;
    --surface-color: #303134;
    --surface-hover: #3c4043;
    --text-primary: #e8eaed;
    --text-secondary: #9aa0a6;
    --border-color: #5f6368;
}

.container {
    max-width: 900px;
    margin: 16px auto;
    height: calc(100vh - 32px);
    display: flex;
    flex-direction: column;
    background: var(--surface-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: all 0.3s ease;
}

/* Header */
.header {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    color: white;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.header h1 {
    font-size: 20px;
    font-weight: 500;
    letter-spacing: -0.5px;
}

.header-buttons {
    display: flex;
    gap: 8px;
}

.theme-toggle-btn,
.clear-btn,
.show-key-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    padding: 8px 12px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
    font-weight: 500;
    backdrop-filter: blur(10px);
}

.theme-toggle-btn:hover,
.clear-btn:hover,
.show-key-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

/* API Key Section */
.api-area {
    display: flex;
    gap: 12px;
    padding: 16px 20px;
    background: var(--surface-color);
    border-bottom: 1px solid var(--border-color);
    align-items: center;
}

.api-area input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 14px;
    background: var(--surface-color);
    color: var(--text-primary);
    transition: all 0.3s ease;
    font-family: var(--font-family);
}

.api-area input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(66, 133, 244, 0.1);
}

.api-area button {
    padding: 12px 20px;
    background: var(--secondary-color);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
}

.api-area button:hover {
    background: #2d8f47;
    transform: translateY(-1px);
    box-shadow: var(--shadow-hover);
}

/* Persona Selection */
.persona-area {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: linear-gradient(135deg, var(--surface-color), var(--surface-hover));
    border-bottom: 1px solid var(--border-color);
}

.persona-area label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    min-width: 140px;
}

.persona-area select {
    flex: 1;
    max-width: 300px;
    padding: 10px 12px;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 14px;
    font-weight: 500;
    background: var(--surface-color);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.3s ease;
}

.persona-area select:hover {
    border-color: var(--primary-color);
}

.persona-area select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(66, 133, 244, 0.1);
}

/* Custom Prompt Area */
.custom-prompt-area {
    padding: 20px;
    background: linear-gradient(135deg, #fff8e1, #f3e5f5);
    border-bottom: 1px solid var(--border-color);
    border-left: 4px solid var(--primary-color);
    animation: slideDown 0.3s ease-out;
}

body.dark .custom-prompt-area {
    background: linear-gradient(135deg, #2a2a2a, #333333);
}

.custom-prompt-area label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.custom-prompt-area textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 14px;
    font-family: var(--font-family);
    resize: vertical;
    min-height: 100px;
    max-height: 200px;
    transition: all 0.3s ease;
    background: var(--surface-color);
    color: var(--text-primary);
    line-height: 1.5;
}

.custom-prompt-area textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(66, 133, 244, 0.1);
}

.apply-prompt-btn {
    margin-top: 12px;
    padding: 10px 20px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
}

.apply-prompt-btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-hover);
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
        max-height: 0;
    }
    to {
        opacity: 1;
        transform: translateY(0);
        max-height: 300px;
    }
}

/* Chat Area */
.chat {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: var(--background-color);
    scroll-behavior: smooth;
}

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

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

.chat::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.chat::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Chat Bubbles */
.bubble {
    position: relative;
    max-width: 85%;
    margin-bottom: 16px;
    animation: fadeIn 0.3s ease-in;
}

.bubble.user {
    margin-left: auto;
}

.bubble.ai {
    margin-right: auto;
}

.content {
    padding: 16px 20px;
    border-radius: 18px;
    box-shadow: var(--shadow);
    position: relative;
    transition: all 0.3s ease;
}

.bubble.user .content {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    color: white;
    border-bottom-right-radius: 6px;
}

.bubble.ai .content {
    background: var(--surface-color);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 6px;
}

.meta {
    font-size: 11px;
    opacity: 0.7;
    margin-bottom: 6px;
    font-weight: 500;
}

.bubble.user .meta {
    text-align: right;
}

.copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    cursor: pointer;
    opacity: 0;
    transition: all 0.3s ease;
}

.bubble:hover .copy-btn {
    opacity: 1;
}

.copy-btn:hover {
    background: rgba(0, 0, 0, 0.2);
    transform: scale(1.1);
}

.token {
    font-size: 11px;
    opacity: 0.6;
    margin-top: 8px;
    text-align: right;
    font-weight: 500;
}

/* Code Blocks */
.code-block {
    background: #1e1e1e;
    border-radius: var(--border-radius);
    margin: 12px 0;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.code-header {
    background: #2d2d2d;
    color: #ccc;
    font-size: 12px;
    padding: 8px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 500;
}

.code-content {
    padding: 16px;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    font-size: 13px;
    color: #e6e6e6;
    overflow-x: auto;
    line-height: 1.4;
}

/* Form Section */
.form {
    padding: 20px;
    background: var(--surface-color);
    border-top: 1px solid var(--border-color);
}

.form-row {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
    align-items: flex-start;
}

.form-row select {
    flex: 0 0 140px;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 14px;
    background: var(--surface-color);
    color: var(--text-primary);
    transition: all 0.3s ease;
    cursor: pointer;
}

.form-row select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(66, 133, 244, 0.1);
}

.input-container {
    position: relative;
    flex: 1;
}

.form-row textarea {
    width: 100%;
    padding: 12px 45px 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 14px;
    resize: vertical;
    min-height: 48px;
    max-height: 200px;
    background: var(--surface-color);
    color: var(--text-primary);
    transition: all 0.3s ease;
    font-family: var(--font-family);
    line-height: 1.4;
}

.form-row textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(66, 133, 244, 0.1);
}

.image-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--surface-hover);
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 16px;
    user-select: none;
}

.image-icon:hover {
    background: var(--border-color);
    transform: translateY(-50%) scale(1.1);
}

.controls {
    display: flex;
    gap: 12px;
    align-items: center;
}

.send-btn {
    flex: 1;
    padding: 12px 24px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
}

.send-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: var(--shadow-hover);
}

.send-btn:disabled {
    background: var(--border-color);
    transform: none;
    box-shadow: none;
    cursor: not-allowed;
    opacity: 0.6;
}

/* Image Preview */
.image-preview {
    text-align: center;
    margin-top: 12px;
}

.image-preview img {
    max-width: 200px;
    max-height: 200px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    object-fit: cover;
}

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

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        margin: 8px;
        height: calc(100vh - 16px);
        border-radius: 0;
    }

    .header {
        flex-direction: column;
        gap: 8px;
        padding: 12px 16px;
    }

    .header h1 {
        font-size: 18px;
    }

    .header-buttons {
        flex-direction: row;
        gap: 6px;
        justify-content: center;
    }

    .bubble {
        max-width: 95%;
    }

    .form-row {
        flex-direction: column;
        gap: 8px;
    }

    .form-row select {
        flex: none;
        width: 100%;
    }

    .controls {
        flex-direction: column;
    }

    .controls .send-btn {
        width: 100%;
    }

    .persona-area {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .persona-area label {
        min-width: auto;
    }

    .persona-area select {
        max-width: none;
    }

    .custom-prompt-area {
        padding: 16px;
    }

    .api-area {
        flex-direction: column;
        gap: 8px;
    }

    .api-area input,
    .api-area button {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 16px;
    }

    .chat {
        padding: 12px;
    }

    .content {
        padding: 12px 16px;
    }

    .form {
        padding: 16px;
    }

    .bubble {
        margin-bottom: 12px;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --border-color: #000000;
        --text-secondary: #000000;
    }

    body.dark {
        --border-color: #ffffff;
        --text-secondary: #ffffff;
    }
}

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