/* ============================================
   clinica.css — Sistema de Consulta de Pacientes
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display:ital@0;1&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,300&display=swap');

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

:root {
    --bg:       #0f1117;
    --surface:  #181c27;
    --surface2: #1e2436;
    --border:   #2a3048;
    --accent:   #4f8ef7;
    --accent2:  #7ee8a2;
    --warn:     #f7a94f;
    --danger:   #f76f6f;
    --text:     #e8ecf4;
    --muted:    #7a849e;
    --radius:   12px;
    --shadow:   0 4px 24px rgba(0,0,0,.4);
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'DM Sans', sans-serif;
    min-height: 100vh;
    line-height: 1.5;
}

/* ---- HEADER ---- */
.header {
    background: linear-gradient(135deg, #0d1b3e 0%, #0f1117 60%);
    border-bottom: 1px solid var(--border);
    padding: 20px 32px;
    display: flex;
    align-items: center;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 100;
}
.header-logo {
    width: 42px; height: 42px;
    background: linear-gradient(135deg, var(--accent), #2563eb);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; flex-shrink: 0;
}
.header-brand h1 {
    font-family: 'DM Serif Display', serif;
    font-size: 1.35rem;
    letter-spacing: -0.02em;
}
.header-brand p { font-size: .75rem; color: var(--muted); margin-top: 1px; }
.header-stats {
    margin-left: auto;
    display: flex;
    gap: 12px;
}
.stat-chip {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 5px 14px;
    font-size: .73rem;
    color: var(--muted);
    white-space: nowrap;
}
.stat-chip strong { color: var(--accent); font-weight: 600; }

/* ---- LAYOUT ---- */
.layout {
    display: grid;
    grid-template-columns: 360px 1fr;
    height: calc(100vh - 83px);
    overflow: hidden;
}

/* ---- SIDEBAR ---- */
.sidebar {
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.search-box {
    padding: 16px;
    border-bottom: 1px solid var(--border);
}
.search-input-wrap { position: relative; }
.search-input-wrap .ico {
    position: absolute;
    left: 13px; top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    pointer-events: none;
}
#searchInput {
    width: 100%;
    padding: 11px 14px 11px 40px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: inherit;
    font-size: .9rem;
    outline: none;
    transition: border-color .18s;
}
#searchInput:focus { border-color: var(--accent); }
#searchInput::placeholder { color: var(--muted); }
.search-meta {
    margin-top: 8px;
    font-size: .72rem;
    color: var(--muted);
    display: flex;
    align-items: center;
    gap: 6px;
}
.spinner {
    width: 12px; height: 12px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .6s linear infinite;
    display: none;
}
.spinner.active { display: block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- RESULTS LIST ---- */
#resultsList {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}
#resultsList::-webkit-scrollbar { width: 4px; }
#resultsList::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.result-item {
    padding: 11px 14px;
    border-radius: 10px;
    cursor: pointer;
    border: 1px solid transparent;
    margin-bottom: 2px;
    transition: background .14s, border-color .14s;
}
.result-item:hover { background: var(--surface2); border-color: var(--border); }
.result-item.active {
    background: rgba(79,142,247,.1);
    border-color: rgba(79,142,247,.35);
}
.result-item h3 {
    font-size: .86rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.result-item .sub {
    font-size: .72rem;
    color: var(--muted);
    margin-top: 3px;
}
.result-tags {
    margin-top: 5px;
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}
.tag {
    font-size: .63rem;
    padding: 2px 7px;
    border-radius: 10px;
    font-weight: 500;
}
.tag-arq  { background: rgba(126,232,162,.12); color: var(--accent2); }
.tag-at   { background: rgba(79,142,247,.12);  color: var(--accent);  }

.list-placeholder {
    text-align: center;
    padding: 48px 20px;
    color: var(--muted);
}
.list-placeholder .ico { font-size: 2.2rem; opacity: .35; margin-bottom: 10px; }
.list-placeholder p  { font-size: .82rem; }

/* ---- MAIN CONTENT ---- */
.main {
    overflow-y: auto;
    background: var(--bg);
}
.main::-webkit-scrollbar { width: 6px; }
.main::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* Empty state */
#emptyState {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--muted);
    text-align: center;
    padding: 40px;
}
#emptyState .big { font-size: 3.5rem; opacity: .2; margin-bottom: 14px; }
#emptyState h2 {
    font-family: 'DM Serif Display', serif;
    font-size: 1.4rem;
    opacity: .45;
    margin-bottom: 6px;
}
#emptyState p { font-size: .82rem; opacity: .35; }

/* ---- PATIENT DETAIL ---- */
#detail { padding: 32px 36px; display: none; }

.detail-header {
    display: flex;
    align-items: flex-start;
    gap: 20px;
    margin-bottom: 28px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border);
}
.avatar {
    width: 62px; height: 62px;
    border-radius: 13px;
    background: linear-gradient(135deg, var(--accent), #2563eb);
    display: flex; align-items: center; justify-content: center;
    font-family: 'DM Serif Display', serif;
    font-size: 1.5rem;
    color: #fff;
    flex-shrink: 0;
    overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.detail-name h2 {
    font-family: 'DM Serif Display', serif;
    font-size: 1.65rem;
    letter-spacing: -0.02em;
    line-height: 1.1;
}
.detail-name .badges {
    margin-top: 8px;
    display: flex;
    gap: 7px;
    flex-wrap: wrap;
}
.badge {
    font-size: .68rem;
    padding: 3px 10px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: var(--surface2);
    color: var(--muted);
}
.badge.id { color: var(--accent); border-color: rgba(79,142,247,.3); }

/* ---- CARDS ---- */
.cards { display: grid; gap: 18px; }
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.card-header {
    padding: 13px 18px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
}
.card-header .ico { font-size: .95rem; }
.card-header h3 {
    font-size: .78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--muted);
}
.card-header .count {
    margin-left: auto;
    font-size: .68rem;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 2px 9px;
    color: var(--muted);
}

/* Info grid */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
}
.info-cell {
    padding: 13px 18px;
    border-bottom: 1px solid var(--border);
    border-right: 1px solid var(--border);
}
.info-cell:last-child, .info-cell.full { border-right: none; }
.info-cell.full { grid-column: 1 / -1; }
.info-cell label {
    font-size: .67rem;
    text-transform: uppercase;
    letter-spacing: .09em;
    color: var(--muted);
    display: block;
    margin-bottom: 4px;
}
.info-cell span {
    font-size: .86rem;
    font-weight: 500;
    word-break: break-word;
}
.info-cell span.empty { color: var(--muted); font-style: italic; font-weight: 300; }

