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

:root {
    --ai-purple:      #6A1B9A;
    --ai-purple-dark: #4A148C;
    --primary:        #1565C0;
    --primary-light:  #1976D2;
    --primary-dark:   #0D47A1;
    --primary-text:   #FFFFFF;
    --accent:         #EF6C00;
    --success:        #2E7D32;
    --success-bg:     #E8F5E9;
    --success-border: #A5D6A7;
    --warning:        #E65100;
    --warning-bg:     #FFF3E0;
    --warning-border: #FFCC80;
    --error:          #C62828;
    --error-bg:       #FFEBEE;
    --error-border:   #EF9A9A;
    --surface:        #FFFFFF;
    --background:     #F5F5F5;
    --border:         #BDBDBD;
    --border-light:   #E0E0E0;
    --text-primary:   #212121;
    --text-secondary: #616161;
    --text-disabled:  #9E9E9E;
    --text-on-primary:#FFFFFF;
    --nav-bg:         #1565C0;
    --row-hover:      #F5F5F5;
    --row-selected:   #E3F2FD;
}

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

body {
    font-family: 'Roboto', sans-serif;
    background: var(--background);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5;
    min-height: 100vh;
}

/* ── Navigation ─────────────────────────────────────────── */
.nav {
    background: var(--nav-bg);
    color: var(--text-on-primary);
    display: flex;
    align-items: center;
    padding: 0 24px;
    height: 56px;
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid var(--primary-dark);
}

.nav-brand {
    font-size: 18px;
    font-weight: 500;
    color: var(--text-on-primary);
    text-decoration: none;
    margin-right: 32px;
    white-space: nowrap;
}

.nav-links {
    display: flex;
    gap: 4px;
    align-items: center;
    flex: 1;
}

