:root {
    /* Provided palette (mapped from Flutter-like colors) */
    --scaffold-bg: #ffffff;            /* scaffoldBackground */
    --nav-bg: #e2eafc;                 /* navigaionBar */
    --card-bg: #f4f5f7;                /* wordCard */
    --text-main: #000000;              /* wordCardText */
    --accent: #8b3dff;                 /* wordCardIcon */
    --ink: #052a3a;                    /* settingCardIcon / settingCardText */
    --shadow: rgba(0, 0, 0, 0.12);     /* cardShadow = Colors.black12 */

    /* System colors */
    --border-color: rgba(5, 42, 58, 0.14);
    --text-muted: rgba(5, 42, 58, 0.68);
    --danger: #dc2626;
    --success: #16a34a;
    --focus: rgba(139, 61, 255, 0.22);

    /* Layout */
    --sidebar-bg: #ffffff;
    --sidebar-width: 280px;
    --radius-lg: 18px;
    --radius-md: 14px;
    --radius-sm: 12px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Tajawal', sans-serif;
}

body {
    background-color: var(--scaffold-bg);
    color: var(--ink);
    min-height: 100vh;
    display: block;
    padding: 0;
}

/* App Shell (Sidebar + Content) */
.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
}

.sidebar {
    background: var(--sidebar-bg);
    border-left: 1px solid var(--border-color);
    padding: 18px 16px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow: auto;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 10px 14px;
    margin-bottom: 6px;
}

.brand-badge {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: rgba(139, 61, 255, 0.12);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 20px -12px var(--shadow);
}

.brand-text h1 {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--ink);
    line-height: 1.2;
}

.brand-text p {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: 2px;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 10px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 12px;
    color: var(--ink);
    text-decoration: none;
    border: 1px solid transparent;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.05s ease;
}

.nav-link:hover {
    background: rgba(226, 234, 252, 0.7);
    border-color: rgba(5, 42, 58, 0.10);
}

.nav-link:active {
    transform: scale(0.99);
}

.nav-link .dot {
    width: 10px;
    height: 10px;
    border-radius: 99px;
    background: rgba(5, 42, 58, 0.2);
}

.nav-link.active .dot {
    background: var(--accent);
}

.sidebar-card {
    margin-top: 14px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px;
    box-shadow: 0 14px 30px -22px var(--shadow);
}

.sidebar-card h3 {
    font-size: 0.95rem;
    color: var(--ink);
    margin-bottom: 6px;
}

.sidebar-card p {
    color: var(--text-muted);
    font-size: 0.85rem;
    line-height: 1.6;
}

.content-area {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    background: var(--nav-bg);
    border-bottom: 1px solid rgba(5, 42, 58, 0.10);
    padding: 16px 22px;
    position: sticky;
    top: 0;
    z-index: 20;
}

