/**
 * ARCHITECTURAL DECISION RECORD (ADR) & PRD TRACEABILITY
 * =======================================================
 * @id ADR-014-UNIVERSAL-DESIGN-SYSTEM-CSS
 * @date 2026-10-14
 * @status ACCEPTED
 * @decision Single unified CSS design system shared between Admin and User applications.
 * @palette
 *   - Base: Black (#09090b), White (#ffffff), Neutral Grays (#18181b, #27272a, #71717a, #e4e4e7, #f4f4f5, #f8fafc).
 *   - Accent Green: Strictly restricted to 10% (call-to-actions, successful status badges, active indicators).
 *   - Admin: theme-dark / body.theme-admin (Pure Black + Grays + 10% Green accents).
 *   - User: theme-light / body.theme-user (Pure White + Soft Grays + 10% Green accents).
 *   - High Density: Micro-paddings, compact tables, no external labels (placeholders as labels).
 */

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

/* --- SHARED CSS VARIABLES & TOKENS --- */
:root {
    --font-stack: 'Manrope', -apple-system, BlinkMacSystemFont, sans-serif;
    
    /* 10% Controlled Green Accents */
    --green-accent: #16a34a;
    --green-accent-bright: #22c55e;
    --green-accent-dark: #14532d;
    --green-badge-bg: #dcfce7;
    --green-badge-text: #15803d;

    /* Semantic Helpers */
    --semantic-amber: #d97706;
    --semantic-red: #dc2626;
    --semantic-red-bg: #fee2e2;
}

/* --- THEME BLACK (ADMIN CONSOLE) --- */
body.theme-admin {
    --bg-base: #09090b;
    --bg-surface: #121214;
    --bg-card: #18181b;
    --border-subtle: #27272a;
    --border-highlight: #3f3f46;
    --text-main: #f4f4f5;
    --text-muted: #a1a1aa;
    --input-bg: #09090b;
    --btn-secondary-bg: #27272a;
    --btn-secondary-text: #f4f4f5;
    --btn-secondary-hover: #3f3f46;
    --table-header-bg: #121214;
    --badge-green-bg: #14532d;
    --badge-green-text: #bbf7d0;
}

/* --- THEME WHITE (USER PORTAL) --- */
body.theme-user {
    --bg-base: #ffffff;
    --bg-surface: #ffffff;
    --bg-card: #ffffff;
    --border-subtle: #e4e4e7;
    --border-highlight: #d4d4d8;
    --text-main: #09090b;
    --text-muted: #71717a;
    --input-bg: #ffffff;
    --btn-secondary-bg: #f4f4f5;
    --btn-secondary-text: #09090b;
    --btn-secondary-hover: #e4e4e7;
    --table-header-bg: #fafafa;
    --badge-green-bg: #dcfce7;
    --badge-green-text: #15803d;
}

/* --- GLOBAL RESET & TYPOGRAPHY --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: var(--font-stack);
    -webkit-font-smoothing: antialiased;
}

body {
    background-color: var(--bg-base);
    color: var(--text-main);
    font-size: 13px;
    line-height: 1.4;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* --- HEADER --- */
header {
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-subtle);
    padding: 8px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    min-width: 0;
}

.brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 14px;
    letter-spacing: -0.02em;
    color: var(--text-main);
    flex-shrink: 0;
}

.brand-dot {
    width: 6px;
    height: 6px;
    background-color: var(--green-accent-bright);
    border-radius: 50%;
    display: inline-block;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.credit-badge {
    background-color: var(--bg-card);
    border: 1px solid var(--border-subtle);
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}

.credit-badge .icon-credit {
    color: var(--green-accent-bright);
}

/* --- LUCIDE SVG ICONS --- */
.icon {
    width: 16px;
    height: 16px;
    stroke-width: 2;
    stroke: currentColor;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
    vertical-align: middle;
    display: inline-block;
    flex-shrink: 0;
}

/* --- TABS NAVIGATION COM ROLAGEM PROTEGIDA & TOUCH SCROLL --- */
.tabs-nav {
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    padding: 0 16px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
    width: 100%;
}

.tabs-nav::-webkit-scrollbar {
    height: 3px;
}
.tabs-nav::-webkit-scrollbar-thumb {
    background: var(--border-highlight);
    border-radius: 3px;
}

.tab-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 13px;
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    transition: color 0.15s, border-color 0.15s;
}

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

/* 10% Green Accent on Active Tab */
.tab-btn.active {
    color: var(--text-main);
    border-bottom-color: var(--green-accent-bright);
}

/* --- MAIN CONTAINER & PANELS --- */
main {
    padding: 12px 16px;
    flex: 1;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.grid-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 8px;
    margin-bottom: 12px;
}

.stat-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-subtle);
    padding: 10px 12px;
    border-radius: 4px;
}

