/* Import Inter font */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* Force Inter everywhere */
*, *::before, *::after {
    font-family: 'Inter', sans-serif;
}

/* Force Inter on form elements */
input, 
button, 
textarea, 
select {
    font-family: 'Inter', sans-serif;
}

:root {
    /* Light theme */
    --primary-color-light: #4caf50;
    --background-light: #ffffff;
    --text-dark: #333333;
    --card-background-light: #f5f5f5;
    --hover-color-light: #45a049;
    --tab-background-light: #ddd;
    --tab-hover-light: #ccc;
    --tab-active-light: #bbb;
    --border-color-light: #ccc;

    /* Dark theme */
    --primary-color-dark: #9370db;
    --background-dark: #121212;
    --text-light: #e0e0e0;
    --card-background-dark: #2d2d2d;
    --hover-color-dark: #7b68ee;
    --tab-background-dark: #333;
    --tab-hover-dark: #444;
    --tab-active-dark: #555;
    --border-color-dark: #444;

    /* Initialize variables */
    --primary-color: var(--primary-color-dark);
    --background: var(--background-dark);
    --text-color: var(--text-light);
    --card-background: var(--card-background-dark);
    --hover-color: var(--hover-color-dark);
    --tab-background: var(--tab-background-dark);
    --tab-hover: var(--tab-hover-dark);
    --tab-active: var(--tab-active-dark);
    --border-color: var(--border-color-dark);
}

/* Base Layout */
body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', sans-serif;
    background-color: var(--background);
    color: var(--text-color);
    transition: all 0.3s ease;
}

.container {
    display: flex;
    min-height: 100vh;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    box-sizing: border-box;
    overflow-y: auto;
}

/* Tabs */
.tabs {
    width: 200px;
    padding-right: 20px;
}

.tab-button {
    width: 100%;
    padding: 10px;
    margin-bottom: 10px;
    background: var(--card-background);
    border: none;
    border-radius: 5px;
    color: var(--text-color);
    cursor: pointer;
    text-align: left;
}

.tab-button:hover {
    background: var(--tab-hover);
}

.tab-button.active {
    background: var(--tab-active);
    border-left: 3px solid var(--primary-color);
}

/* Main content area */
.tab-content-container {
    flex: 1;
    overflow: hidden;
    position: relative;
}

.tab-content {
    height: 100%;
    display: none;
}

.tab-content.active {
    display: block;
}

/* API Key Container */
#api-key-container {
    margin-bottom: 20px;
    padding: 15px;
    background: var(--card-background);
    border-radius: 5px;
}

#api-presets {
    margin: 0;
}

.model-presets,
.chat-presets {
    display: none;
}

.api-key-input {
    width: calc(100% - 20px);
    padding: 8px;
    margin: 5px 0;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--background);
    color: var(--text-color);
}

.button-group {
    display: flex;
    gap: 10px;
    margin: 10px 0;
    flex-wrap: wrap;
}

.button {
    padding: 8px 15px;
    background: var(--primary-color);
    border: none;
    border-radius: 4px;
    color: white;
    cursor: pointer;
    white-space: nowrap;
}

.button:hover {
    background: var(--hover-color);
}

/* Chat Interface */
#chat-interface {
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: 400px;
}

#chat-messages {
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    padding: 20px;
}

#chat-form {
    display: flex;
    gap: 10px;
    padding: 10px;
    background: var(--background);
    width: calc(100% - 20px);
    position: relative;
    bottom: 0;
}

#chat-input {
    flex: 1;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--background);
    color: var(--text-color);
}

/* Messages */
.message {
    padding: 6px 10px;
    margin: 2px 0;
    border-radius: 12px;
    max-width: 80%;
    display: inline-block;
}

