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

:root {
    --bg-primary: #FFF8F4;
    --bg-secondary: #FFFFFF;
    --text-primary: #262624;
    --text-secondary: #6B6B68;
    --accent: rgb(185, 102, 71);
    --accent-hover: rgb(165, 82, 51);
    --border: #E5E5E0;
    --shadow: rgba(38, 38, 36, 0.08);
    --radius: 8px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
}

/* Page Management */
.page {
    display: none;
}

.page.active {
    display: block;
}

/* Login Page */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-box {
    background: var(--bg-secondary);
    padding: 48px;
    border-radius: 12px;
    box-shadow: 0 4px 24px var(--shadow);
    width: 100%;
    max-width: 420px;
}

.app-title {
    font-size: 32px;
    font-weight: 600;
    text-align: center;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.app-subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 32px;
    font-size: 15px;
}

.login-form {
    margin-bottom: 24px;
}

.login-divider {
    text-align: center;
    margin: 24px 0;
    position: relative;
}

.login-divider::before,
.login-divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 40%;
    height: 1px;
    background: var(--border);
}

.login-divider::before {
    left: 0;
}

.login-divider::after {
    right: 0;
}

.login-divider span {
    background: var(--bg-secondary);
    padding: 0 16px;
    color: var(--text-secondary);
    font-size: 14px;
}

/* Form Elements */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    font-size: 14px;
    color: var(--text-primary);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 15px;
    font-family: inherit;
    background: var(--bg-secondary);
    color: var(--text-primary);
    transition: all 0.2s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(185, 102, 71, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background: var(--accent);
    color: white;
    width: 100%;
}

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(185, 102, 71, 0.3);
}

.btn-secondary {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border);
    width: 100%;
}

.btn-secondary:hover {
    background: var(--bg-primary);
    border-color: var(--text-secondary);
}

.btn-text {
    background: transparent;
    color: var(--text-secondary);
    padding: 8px 16px;
}

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

.btn-small {
    padding: 6px 12px;
    font-size: 13px;
}

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

.btn-danger:hover {
    background: #c82333;
}

/* Navbar */
.navbar {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 16px 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
}

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

.user-display {
    font-size: 14px;
    color: var(--text-secondary);
    padding: 8px 16px;
    background: var(--bg-primary);
    border-radius: var(--radius);
}

/* Main Container */
.main-container {
    display: flex;
    max-width: 1400px;
    margin: 0 auto;
    min-height: calc(100vh - 73px);
}

/* Sidebar */
.sidebar {
    width: 240px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    padding: 24px 0;
}

.sidebar-section {
    padding: 0 12px;
}

.sidebar-btn {
    width: 100%;
    padding: 12px 16px;
    background: transparent;
    border: none;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 15px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    margin-bottom: 4px;
}

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

.sidebar-btn.active {
    background: var(--bg-primary);
    color: var(--accent);
    font-weight: 500;
}

.sidebar-icon {
    font-size: 20px;
}

/* Content Area */
.content {
    flex: 1;
    padding: 32px;
    overflow-y: auto;
}

.view {
    display: none;
}

.view.active {
    display: block;
}

.view-header {
    margin-bottom: 32px;
}

.view-header h2 {
    font-size: 28px;
    font-weight: 600;
    margin-bottom: 8px;
}

.view-subtitle {
    color: var(--text-secondary);
    font-size: 15px;
}

.view-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.search-input {
    flex: 1;
    min-width: 200px;
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    background: var(--bg-secondary);
}

.filter-select {
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    background: var(--bg-secondary);
    cursor: pointer;
}

/* Card Grid */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    transition: all 0.2s;
    cursor: pointer;
}

.card:hover {
    box-shadow: 0 4px 12px var(--shadow);
    transform: translateY(-2px);
    border-color: var(--accent);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.card-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.card-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
}

.card-content {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 16px;
}

.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.card-meta {
    font-size: 13px;
    color: var(--text-secondary);
}

.card-actions {
    display: flex;
    gap: 8px;
}

.progress-bar {
    height: 6px;
    background: var(--bg-primary);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 12px;
}

.progress-fill {
    height: 100%;
    background: var(--accent);
    transition: width 0.3s;
}

