/* ============================================================
   ENCARSIK AI — Light minimal theme
   ============================================================ */

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

:root {
    --bg:        #f4f5f7;
    --surface:   #ffffff;
    --surface-2: #f9fafb;
    --surface-3: #f0f1f3;
    --border:    #e5e7eb;
    --border-h:  #d1d5db;

    --text:      #111827;
    --text-2:    #6b7280;
    --text-3:    #9ca3af;

    --accent:    #7c5cfc;
    --accent-h:  #6d4bef;
    --accent-bg: rgba(124,92,252,.08);
    --accent-light: rgba(124,92,252,.05);
    --accent-ring: rgba(124,92,252,.2);
    --accent-on: #ffffff;

    --green:     #22c55e;
    --yellow:    #f59e0b;
    --red:       #ef4444;
    --blue:      #3b82f6;

    --radius-sm: 8px;
    --radius:    12px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    --sidebar-w: 72px;
    --font:      'Inter', system-ui, -apple-system, sans-serif;
    --mono:      'JetBrains Mono', 'Fira Code', ui-monospace, monospace;

    --shadow-sm: 0 1px 2px rgba(0,0,0,.04);
    --shadow:    0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,.06);
    --shadow-lg: 0 8px 24px rgba(0,0,0,.08);

    --transition: .15s cubic-bezier(.4,0,.2,1);
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

body {
    margin: 0;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    display: flex;
    height: 100vh;
    overflow: hidden;
    font-size: 14px;
    line-height: 1.6;
}

a { text-decoration: none; color: var(--accent); transition: color var(--transition); }
a:hover { color: var(--accent-h); }

::selection { background: var(--accent-bg); }

/* ============================================================
   SIDEBAR (slim icon sidebar)
   ============================================================ */
.sidebar {
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-y: auto;
    z-index: 10;
}

.sidebar-logo {
    padding: 18px 0 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    border-bottom: 1px solid var(--border);
    width: 100%;
}

.sidebar-logo .logo-icon {
    width: 38px;
    height: 38px;
    border-radius: var(--radius);
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    color: #fff;
    flex-shrink: 0;
}

.sidebar-logo .logo-text { display: none; }

.nav {
    flex: 1;
    padding: 12px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    width: 100%;
}

.nav-section-label { display: none; }

.nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 54px;
    height: 54px;
    color: var(--text-3);
    border-radius: var(--radius);
    font-size: 10px;
    font-weight: 500;
    transition: all var(--transition);
    gap: 3px;
    text-align: center;
    line-height: 1.1;
}

.nav a:hover {
    background: var(--surface-3);
    color: var(--text-2);
}

.nav a.active {
    background: var(--accent-bg);
    color: var(--accent);
}

.nav a.active svg { opacity: 1; }

.nav svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    opacity: .55;
    transition: opacity var(--transition);
}

.nav a:hover svg { opacity: .8; }
.nav a.active svg { opacity: 1; }

.nav a span {
    font-size: 10px;
    letter-spacing: -.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 52px;
}

/* Chat history sub-items — hidden in slim sidebar */
.chat-history-block { display: none; }
.toggle-chats-btn { display: none; }

/* ============================================================
   MAIN CONTENT AREA
   ============================================================ */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 32px 40px;
    overflow-y: auto;
    background: var(--bg);
}

.page-header,
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 28px;
    gap: 16px;
}

.header h1 {
    font-size: 26px;
    font-weight: 700;
    margin: 0;
    letter-spacing: -.4px;
    color: var(--text);
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition);
}

.card:hover { box-shadow: var(--shadow); }

.card-title {
    font-size: 15px;
    font-weight: 600;
    margin: 0 0 16px;
    color: var(--text);
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    border: none;
    font-family: var(--font);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

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

.btn,
.btn-primary {
    background: var(--accent);
    color: var(--accent-on);
    box-shadow: var(--shadow-sm);
}

.btn:hover,
.btn-primary:hover {
    background: var(--accent-h);
    box-shadow: var(--shadow);
}

.btn-secondary,
.btn.secondary {
    background: var(--surface);
    color: var(--text);
    box-shadow: none;
    border: 1px solid var(--border);
}

.btn-secondary:hover,
.btn.secondary:hover {
    background: var(--surface-2);
    border-color: var(--border-h);
}

.btn-danger {
    background: rgba(239,68,68,.08);
    color: var(--red);
    box-shadow: none;
}

.btn-danger:hover { background: rgba(239,68,68,.14); }

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-2);
    box-shadow: none;
}

.btn-outline:hover {
    background: var(--surface-2);
    color: var(--text);
    border-color: var(--border-h);
}

.btn-sm {
    padding: 7px 14px;
    font-size: 12px;
    border-radius: 6px;
}

/* ============================================================
   TABLES
   ============================================================ */
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

table a { color: var(--accent); font-weight: 500; }
table a:hover { color: var(--accent-h); text-decoration: underline; text-underline-offset: 2px; }

th, td {
    padding: 13px 18px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    background: var(--surface-2);
    color: var(--text-3);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .5px;
}

tr:last-child td { border-bottom: none; }

tr:hover td { background: var(--accent-light); }

td button {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-2);
    padding: 5px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-family: var(--font);
    font-weight: 500;
    transition: all var(--transition);
    margin-right: 4px;
}

td button:hover {
    background: var(--surface-2);
    color: var(--text);
    border-color: var(--border-h);
}

td button[style*="color:var(--red)"],
td button[style*="color: var(--red)"] {
    border-color: rgba(239,68,68,.2);
}

.token {
    color: var(--text-3);
    font-family: var(--mono);
    font-size: 12px;
}

.action-btn {
    background: var(--surface);
    color: var(--text-2);
    border: 1px solid var(--border);
    padding: 5px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-family: var(--font);
    font-weight: 500;
    transition: all var(--transition);
}