.message-content {
    margin: 0;
    padding: 0;
    line-height: 1.2;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.message-content p {
    margin: 0;
    padding: 0;
}

.user-message {
    background: var(--primary-color);
    color: white;
    align-self: flex-end;
    margin-left: auto;
    border-bottom-right-radius: 4px;
}

.bot-message {
    background: var(--card-background);
    color: var(--text-color);
    align-self: flex-start;
    margin-right: auto;
    border-bottom-left-radius: 4px;
}

.message-metrics {
    margin-top: 2px;
    font-size: 0.7em;
    opacity: 0.7;
    text-transform: lowercase;
}

/* Cost Estimator */
.card-container {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 20px;
    max-width: 1200px;
}

.estimator-card {
    flex: 1;
    min-width: 350px;
    max-width: 400px;
    background-color: var(--card-background);
    border-radius: 8px;
    padding: 25px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.estimator-card h2 {
    margin: 0 0 20px 0;
    font-size: 1.1rem;
    color: var(--text-color);
}

.model-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 25px;
}

.model-preset-btn {
    background-color: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 10px 15px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-color);
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 140px;
    text-transform: lowercase;
}

.model-preset-btn:hover {
    background-color: var(--hover-color);
    transform: translateY(-1px);
}

.model-preset-btn .model-name {
    font-weight: bold;
    margin-bottom: 4px;
}

.model-preset-btn .token-prices {
    font-size: 0.75rem;
    opacity: 0.8;
    text-align: center;
}

.input-group {
    margin-bottom: 20px;
    width: 100%;
}

.token-input {
    width: calc(100% - 24px); /* Account for padding */
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background-color: var(--background);
    color: var(--text-color);
    font-size: 0.9rem;
    transition: all 0.2s ease;
    text-transform: lowercase;
}

.price-input {
    background-color: var(--card-background);
    border-style: dashed;
}

.token-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(147, 112, 219, 0.2);
}

.token-input::placeholder {
    color: var(--text-color);
    opacity: 0.5;
    text-transform: lowercase;
}

.result-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
}

.cost-display {
    text-align: center;
    font-size: 1.1rem;
    margin-top: 15px;
    padding: 12px;
    border-radius: 6px;
    background-color: var(--background);
    border: 1px solid var(--border-color);
}

#total-cost {
    font-size: 1.4rem;
    font-weight: bold;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 120px;
}

.total-cost {
    margin-top: 20px;
    padding-top: 10px;
    border-top: 1px solid var(--border-color);
}

/* Preset Buttons */
.preset-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}

.preset-button {
    background-color: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 10px 15px;
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.2s ease;
    width: calc(50% - 4px);
    text-align: left;
}

.preset-button:hover {
    background-color: var(--hover-color);
}

.preset-button.active {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.preset-name {
    font-weight: bold;
    margin-bottom: 4px;
}

.preset-pricing {
    font-size: 0.9em;
    opacity: 0.8;
    display: flex;
    justify-content: space-between;
}

/* Advanced Settings */
.pricing-settings {
    padding: 20px;
    background-color: var(--card-background);
    border-radius: 8px;
    margin-top: 20px;
}

.preset-pricing-container {
    display: grid;
    gap: 20px;
}

.pricing-item {
    background-color: var(--background);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 15px;
}

.pricing-item h3 {
    margin: 0 0 10px 0;
    color: var(--primary-color);
}

.pricing-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 10px;
}

.pricing-input-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.pricing-input-group label {
    font-size: 0.9em;
    color: var(--text-color);
}

.pricing-input-group input {
    background-color: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 8px;
    color: var(--text-color);
}

/* Theme Switch */
.theme-switch-wrapper {
    position: fixed;
    bottom: 20px;
    right: 20px;
    transition: opacity 0.3s ease;
}

.theme-switch-wrapper.hidden {
    opacity: 0;
    pointer-events: none;
}

@media (min-width: 769px) {
    .theme-switch-wrapper.hidden {
        opacity: 1;
        pointer-events: all;
    }
}

.theme-switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 34px;
}

.theme-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--card-background);
    transition: 0.4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 4px;
    bottom: 4px;
    background-color: var(--primary-color);
    transition: 0.4s;
    border-radius: 50%;
}

input:checked + .slider:before {
    transform: translateX(26px);
}

