/* Variables & Base styling */
:root {
    --bg-primary: #0a0a0f;
    --bg-panel: rgba(20, 25, 35, 0.6);
    --bg-input: rgba(0, 0, 0, 0.4);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-focus: rgba(56, 189, 248, 0.5);

    --text-primary: #ffffff;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;

    --accent-color: #38bdf8;
    --accent-hover: #0284c7;

    --success-color: #10b981;
    --danger-color: #ef4444;

    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    --glass-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-primary);
    background-image:
        radial-gradient(ellipse at top left, rgba(56, 189, 248, 0.1) 0%, transparent 40%),
        radial-gradient(ellipse at bottom right, rgba(168, 85, 247, 0.08) 0%, transparent 40%);
    color: var(--text-primary);
    font-family: var(--font-body);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.hidden {
    display: none !important;
}

/* Container */
.app-container {
    width: 100%;
    max-width: 1200px;
    height: calc(100vh - 48px);
    background: var(--bg-panel);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    box-shadow: var(--glass-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Header */
header {
    padding: 20px 32px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.2);
}

.logo {
    display: flex;
    align-items: center;
    gap: 16px;
}

.logo i {
    width: 32px;
    height: 32px;
    color: var(--accent-color);
}

.logo h1 {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.logo p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.header-actions {
    display: flex;
    gap: 12px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 8px;
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid transparent;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn i {
    width: 18px;
    height: 18px;
}

.btn-primary {
    background: var(--accent-color);
    color: #fff;
    box-shadow: 0 4px 12px rgba(56, 189, 248, 0.3);
}

.btn-primary:hover:not(:disabled) {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(56, 189, 248, 0.4);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border-color: var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

.btn-text {
    background: transparent;
    color: var(--text-secondary);
}

.btn-text:hover:not(:disabled) {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

.btn-icon {
    padding: 10px;
}

/* Main Content */
main {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.split-pane {
    display: flex;
    width: 100%;
    height: 100%;
}

.pane {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.input-pane {
    border-right: 1px solid var(--border-color);
}

.pane-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.1);
}

.pane-header h2 {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.editor-container,
.output-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 24px;
    overflow-y: auto;
    background: var(--bg-input);
}

/* Form Elements */
textarea,
input[type="text"],
input[type="password"],
select {
    width: 100%;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 16px;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.95rem;
    transition: var(--transition);
}

textarea:focus,
input:focus,
select:focus {
    outline: none;
    border-color: var(--border-focus);
    background: rgba(255, 255, 255, 0.05);
}

textarea {
    flex: 1;
    resize: none;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    line-height: 1.5;
}

#diffInput {
    white-space: pre;
    overflow-wrap: normal;
    overflow-x: auto;
}

#messageOutput {
    font-size: 0.95rem;
}

.options-bar {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 16px;
    background: rgba(0, 0, 0, 0.2);
}

.option-group {
    flex: 1;
    min-width: 150px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.option-group label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Output States */
.empty-state,
.loading-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 16px;
    color: var(--text-secondary);
}

.empty-state i {
    width: 48px;
    height: 48px;
    opacity: 0.5;
}

.loading-state i {
    width: 48px;
    height: 48px;
    color: var(--accent-color);
}

.spin {
    animation: spin 1s linear infinite;
}

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

.action-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.2);
}

.tokens-info {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.footer-buttons {
    display: flex;
    gap: 12px;
}

/* Modals */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 1;
    transition: var(--transition);
}

.modal.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    width: 100%;
    max-width: 500px;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    transform: translateY(0) scale(1);
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    max-height: 90vh;
}

.modal.hidden .modal-content {
    transform: translateY(20px) scale(0.95);
}

.history-modal {
    max-width: 700px;
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-family: var(--font-heading);
    font-size: 1.25rem;
}

.btn-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
}

.btn-close:hover {
    color: var(--text-primary);
    transform: rotate(90deg);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

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

.form-group label {
    font-size: 0.9rem;
    font-weight: 500;
}

.help-text {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.modal-footer {
    padding: 20px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    background: rgba(0, 0, 0, 0.2);
    border-bottom-left-radius: 16px;
    border-bottom-right-radius: 16px;
}

/* History Items */
.history-item {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.history-message {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    white-space: pre-wrap;
    background: rgba(0, 0, 0, 0.3);
    padding: 12px;
    border-radius: 4px;
    border-left: 3px solid var(--accent-color);
}

.history-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 32px;
    right: 32px;
    background: rgba(20, 25, 35, 0.9);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    padding: 12px 24px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    transition: var(--transition);
}

.toast.hidden {
    opacity: 0;
    transform: translateY(20px);
    pointer-events: none;
}

.toast i {
    color: var(--success-color);
    width: 20px;
    height: 20px;
}

/* Responsive */
@media (max-width: 900px) {
    .split-pane {
        flex-direction: column;
    }

    .input-pane {
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        max-height: 50%;
    }
}