/* Stats row */
.stats-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
}
.stat-block {
    padding: 20px;
    text-align: center;
    border-right: 1px solid var(--border);
}
.stat-block:last-child { border-right: none; }
.stat-block .val {
    font-family: 'DM Serif Display', serif;
    font-size: 2.2rem;
    color: var(--accent);
    display: block;
}
.stat-block .val.green { color: var(--accent2); }
.stat-block .lbl {
    font-size: .71rem;
    color: var(--muted);
    margin-top: 3px;
}

/* Files list */
.files-list { padding: 10px; }
.file-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 10px;
    border-radius: 8px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background .14s, border-color .14s;
    text-decoration: none;
    color: inherit;
    margin-bottom: 3px;
}
.file-item:hover { background: var(--surface2); border-color: var(--border); }
.file-icon {
    width: 36px; height: 36px;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.05rem;
    flex-shrink: 0;
}
.file-icon.pdf  { background: rgba(247,169,79,.1);  color: var(--warn); }
.file-icon.img  { background: rgba(126,232,162,.1); color: var(--accent2); }
.file-icon.doc  { background: rgba(79,142,247,.1);  color: var(--accent); }
.file-meta { flex: 1; min-width: 0; }
.file-meta .fname {
    font-size: .83rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.file-meta .finfo { font-size: .7rem; color: var(--muted); margin-top: 2px; }
.pasta-badge {
    font-size: .63rem;
    padding: 2px 8px;
    border-radius: 10px;
    flex-shrink: 0;
}
.pasta-badge.Arquivos { background: rgba(79,142,247,.15);  color: var(--accent);  }
.pasta-badge.Imagens  { background: rgba(126,232,162,.15); color: var(--accent2); }
.pasta-badge.GALLERY  { background: rgba(247,169,79,.15);  color: var(--warn);    }

/* Atendimentos table */
.table-wrap { overflow-x: auto; }
.at-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .83rem;
}
.at-table th {
    padding: 10px 16px;
    text-align: left;
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--muted);
    font-weight: 500;
    border-bottom: 1px solid var(--border);
    background: var(--surface2);
}
.at-table td {
    padding: 11px 16px;
    border-bottom: 1px solid var(--border);
}
.at-table tr:last-child td { border-bottom: none; }
.at-table tr:hover td { background: var(--surface2); }

/* Empty block */
.empty-block {
    padding: 24px;
    text-align: center;
    color: var(--muted);
    font-size: .82rem;
}

/* Highlight */
mark {
    background: rgba(79,142,247,.25);
    color: inherit;
    border-radius: 2px;
    padding: 0 1px;
}

/* Responsive */
@media (max-width: 900px) {
    .layout { grid-template-columns: 1fr; }
    .sidebar { max-height: 50vh; }
    .header-stats { display: none; }
    #detail { padding: 20px; }
}