/* Status messages */
.status-success {
    color: var(--primary-color);
    margin: 10px 0;
}

.status-error {
    color: #f44336;
    margin: 10px 0;
}

/* Typing indicator */
.typing-container {
    align-self: flex-start;
    margin: 10px 0;
    padding: 15px;
    background: var(--card-background);
    border-radius: 8px;
    max-width: 85px;
}

.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
}

.typing-indicator span {
    display: inline-block;
    width: 8px;
    height: 8px;
    background-color: var(--text-color);
    border-radius: 50%;
    opacity: 0.4;
    animation: typing 1s infinite;
}

.typing-indicator span:nth-child(1) {
    animation-delay: 0s;
}
.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}
.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

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

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--card-background);
}

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

::-webkit-scrollbar-thumb:hover {
    background: var(--hover-color);
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        flex-direction: column;
        padding: 10px;
    }

    .tabs {
        width: 100%;
        padding: 0;
        margin-bottom: 15px;
    }

    .tab-content-container {
        width: 100%;
    }

    #chat-interface {
        min-height: 70vh;
    }

    #chat-messages {
        min-height: calc(70vh - 100px);
    }

    #chat-form {
        flex-wrap: nowrap;
    }

    #chat-input {
        flex: 1;
        min-width: 0;
    }

    .button {
        width: auto;
    }

    .message {
        max-width: 90%;
    }

    .card-container {
        grid-template-columns: 1fr;
    }

    .theme-switch-wrapper {
        bottom: 20px;
        left: 20px;
    }
}

/* Media Queries for Mobile Responsiveness */
@media screen and (max-width: 768px) {
    .container {
        flex-direction: column;
        padding: 10px;
    }

    .tabs {
        width: 100%;
        padding-right: 0;
        margin-bottom: 20px;
    }

    .tab-content-container {
        width: 100%;
    }

    .preset-pricing-container {
        max-width: 100%;
        overflow-x: auto;
        padding: 10px 0;
    }

    .preset-pricing-container input[type="number"],
    .preset-pricing-container input[type="text"] {
        width: 140px;
        font-size: 15px;
        padding: 6px;
    }

    .button-group {
        justify-content: center;
    }

    #chat-form {
        width: calc(100% - 10px);
    }
}

/* Light Theme */
body.light-theme {
    --primary-color: var(--primary-color-light);
    --background: var(--background-light);
    --text-color: var(--text-dark);
    --card-background: var(--card-background-light);
    --hover-color: var(--hover-color-light);
    --tab-background: var(--tab-background-light);
    --tab-hover: var(--tab-hover-light);
    --tab-active: var(--tab-active-light);
    --border-color: var(--border-color-light);
}

/* Factory Reset */
.factory-reset-section {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
}

.danger-button {
    background-color: #dc3545;
    color: white;
}

.danger-button:hover {
    background-color: #c82333;
}

/* Backup/Restore Section */
.settings-backup-section {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
}

.settings-backup-section h2 {
    margin-bottom: 1rem;
}

::placeholder {
}

/* Tutorial Section Styles */
.tutorial-section {
    padding: 20px;
    max-width: 800px;
    margin: 0 auto;
}

.tutorial-section h2 {
    color: var(--text-color);
    margin-bottom: 30px;
    text-align: center;
}

.provider-section {
    background-color: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 25px;
}

.provider-section h3 {
    color: var(--primary-color);
    margin-top: 0;
    margin-bottom: 15px;
}

.provider-section p {
    margin-bottom: 15px;
    line-height: 1.5;
}

.provider-section ul {
    list-style-type: none;
    padding-left: 0;
}

.provider-section li {
    margin-bottom: 8px;
    line-height: 1.5;
}

.provider-section a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.2s ease;
}

.provider-section a:hover {
    color: var(--hover-color);
    text-decoration: underline;
}

.model-note {
    font-style: italic;
    opacity: 0.9;
    padding: 10px;
    border-left: 3px solid var(--primary-color);
    margin-top: 15px;
}