.action-btn:hover {
    background: var(--accent-bg);
    color: var(--accent);
    border-color: var(--accent-ring);
}

/* ============================================================
   FORMS
   ============================================================ */
.form-container {
    background: var(--surface);
    padding: 24px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
}

.form-group { margin-bottom: 18px; }

label {
    display: block;
    margin-bottom: 6px;
    color: var(--text-2);
    font-size: 13px;
    font-weight: 500;
}

input, select, textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-size: 14px;
    font-family: var(--font);
    transition: all var(--transition);
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-ring);
}

input::placeholder, textarea::placeholder {
    color: var(--text-3);
}

textarea {
    resize: vertical;
    min-height: 80px;
    line-height: 1.5;
}

/* ============================================================
   CHAT INTERFACE
   ============================================================ */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg);
}

.messages {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    width: 100%;
    gap: 8px;
}

.message {
    margin: 4px 0;
    padding: 12px 18px;
    border-radius: var(--radius-lg);
    max-width: 85%;
    line-height: 1.6;
    white-space: pre-wrap;
    font-size: 14px;
}

.user {
    background: var(--accent);
    align-self: flex-end;
    color: #fff;
    border-radius: var(--radius-lg) var(--radius-lg) 6px var(--radius-lg);
}

.ai {
    background: var(--surface);
    align-self: flex-start;
    color: var(--text);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    border-radius: var(--radius-lg) var(--radius-lg) var(--radius-lg) 6px;
}

.input-area {
    display: flex;
    padding: 16px 24px 24px;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
    gap: 10px;
    background: transparent;
    border: none;
}

.input-area textarea {
    flex: 1;
    resize: none;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 12px 20px;
    font-size: 14px;
    background: var(--surface);
    color: var(--text);
    max-height: 48px;
    font-family: var(--font);
    box-shadow: var(--shadow-sm);
    transition: border-color var(--transition);
}

.input-area textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-ring);
}

.input-area button {
    padding: 12px 22px;
    background: var(--accent);
    border: none;
    border-radius: 999px;
    color: #fff;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    font-size: 14px;
    font-family: var(--font);
    white-space: nowrap;
    box-shadow: var(--shadow-sm);
}

.input-area button:hover {
    background: var(--accent-h);
    box-shadow: var(--shadow);
}

.thinking {
    font-style: italic;
    color: var(--text-3);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: .4; }
    50% { opacity: 1; }
}

/* ============================================================
   HOME INFO
   ============================================================ */
.home-infotext {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 48px;
    max-width: 640px;
    margin: auto;
    box-shadow: var(--shadow-md);
}

.home-infotext h2 {
    font-size: 26px;
    font-weight: 700;
    margin: 0 0 12px;
    letter-spacing: -.4px;
}

.home-infotext p {
    margin-bottom: 14px;
    font-size: 15px;
    line-height: 1.7;
    color: var(--text-2);
}

.home-infotext a {
    color: var(--accent);
    font-weight: 600;
    border-bottom: none;
}

.home-infotext a:hover { color: var(--accent-h); }

/* ============================================================
   STATUS BADGES
   ============================================================ */
.status-label {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 999px;
    font-weight: 600;
    font-size: 11px;
    gap: 5px;
}

.status-done    { background: rgba(34,197,94,.1);  color: #16a34a; }
.status-pending { background: rgba(245,158,11,.1); color: #d97706; }
.status-error   { background: rgba(239,68,68,.08); color: #dc2626; }
.status-loading { background: rgba(107,114,128,.08); color: var(--text-2); }

/* ============================================================
   CHAT INFO GRID
   ============================================================ */
.chat-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 24px;
    background: var(--surface-2);
    padding: 18px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.info-item .label,
.label {
    color: var(--text-3);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .4px;
}

/* ============================================================
   CHIPS
   ============================================================ */
.chip {
    padding: 4px 12px;
    border-radius: 999px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text-3);
    font-weight: 500;
    font-size: 11px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

/* ============================================================
   TABS
   ============================================================ */
.tabs {
    display: flex;
    gap: 2px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 24px;
}

.tab {
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-3);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all var(--transition);
    background: none;
    border-top: none; border-left: none; border-right: none;
    font-family: var(--font);
}

.tab:hover { color: var(--text-2); }

.tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* ============================================================
   PROGRESS BAR
   ============================================================ */
.progress-container {
    width: 100%;
    height: 6px;
    background: var(--surface-3);
    border-radius: 999px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--accent);
    border-radius: 999px;
    transition: width .5s ease;
}

/* ============================================================
   LOG VIEWER
   ============================================================ */
.chat-log {
    background: var(--surface-2);
    color: var(--text-2);
    padding: 16px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    height: 360px;
    overflow-y: auto;
    font-family: var(--mono);
    font-size: 12px;
    line-height: 1.7;
    white-space: pre-wrap;
}

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,.08); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,.14); }

/* ============================================================
   LOADER
   ============================================================ */
.loader {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    animation: spin .8s linear infinite;
}

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

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
    .sidebar { width: 56px; min-width: 56px; }
    .nav a { width: 44px; height: 44px; }
    .nav a span { display: none; }
    .main { padding: 16px; }
}

/* ============================================================
   UTILITIES
   ============================================================ */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: 8px; }
.gap-md { gap: 16px; }
.gap-lg { gap: 24px; }
.mt-sm { margin-top: 8px; }
.mt-md { margin-top: 16px; }
.mt-lg { margin-top: 24px; }
.mb-md { margin-bottom: 16px; }
.text-muted { color: var(--text-2); }
.text-sm { font-size: 13px; }
.fw-600 { font-weight: 600; }
.mono { font-family: var(--mono); }