.badge {
    display: inline-block;
    padding: 4px 12px;
    background: var(--bg-primary);
    color: var(--text-primary);
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.badge-success {
    background: #d4edda;
    color: #155724;
}

.badge-warning {
    background: #fff3cd;
    color: #856404;
}

.empty-state {
    text-align: center;
    padding: 64px 32px;
    color: var(--text-secondary);
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 20px;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.empty-state p {
    margin-bottom: 24px;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(38, 38, 36, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: 12px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(38, 38, 36, 0.3);
}

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

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

.modal-header h2 {
    font-size: 24px;
    font-weight: 600;
}

.modal-close {
    background: transparent;
    border: none;
    font-size: 28px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    transition: all 0.2s;
}

.modal-close:hover {
    background: var(--bg-primary);
    color: var(--text-primary);
}

.modal-content form {
    padding: 24px;
}

.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.modal-actions .btn {
    flex: 1;
}

#examplesContainer {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.example-input {
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
}

#wordDetailContent {
    padding: 24px;
}

.detail-section {
    margin-bottom: 24px;
}

.detail-section h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.detail-section p {
    font-size: 16px;
    color: var(--text-primary);
    line-height: 1.6;
}

.example-list {
    list-style: none;
}

.example-list li {
    padding: 12px;
    background: var(--bg-primary);
    border-radius: var(--radius);
    margin-bottom: 8px;
    font-size: 15px;
    color: var(--text-primary);
}

.detail-actions {
    display: flex;
    gap: 12px;
    padding: 24px;
    border-top: 1px solid var(--border);
}

/* Toast */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--text-primary);
    color: white;
    padding: 16px 24px;
    border-radius: var(--radius);
    box-shadow: 0 4px 24px var(--shadow);
    z-index: 2000;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast.error {
    background: #dc3545;
}

.toast.success {
    background: #28a745;
}

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

    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border);
        padding: 16px 0;
    }

    .sidebar-section {
        display: flex;
        overflow-x: auto;
        gap: 8px;
    }

    .sidebar-btn {
        flex-shrink: 0;
        width: auto;
    }

    .content {
        padding: 20px;
    }

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

    .view-actions {
        flex-direction: column;
    }

    .search-input {
        min-width: 100%;
    }

    .login-box {
        padding: 32px 24px;
    }
}


/* Add to frontend/styles.css */

.ai-container {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 24px;
    height: calc(100vh - 200px);
}

.ai-sidebar {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    overflow-y: auto;
}

.ai-sidebar h3 {
    font-size: 18px;
    margin-bottom: 16px;
}

.word-search {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.ai-words-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ai-word-item {
    padding: 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
}

.ai-word-item:hover {
    border-color: var(--accent);
    background: var(--bg-secondary);
}

.ai-word-item.selected {
    background: var(--accent-light);
    border-color: var(--accent);
}

.ai-word-title {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.ai-word-meaning {
    font-size: 13px;
    color: var(--text-secondary);
}

.ai-main {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    overflow-y: auto;
}

.ai-form-section h3 {
    font-size: 18px;
    margin-bottom: 16px;
}

.selected-words {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-height: 50px;
    padding: 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 20px;
}

.selected-word-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--accent);
    color: white;
    border-radius: 16px;
    font-size: 14px;
}

.selected-word-tag button {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 16px;
    padding: 0;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-result-section {
    margin-top: 32px;
    padding-top: 32px;
    border-top: 2px solid var(--border);
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.result-header h3 {
    font-size: 18px;
}

.result-actions {
    display: flex;
    gap: 8px;
}

.ai-result {
    background: var(--bg-primary);
    padding: 24px;
    border-radius: var(--radius);
    line-height: 1.8;
    font-size: 15px;
    white-space: pre-wrap;
    margin-bottom: 20px;
}

.ai-metadata {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    padding: 16px;
    background: var(--bg-primary);
    border-radius: var(--radius);
}

.metadata-item {
    text-align: center;
}

.metadata-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.metadata-value {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

@media (max-width: 1024px) {
    .ai-container {
        grid-template-columns: 1fr;
        height: auto;
    }

    .ai-sidebar {
        max-height: 400px;
    }
}