.stat-title {
    color: var(--text-muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 20px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--text-main);
}

.stat-value.highlight-green {
    color: var(--green-accent-bright);
}

.panel {
    background-color: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 4px;
    padding: 12px;
    margin-bottom: 12px;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-subtle);
    padding-bottom: 8px;
    margin-bottom: 10px;
    font-weight: 600;
    font-size: 13px;
    color: var(--text-main);
}

/* --- COMPACT INPUTS (PLACEHOLDERS AS LABELS) --- */
.input-row {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.input-compact, textarea.input-compact, select.input-compact {
    background-color: var(--input-bg);
    border: 1px solid var(--border-subtle);
    color: var(--text-main);
    padding: 8px 10px;
    border-radius: 4px;
    font-size: 13px;
    outline: none;
    flex: 1;
    min-width: 140px;
    transition: border-color 0.15s;
}

.input-compact:focus, textarea.input-compact:focus, select.input-compact:focus {
    border-color: var(--border-highlight);
}

textarea.input-compact {
    resize: vertical;
    min-height: 80px;
}

.input-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 11.5px;
    font-weight: 700;
    margin-bottom: 4px;
    color: var(--text-main);
}

.input-help {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
    line-height: 1.35;
}

.form-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 4px;
    padding: 10px 12px;
    flex: 1;
    min-width: 260px;
}

.info-banner {
    background: var(--bg-surface);
    border-left: 3px solid var(--green-accent);
    padding: 8px 12px;
    border-radius: 0 4px 4px 0;
    margin-bottom: 12px;
    font-size: 11.5px;
    color: var(--text-muted);
    line-height: 1.45;
}

.info-banner strong {
    color: var(--text-main);
}

/* --- ACTION BUTTONS (10% GREEN FOR PRIMARY CTA) --- */
.btn {
    background-color: var(--btn-secondary-bg);
    color: var(--btn-secondary-text);
    border: 1px solid var(--border-subtle);
    padding: 8px 14px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background-color 0.15s;
    text-decoration: none;
}

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

/* 10% Green Accent on Primary Actions */
.btn-primary {
    background-color: var(--green-accent);
    color: #ffffff;
    border-color: var(--green-accent);
}

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

.btn-danger {
    background-color: #7f1d1d;
    border-color: #991b1b;
    color: #fecaca;
}

.btn-danger:hover {
    background-color: #991b1b;
}

/* --- COMPACT DATA TABLES --- */
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

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

th {
    color: var(--text-muted);
    font-weight: 600;
    background-color: var(--table-header-bg);
}

/* --- DESCRIPTIONS & LEARN MORE (AUTO-DIDACTIC UI) --- */
.panel-desc {
    font-size: 11.5px;
    color: var(--text-muted);
    margin-bottom: 10px;
    line-height: 1.4;
}

.learn-more-link {
    color: var(--green-accent);
    text-decoration: underline;
    cursor: pointer;
    font-weight: 600;
    margin-left: 4px;
    display: inline-flex;
    align-items: center;
    gap: 2px;
}

.learn-more-link:hover {
    color: var(--green-accent-bright);
}

/* Modal Explicativo (Saiba Mais) */
#explain-modal {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(9, 9, 11, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2500;
}

.explain-card {
    background: var(--bg-card);
    border: 1px solid var(--border-highlight);
    color: var(--text-main);
    padding: 18px 20px;
    border-radius: 6px;
    width: 100%;
    max-width: 480px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0,0,0,0.4);
}

.explain-title {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-subtle);
    padding-bottom: 8px;
}

.explain-body {
    font-size: 12.5px;
    line-height: 1.5;
    color: var(--text-main);
}

.explain-body p {
    margin-bottom: 8px;
}

.explain-body ul {
    margin: 8px 0 12px 18px;
}

.explain-body li {
    margin-bottom: 4px;
}

.explain-outcome {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    padding: 8px 10px;
    border-radius: 4px;
    margin-top: 8px;
    font-size: 11.5px;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-green { 
    background: var(--badge-green-bg); 
    color: var(--badge-green-text); 
}
.badge-amber { 
    background: #78350f; 
    color: #fde68a; 
}
.badge-red { 
    background: #7f1d1d; 
    color: #fecaca; 
}

/* --- AUTH MODAL --- */
#auth-modal {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(9, 9, 11, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.auth-card {
    background: #ffffff;
    color: #09090b;
    padding: 20px;
    border-radius: 6px;
    width: 100%;
    max-width: 340px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
}

.auth-card .input-compact {
    background: #f8fafc;
    border-color: #e2e8f0;
    color: #09090b;
}

/* Toast */
#toast {
    position: fixed;
    bottom: 16px;
    right: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-highlight);
    color: var(--text-main);
    padding: 8px 14px;
    border-radius: 4px;
    font-size: 12px;
    display: none;
    z-index: 2000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}
