/* Global Styles & Variables */
:root {
    --primary-color: #6366f1;
    /* Indigo 500 */
    --primary-hover: #4f46e5;
    /* Indigo 600 */
    --secondary-color: #ec4899;
    /* Pink 500 */
    --background-color: #f8fafc;
    /* Slate 50 */
    --surface-color: #ffffff;
    --text-main: #1e293b;
    /* Slate 800 */
    --text-muted: #64748b;
    /* Slate 500 */
    --border-color: #e2e8f0;
    /* Slate 200 */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --font-family: 'Inter', system-ui, -apple-system, sans-serif;
    --radius-lg: 0.75rem;
    --radius-md: 0.5rem;
}

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

body {
    font-family: var(--font-family);
    background-color: var(--background-color);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: 700;
    line-height: 1.2;
}

button {
    cursor: pointer;
    border: none;
    background: none;
    font-family: inherit;
}

input,
textarea {
    font-family: inherit;
}

/* Utilities */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

.flex {
    display: flex;
}

.flex-col {
    display: flex;
    flex-direction: column;
}

.items-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.gap-2 {
    gap: 0.5rem;
}

.gap-4 {
    gap: 1rem;
}

.hidden {
    display: none !important;
}

/* Site alert banner */
.site-alert {
    background-color: #ef4444; /* red-500 */
    color: #ffffff;
    text-align: center;
    padding: 0.35rem 0.75rem;
    font-weight: 600;
    font-size: 0.95rem;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    box-shadow: var(--shadow-sm);
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}



/* Layout */
.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.sidebar {
    width: 280px;
    background-color: var(--surface-color);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--background-color);
    position: relative;
}

.workspace {
    flex: 1;
    display: flex;
    gap: 1.5rem;
    padding: 1.5rem;
    overflow: hidden;
}

/* Sidebar Elements */
.logo {
    margin-bottom: 2rem;
    color: var(--primary-color);
}

.history-container {
    flex: 1;
    overflow-y: auto;
}