.topbar-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.topbar-title {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.topbar-title h2 {
    font-size: 1.2rem;
    color: var(--ink);
    margin: 0;
}

.topbar-title p {
    color: rgba(5, 42, 58, 0.72);
    font-size: 0.9rem;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.pill {
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(5, 42, 58, 0.10);
    padding: 8px 10px;
    border-radius: 999px;
    color: var(--ink);
    font-weight: 700;
    font-size: 0.85rem;
}

.page {
    padding: 18px 22px 26px;
    max-width: 1280px;
    width: 100%;
    margin: 0 auto;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 14px;
    margin-bottom: 14px;
}

.stat-card {
    grid-column: span 3;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 14px 14px 12px;
    box-shadow: 0 18px 40px -28px var(--shadow);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.stat-meta {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.stat-label {
    color: var(--text-muted);
    font-weight: 700;
    font-size: 0.86rem;
}

.stat-value {
    color: var(--ink);
    font-weight: 900;
    font-size: 1.35rem;
    line-height: 1;
}

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    background: rgba(139, 61, 255, 0.12);
    flex: 0 0 auto;
}

main {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
}

h2 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--ink);
}

/* Upload Section */
.upload-section {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    box-shadow: 0 20px 50px -36px var(--shadow);
}

.file-drop-area {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 2rem;
    border: 2px dashed rgba(139, 61, 255, 0.55);
    border-radius: var(--radius-md);
    background: rgba(226, 234, 252, 0.6);
    transition: all 0.3s ease;
    cursor: pointer;
    margin-bottom: 1rem;
}

.file-drop-area:hover, .file-drop-area.dragover {
    background: rgba(226, 234, 252, 0.9);
    border-color: var(--accent);
}

.upload-icon {
    color: var(--accent);
    margin-bottom: 1rem;
}

.file-msg {
    font-size: 1rem;
    color: var(--text-muted);
    font-weight: 500;
}

.file-input {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 100%;
    opacity: 0;
    cursor: pointer;
}

.submit-btn {
    width: 100%;
    background-color: var(--accent);
    color: white;
    border: none;
    padding: 1rem;
    border-radius: 0.75rem;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.3s ease, transform 0.1s ease;
}

.submit-btn:hover {
    background-color: #7528ff;
}

.submit-btn:active {
    transform: scale(0.98);
}

.submit-btn:disabled {
    background-color: var(--text-muted);
    cursor: not-allowed;
}

.progress-bar-container {
    display: none;
    width: 100%;
    height: 12px;
    background-color: rgba(5, 42, 58, 0.10);
    border-radius: 6px;
    margin-top: 1rem;
    overflow: hidden;
    position: relative;
}

.progress-bar {
    height: 100%;
    background-color: var(--success);
    width: 0%;
    transition: width 0.2s ease;
}

.progress-text {
    position: absolute;
    top: -24px;
    right: 0;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.status-message {
    margin-top: 1rem;
    text-align: center;
    font-weight: bold;
    padding: 0.5rem;
    border-radius: 0.5rem;
    display: none;
}

.status-success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
    display: block;
}

.status-error {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    display: block;
}

/* Models List Area */
.files-list-section {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    box-shadow: 0 20px 50px -36px var(--shadow);
}

.filters-bar {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 10px;
    margin: 10px 0 14px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.field label {
    color: var(--text-muted);
    font-weight: 700;
    font-size: 0.85rem;
}

.control {
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid rgba(5, 42, 58, 0.14);
    color: var(--ink);
    padding: 10px 12px;
    border-radius: 12px;
    outline: none;
    transition: box-shadow 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.control:focus {
    border-color: rgba(139, 61, 255, 0.55);
    box-shadow: 0 0 0 4px var(--focus);
}

.filters-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 6px;
}

.muted {
    color: var(--text-muted);
    font-size: 0.88rem;
    font-weight: 700;
}

.models-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.model-card {
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.model-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 18px 44px -32px var(--shadow);
    border-color: rgba(139, 61, 255, 0.35);
}

.model-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.model-icon {
    width: 40px;
    height: 40px;
    border-radius: 0.5rem;
    background: rgba(139, 61, 255, 0.12);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
}

.model-details {
    flex: 1;
    overflow: hidden;
}

.model-name {
    font-weight: bold;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    direction: ltr;
    text-align: right;
    font-size: 0.95rem;
}

.model-size {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
}

.model-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.btn-action {
    flex: 1;
    padding: 0.5rem;
    border-radius: 0.5rem;
    border: none;
    font-weight: 500;
    font-size: 0.85rem;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    transition: opacity 0.2s;
}

.btn-action:hover {
    opacity: 0.9;
}

.btn-copy {
    background-color: rgba(5, 42, 58, 0.06);
    color: var(--ink);
    border: 1px solid rgba(5, 42, 58, 0.12);
}

.btn-activate {
    background-color: rgba(16, 185, 129, 0.1);
    color: var(--success);
    border: 1px solid var(--success);
}

.btn-deactivate {
    background-color: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border: 1px solid var(--danger);
}

.btn-delete {
    background-color: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border: 1px solid var(--danger);
}

.badge {
    padding: 0.15rem 0.4rem;
    border-radius: 0.25rem;
    font-size: 0.7rem;
    font-weight: bold;
    margin-right: 0.5rem;
}

.status-active {
    background-color: rgba(16, 185, 129, 0.2);
    color: var(--success);
}

.status-inactive {
    background-color: rgba(239, 68, 68, 0.2);
    color: var(--danger);
}

/* Suggestions Section */
.suggestions-section {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    margin-top: 2rem;
    box-shadow: 0 20px 50px -36px var(--shadow);
}

.suggestions-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

.suggestion-card {
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.suggestion-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 18px 44px -32px var(--shadow);
    border-color: rgba(139, 61, 255, 0.35);
}

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

.suggestion-title {
    font-size: 1.15rem;
    font-weight: bold;
    color: var(--text-main);
}

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

.suggestion-body {
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--text-muted);
    white-space: pre-wrap;
}

.suggestion-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 0.5rem;
}

footer {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

code {
    background: rgba(5, 42, 58, 0.06);
    padding: 0.2rem 0.5rem;
    border-radius: 0.25rem;
    color: var(--accent);
    font-family: monospace;
}

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

.modal-content {
    background: #ffffff;
    width: 90%;
    max-width: 600px;
    border-radius: 1rem;
    padding: 2rem;
    border: 1px solid var(--border-color);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 34px 90px -60px var(--shadow);
}

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

.modal-title {
    font-size: 1.5rem;
    color: var(--accent);
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
}

.close-btn:hover {
    color: var(--danger);
}

.modal-body {
    overflow-y: auto;
    flex: 1;
    padding-right: 0.5rem;
}

.animation-row {
    display: flex;
    flex-direction: column;
    margin-bottom: 1rem;
}

.animation-row label {
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.animation-row input {
    background: rgba(5, 42, 58, 0.04);
    border: 1px solid rgba(5, 42, 58, 0.14);
    color: var(--ink);
    padding: 0.75rem;
    border-radius: 0.5rem;
    font-size: 1rem;
}

.animation-row input:focus {
    outline: none;
    border-color: rgba(139, 61, 255, 0.55);
    box-shadow: 0 0 0 4px var(--focus);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

/* Responsive */
@media (max-width: 980px) {
    .app-shell {
        grid-template-columns: 1fr;
    }
    .sidebar {
        position: relative;
        height: auto;
        border-left: none;
        border-bottom: 1px solid var(--border-color);
    }
    .stats-grid {
        grid-template-columns: repeat(12, 1fr);
    }
    .stat-card {
        grid-column: span 6;
    }
    .filters-bar {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 520px) {
    .page {
        padding: 14px 14px 22px;
    }
    .topbar {
        padding: 14px 14px;
    }
    .stat-card {
        grid-column: span 12;
    }
}