.nav-link {
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
}
.nav-link:hover { background: rgba(255,255,255,0.15); color: #fff; }
.nav-link.active { background: rgba(255,255,255,0.2); color: #fff; }
.nav-link-back { color: rgba(255,255,255,0.6); border-right: 1px solid rgba(255,255,255,0.2); margin-right: 8px; padding-right: 20px; }
.nav-link-back:hover { background: rgba(255,255,255,0.1); color: rgba(255,255,255,0.9); }

.nav-right {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-left: auto;
}

/* ── Unified nav dropdown (.nav-dd) ──────────────────────── */
.nav-dd {
    position: relative;
}
.nav-dd-btn {
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.3);
    color: #fff;
    padding: 7px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    font-family: 'Roboto', sans-serif;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    line-height: 1.4;
}
.nav-dd-btn:hover { background: rgba(255,255,255,0.25); }
.nav-dd-list {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    min-width: 160px;
    z-index: 200;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.nav-dd-list.open { display: block; }
.nav-dd-item {
    display: block;
    padding: 10px 16px;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 14px;
    cursor: pointer;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    font-family: 'Roboto', sans-serif;
    white-space: nowrap;
}
.nav-dd-item:hover { background: var(--row-hover); }
.nav-dd-item.active { font-weight: 500; color: var(--primary); }
.nav-dd-divider { border: none; border-top: 1px solid var(--border-light); margin: 4px 0; }

/* ── Layout ─────────────────────────────────────────────── */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 24px;
}

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

/* ── Cards ──────────────────────────────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: 4px;
    padding: 20px;
    margin-bottom: 16px;
}
.card-title {
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 16px;
    color: var(--text-primary);
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    font-family: 'Roboto', sans-serif;
    white-space: nowrap;
}
.btn-primary   { background: var(--primary);  color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-accent    { background: var(--accent);   color: #fff; }
.btn-accent:hover  { background: #BF360C; }
.btn-outlined  { background: transparent; border: 1px solid var(--border); color: var(--text-primary); }
.btn-outlined:hover { background: var(--row-hover); }
.btn-danger    { background: var(--error);  color: #fff; border: 1px solid var(--error);}
.btn-danger:hover  { background: #B71C1C; }
.btn-success   { background: var(--success); color: #fff; }
.btn-success:hover { background: #1B5E20; }
.btn-ai        { background: var(--ai-purple); color: #fff; }
.btn-ai:hover  { background: var(--ai-purple-dark); }
.btn-sm { padding: 4px 10px; font-size: 13px; }
.btn-icon { padding: 6px 10px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Table ──────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
thead th {
    background: #FAFAFA;
    border-bottom: 2px solid var(--border-light);
    padding: 10px 12px;
    text-align: left;
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--border-light); }
tbody tr:hover { background: var(--row-hover); }
tbody tr.selected { background: var(--row-selected); }
tbody td { padding: 10px 12px; vertical-align: middle; }
tfoot td { padding: 10px 12px; font-weight: 500; border-top: 2px solid var(--border-light); }

.actions-cell { white-space: nowrap; display: flex; gap: 6px; }

/* ── Pagination ─────────────────────────────────────────── */
.pagination {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 16px;
    justify-content: center;
}
.pagination a, .pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    border: 1px solid var(--border-light);
    border-radius: 4px;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 13px;
}
.pagination a:hover { background: var(--row-hover); }
.pagination .current { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination .disabled { color: var(--text-disabled); pointer-events: none; }

/* ── Forms ──────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-row { display: flex; gap: 16px; }
.form-row .form-group { flex: 1; }
label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    line-height: 22px;
}
input[type=text], input[type=password], input[type=number],
input[type=date], input[type=email], select, textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 14px;
    font-family: 'Roboto', sans-serif;
    color: var(--text-primary);
    background: var(--surface);
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
}
input[type=checkbox] { width: auto; }
.form-hint { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }
.form-error { font-size: 12px; color: var(--error); margin-top: 4px; }

/* ── Alerts ─────────────────────────────────────────────── */
.alert {
    padding: 12px 16px;
    border-radius: 4px;
    border: 1px solid;
    margin-bottom: 16px;
    font-size: 14px;
}
.alert-success { background: var(--success-bg); border-color: var(--success-border); color: var(--success); }
.alert-error   { background: var(--error-bg);   border-color: var(--error-border);   color: var(--error); }
.alert-info    { background: #E3F2FD;            border-color: #90CAF9;              color: #0D47A1; }

/* ── Tabs ───────────────────────────────────────────────── */
.tabs { display: flex; border-bottom: 2px solid var(--border-light); margin-bottom: 20px; }
.tab-btn {
    padding: 10px 20px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    font-family: 'Roboto', sans-serif;
}
.tab-btn:hover { color: var(--primary); background: rgba(21,101,192,0.05); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Modal ──────────────────────────────────────────────── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 300;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
    background: var(--surface);
    border-radius: 4px;
    border: 1px solid var(--border-light);
    width: 100%;
    max-width: 640px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}
.modal-lg { max-width: 860px; }
.modal-header {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-light);
    flex-shrink: 0;
}
.modal-title { font-size: 16px; font-weight: 500; flex: 1; }
.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 20px;
    color: var(--text-secondary);
    padding: 0 4px;
    line-height: 1;
}
.modal-close:hover { color: var(--text-primary); }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 20px;
    border-top: 1px solid var(--border-light);
    flex-shrink: 0;
}

/* ── Login page ─────────────────────────────────────────── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--background);
}
.login-card {
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: 4px;
    padding: 40px 36px;
    width: 100%;
    max-width: 380px;
}
.login-logo {
    text-align: center;
    margin-bottom: 28px;
}
.login-logo h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: -0.5px;
}
.login-logo p { color: var(--text-secondary); font-size: 13px; margin-top: 4px; }

/* ── Settings sections ──────────────────────────────────── */
.section-title {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-light);
}

/* ── Chips / badges ─────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-error   { background: var(--error-bg);   color: var(--error); }
.badge-info    { background: #E3F2FD; color: var(--primary); }

/* ── Utilities ──────────────────────────────────────────── */
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-disabled); font-size: 13px; }
.mt-0 { margin-top: 0; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-0 { margin-bottom: 0; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.gap-8 { gap: 8px; }
.gap-16 { gap: 16px; }
.w-full { width: 100%; }
.font-bold { font-weight: 700; }
.font-500 { font-weight: 500; }

.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-secondary);
}
.empty-state p { font-size: 15px; margin-bottom: 6px; }
.empty-state small { font-size: 13px; color: var(--text-disabled); }

hr.divider { border: none; border-top: 1px solid var(--border-light); margin: 20px 0; }

/* ── Extra utilities ─────────────────────────────────────── */
.m-0  { margin: 0; }
.mt-4 { margin-top: 4px; }
.mt-24 { margin-top: 24px; }
.ml-auto { margin-left: auto; }
.min-w-180 { min-width: 180px; }
.flex-2 { flex: 2; }
.d-none { display: none; }
.d-inline { display: inline; }
.text-sm { font-size: 13px; }
.pb-2 { padding-bottom: 2px; }
.link-primary { color: var(--primary); }
.textarea-resize-v { resize: vertical; }
.section-title.mt-8 { margin-top: 8px; }