.history-item {
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    background-color: var(--background-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background-color 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    font-size: 0.9rem;
}

.history-item:hover {
    background-color: #f1f5f9;
}

.history-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.history-type {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
}

.history-date {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.delete-btn {
    opacity: 0;
    color: var(--text-muted);
    padding: 0.2rem 0.5rem;
    transition: opacity 0.2s;
}

.history-item:hover .delete-btn {
    opacity: 1;
}

.delete-btn:hover {
    color: #ef4444;
}

/* Top Bar */
.top-bar {
    height: 64px;
    background-color: var(--surface-color);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.avatar {
    width: 32px;
    height: 32px;
    background-color: var(--primary-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

/* Cards & Sections */
.card {
    background-color: var(--surface-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.input-section {
    flex: 1;
    max-width: 40%;
    padding: 1.5rem;
}

.output-section {
    flex: 1;
    padding: 1.5rem;
    position: relative;
}

.input-header,
.output-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

textarea {
    width: 100%;
    flex: 1;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem;
    resize: none;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

textarea:focus {
    border-color: var(--primary-color);
}

/* Buttons */
.action-buttons {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

.btn {
    flex: 1;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    font-weight: 500;
    transition: transform 0.1s, box-shadow 0.1s;
}

.btn:active {
    transform: translateY(1px);
}

.btn.primary {
    background-color: var(--primary-color);
    color: white;
    box-shadow: 0 4px 6px -1px rgba(99, 102, 241, 0.4);
}

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

.btn.secondary {
    background-color: var(--background-color);
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

.btn.secondary:hover {
    background-color: #f1f5f9;
}

/* Output Content */
.output-content {
    flex: 1;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.markdown-body {
    font-size: 1rem;
    line-height: 1.6;
}

.placeholder-state {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

/* Loading State */
.loading-state {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

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

    .sidebar {
        display: none;
        /* Simplify for now or add toggle */
    }

    .workspace {
        flex-direction: column;
        overflow-y: auto;
    }

    .input-section,
    .output-section {
        max-width: 100%;
        min-height: 400px;
    }
}

.fade-in {
    animation: fadeIn 0.3s ease-out forwards;
}

/* Button Groups */
.btn-group {
    display: flex;
    gap: 0.25rem;
    flex: 1;
}

.btn-group .btn {
    border-radius: var(--radius-md) 0 0 var(--radius-md);
    flex: 1;
}

.btn-group .btn.icon-only {
    flex: 0 0 auto;
    width: 40px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    background-color: #f1f5f9;
    border: 1px solid var(--border-color);
    border-left: none;
}

.btn.icon-only:hover {
    background-color: #e2e8f0;
}

/* Chat Interface */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-height: 600px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.chat-input-area {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 0.5rem;
}

.chat-bubble {
    padding: 0.75rem 1rem;
    border-radius: 1rem;
    max-width: 80%;
    font-size: 0.95rem;
    line-height: 1.5;
}

.chat-bubble.user {
    background-color: var(--primary-color);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 0.25rem;
}

.chat-bubble.ai {
    background-color: #f1f5f9;
    color: var(--text-main);
    align-self: flex-start;
    border-bottom-left-radius: 0.25rem;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background-color: var(--surface-color);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 400px;
    box-shadow: var(--shadow-md);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.close-btn {
    font-size: 1.5rem;
    line-height: 1;
    padding: 0.5rem;
}

.range-control {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 1rem 0 2rem;
}

input[type="range"] {
    flex: 1;
}

.full-width {
    width: 100%;
}

/* Flashcards */
.flashcards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    padding: 1rem 0;
}

.flashcard {
    background-color: transparent;
    width: 100%;
    height: 200px;
    perspective: 1000px;
    cursor: pointer;
}

.flashcard-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.6s;
    transform-style: preserve-3d;
    box-shadow: var(--shadow-md);
    border-radius: var(--radius-lg);
}

.flashcard.flipped .flashcard-inner {
    transform: rotateY(180deg);
}

.flashcard-front,
.flashcard-back {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden;
    /* Safari */
    backface-visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    font-size: 1.1rem;
    overflow-y: auto;
}

.flashcard-front {
    color: var(--text-main);
    z-index: 2;
    transform: rotateY(0deg);
}

.flashcard-back {
    background-color: var(--primary-color);
    color: white;
    transform: rotateY(180deg);
    z-index: 1;
}

.landing-container {
    height: 100vh;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #6366f1 0%, #ec4899 100%);
    color: white;
    text-align: center;
    overflow: hidden;
    position: relative;
}

.landing-content {
    z-index: 10;
    padding: 2rem;
}

.landing-title {
    font-size: 4rem;
    font-weight: 800;
    margin-bottom: 1rem;
    letter-spacing: -0.05em;
    text-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.landing-subtitle {
    font-size: 1.5rem;
    margin-bottom: 2rem;
    opacity: 0.9;
}

.landing-features {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-bottom: 3rem;
    flex-wrap: wrap;
}

.feature-item {
    background: rgba(255, 255, 255, 0.2);
    padding: 0.5rem 1rem;
    border-radius: 2rem;
    backdrop-filter: blur(10px);
    font-size: 0.9rem;
}

.btn-login {
    background-color: white;
    color: var(--primary-color);
    padding: 1rem 2rem;
    border-radius: 2rem;
    font-size: 1.2rem;
    font-weight: 600;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s, box-shadow 0.2s;
    border: none;
    cursor: pointer;
}

.btn-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

.btn-login:active {
    transform: translateY(0);
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in-up {
    animation: fadeInUp 0.8s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

/* User Profile Update */
.user-profile {
    gap: 0.5rem;
}

.btn-text {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0 0.5rem;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.btn-text:hover {
    opacity: 1;
}

.hidden {
    display: none !important;
}