/* ── Page header ─────────────────────────────────────────── */
.page-header { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }

/* ── Cards ───────────────────────────────────────────────── */
.card-flush { padding: 0; }

/* ── Forms extras ────────────────────────────────────────── */
.form-inline   { display: inline; }
.input-readonly { background: #F5F5F5; }
.input-sm  { padding: 4px 8px; font-size: 13px; border: 1px solid var(--border); border-radius: 4px;
             width: 130px; }
.select-sm { padding: 4px 6px; font-size: 13px; border: 1px solid var(--border); border-radius: 4px; }

/* ── Settings extras ─────────────────────────────────────── */
.mb-24 { margin-bottom: 24px; }
.ml-8  { margin-left: 8px; }
.max-w-480 { max-width: 480px; }
.max-w-400 { max-width: 400px; }
.lang-options { display: flex; flex-direction: column; gap: 8px; }
.lang-btn     { justify-content: flex-start; gap: 10px; }
.emoji-icon   { font-size: 18px; }
.install-wrap { max-width: 520px; width: 100%; padding: 0 16px; }
.text-center  { text-align: center; }

/* ── Admin / Users ──────────────────────────────────────── */
.badge-admin       { background: var(--primary); color: #fff; }
.nav-dd-item-admin { font-weight: 500; color: var(--primary); }
.ml-8  { margin-left: 8px; }
.text-disabled { color: var(--text-disabled); }
.max-w-560 { max-width: 560px; }

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE – tablets & large phones (≤ 768px)
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
    .container { padding: 16px; }

    /* Nav: single compact row, brand hidden on small screens */
    .nav {
        padding: 0 10px;
        height: 48px;
        flex-wrap: nowrap;
        gap: 0;
    }
    .nav-brand  { display: none; }
    .nav-links  { flex: 1; gap: 0; overflow: visible; padding: 0; border-top: none; }
    .nav-right  { flex-shrink: 0; gap: 4px; margin-left: auto; }
    .nav-link   { padding: 6px 10px; font-size: 13px; white-space: nowrap; }

    /* Forms */
    .form-row   { flex-direction: column; gap: 8px; }

    /* Modals — wider on tablet */
    .modal      { max-width: calc(100vw - 32px); }

    /* Summary */
    .summary-bar { gap: 16px; }
}

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE – smartphones (≤ 480px)
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 480px) {
    .container  { padding: 10px; }
    .page-title { font-size: 17px; }
    .card       { padding: 12px; }

    /* Nav */
    .nav-brand  { font-size: 15px; }
    .nav-link   { font-size: 12px; padding: 5px 8px; }
    .nav-dd-btn { font-size: 12px; padding: 5px 8px; }

    /* Buttons */
    .btn        { font-size: 13px; padding: 7px 11px; }
    .btn-sm     { font-size: 12px; padding: 3px 8px; }
    .toolbar    { gap: 6px; }
    .toolbar .btn { flex: 1 1 auto; justify-content: center; }

    /* Tables — horizontal scroll for non-card tables */
    .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 4px; }
    thead th    { font-size: 11px; padding: 8px; }
    tbody td    { padding: 8px; font-size: 13px; }
    tfoot td    { padding: 8px; }

    /* Modals — slide up from bottom */
    .modal-overlay  { padding: 0; align-items: flex-end; }
    .modal          {
        max-width: 100%;
        border-radius: 14px 14px 0 0;
        max-height: 92vh;
    }
    .modal-body     { padding: 14px; }
    .modal-header,
    .modal-footer   { padding: 12px 14px; }

    /* Forms */
    .form-row       { flex-direction: column; gap: 0; }

    /* Cards */
    .card           { border-radius: 6px; }

    /* Page header buttons */
    .page-header    { gap: 8px; }

    /* Settings tabs */
    .tabs           { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .tab-btn        { white-space: nowrap; padding: 10px 14px; }

    /* Pagination */
    .pagination a,
    .pagination span { min-width: 28px; height: 28px; font-size: 12px; padding: 0 6px; }

    /* Login card */
    .login-card     { padding: 28px 20px; }
    .install-wrap   { padding: 0 10px; }
}
