/* ============================================================
   app.css — medicos.productosm.com
   ============================================================ */

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

:root {
    --color-primary:    #1a6fb5;
    --color-primary-bg: #e8f1fb;
    --color-primary-text: #0c447c;

    --sidebar-w: 220px;
    --topbar-h:  0px;

    --bg:        #f4f5f7;
    --surface:   #ffffff;
    --border:    rgba(0,0,0,0.09);
    --border-md: rgba(0,0,0,0.15);

    --text:      #1a1a1a;
    --text-muted:#6b7280;
    --text-hint: #9ca3af;

    --success-bg:  #ecfdf5; --success-text: #065f46;
    --warning-bg:  #fffbeb; --warning-text: #92400e;
    --danger-bg:   #fef2f2; --danger-text:  #991b1b;
    --info-bg:     #eff6ff; --info-text:    #1e40af;

    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
}

/* ---- LAYOUT ---- */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ---- SIDEBAR ---- */
.sidebar {
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 0.5px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 1.25rem;
    border-bottom: 0.5px solid var(--border);
}
.logo-icon {
    width: 34px; height: 34px;
    background: var(--color-primary-bg);
    border-radius: var(--radius-md);
    display: flex; align-items: center; justify-content: center;
    color: var(--color-primary);
    font-size: 18px;
    flex-shrink: 0;
}
.logo-title { font-size: 13px; font-weight: 600; color: var(--text); line-height: 1.2; }
.logo-sub   { font-size: 11px; color: var(--text-muted); }

.sidebar-nav {
    flex: 1;
    padding: 0.75rem 0.5rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 7px 10px;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    font-size: 13px;
    text-decoration: none;
    transition: background 0.12s, color 0.12s;
}
.nav-item i { font-size: 16px; flex-shrink: 0; }
.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.active { background: var(--color-primary-bg); color: var(--color-primary-text); font-weight: 500; }

.nav-badge {
    margin-left: auto;
    background: #fee2e2;
    color: #991b1b;
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 10px;
    font-weight: 600;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0.9rem 1rem;
    border-top: 0.5px solid var(--border);
}
.user-avatar {
    width: 30px; height: 30px;
    border-radius: 50%;
    background: var(--color-primary-bg);
    color: var(--color-primary-text);
    font-size: 11px; font-weight: 600;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.user-name { font-size: 12px; font-weight: 500; color: var(--text); }
.user-role { font-size: 11px; color: var(--text-muted); text-transform: capitalize; }
.user-info { flex: 1; min-width: 0; }
.logout-btn {
    color: var(--text-hint);
    font-size: 17px;
    text-decoration: none;
    display: flex; align-items: center;
}
.logout-btn:hover { color: #991b1b; }

/* ---- MAIN ---- */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    min-height: 100vh;
}
.page-inner {
    padding: 1.75rem 2rem;
    max-width: 1200px;
}

/* ---- PAGE HEADER ---- */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    gap: 1rem;
}
.page-title  { font-size: 20px; font-weight: 600; color: var(--text); }
.page-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.page-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }

/* ---- METRIC CARDS ---- */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 1.5rem;
}
.metric-card {
    background: var(--surface);
    border: 0.5px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1rem 1.25rem;
}
.metric-label { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.metric-value { font-size: 24px; font-weight: 600; color: var(--text); line-height: 1; }
.metric-sub   { font-size: 11px; color: var(--text-hint); margin-top: 5px; }
.metric-card.success .metric-value { color: #065f46; }
.metric-card.danger  .metric-value { color: #991b1b; }
.metric-card.info    .metric-value { color: var(--color-primary); }

/* ---- CARDS ---- */
.card {
    background: var(--surface);
    border: 0.5px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
}
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 0.5px solid var(--border);
}
.card-title { font-size: 14px; font-weight: 500; color: var(--text); }
.card-action {
    font-size: 12px;
    color: var(--color-primary);
    text-decoration: none;
    cursor: pointer;
}

/* ---- TABLES ---- */
.table-wrap { overflow-x: auto; }
table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.data-table th {
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0 10px 10px;
    border-bottom: 0.5px solid var(--border-md);
    white-space: nowrap;
}
.data-table td {
    padding: 9px 10px;
    border-bottom: 0.5px solid var(--border);
    color: var(--text);
    vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg); }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table tfoot td {
    font-weight: 600;
    border-top: 1px solid var(--border-md);
    border-bottom: none;
    background: var(--bg);
}

/* ---- BADGES ---- */
.badge {
    display: inline-flex;
    align-items: center;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 20px;
    font-weight: 500;
    white-space: nowrap;
}
.badge-success  { background: var(--success-bg); color: var(--success-text); }
.badge-warning  { background: var(--warning-bg); color: var(--warning-text); }
.badge-danger   { background: var(--danger-bg);  color: var(--danger-text);  }
.badge-info     { background: var(--info-bg);    color: var(--info-text);    }
.badge-neutral  { background: var(--bg);         color: var(--text-muted);   }

/* ---- BUTTONS ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    font-size: 13px;
    font-weight: 500;
    border-radius: var(--radius-md);
    border: 0.5px solid var(--border-md);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    text-decoration: none;
    transition: background 0.1s;
    white-space: nowrap;
}
.btn:hover { background: var(--bg); }
.btn-primary {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}
.btn-primary:hover { background: #155d9e; }
.btn-success { background: var(--success-bg); color: var(--success-text); border-color: #a7f3d0; }
.btn-danger  { background: var(--danger-bg);  color: var(--danger-text);  border-color: #fecaca; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn i { font-size: 15px; }

/* ---- FORMS ---- */
.form-group { margin-bottom: 1rem; }
.form-label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 5px;
}
.form-control {
    width: 100%;
    padding: 8px 12px;
    font-size: 13px;
    border: 0.5px solid var(--border-md);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--text);
    transition: border-color 0.15s;
    font-family: inherit;
}
.form-control:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(26,111,181,0.12);
}
textarea.form-control { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-hint { font-size: 11px; color: var(--text-hint); margin-top: 4px; }

/* ---- ALERTS ---- */
.alert {
    padding: 10px 14px;
    border-radius: var(--radius-md);
    font-size: 13px;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}
.alert-success { background: var(--success-bg); color: var(--success-text); }
.alert-danger  { background: var(--danger-bg);  color: var(--danger-text);  }
.alert-warning { background: var(--warning-bg); color: var(--warning-text); }
.alert-info    { background: var(--info-bg);    color: var(--info-text);    }

/* ---- STATUS BADGE CON DOT ---- */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    padding: 3px 10px;
    border-radius: 20px;
    font-weight: 500;
}
.status-badge .dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: currentColor;
}
.status-open   { background: var(--success-bg); color: var(--success-text); }
.status-closed { background: var(--bg);         color: var(--text-muted); }

/* ---- MONTH SELECTOR ---- */
.month-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--surface);
    border: 0.5px solid var(--border-md);
    border-radius: var(--radius-md);
    padding: 6px 12px;
    font-size: 13px;
    cursor: pointer;
}

/* ---- GRID HELPERS ---- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1.25rem; }

/* ---- DIVIDER ---- */
.divider { border: none; border-top: 0.5px solid var(--border); margin: 1rem 0; }

/* ---- CALENDAR (turnos) ---- */
.cal-grid {
    display: grid;
    grid-template-columns: 100px repeat(31, 1fr);
    border: 0.5px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    font-size: 11px;
}
.cal-header {
    background: var(--bg);
    padding: 4px 2px;
    text-align: center;
    border-right: 0.5px solid var(--border);
    border-bottom: 0.5px solid var(--border-md);
    font-weight: 600;
    color: var(--text-muted);
}
.cal-row-label {
    padding: 4px 8px;
    background: var(--bg);
    border-right: 0.5px solid var(--border-md);
    border-bottom: 0.5px solid var(--border);
    font-weight: 500;
    color: var(--text-muted);
    display: flex;
    align-items: center;
}
.cal-cell {
    padding: 3px 2px;
    text-align: center;
    border-right: 0.5px solid var(--border);
    border-bottom: 0.5px solid var(--border);
    cursor: pointer;
    min-height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 500;
    color: var(--text-muted);
}
.cal-cell:hover { background: var(--color-primary-bg); color: var(--color-primary-text); }
.cal-cell.assigned { background: var(--info-bg); color: var(--info-text); }
.cal-cell.empty { background: transparent; cursor: default; }

/* ---- UTILS ---- */
.text-muted    { color: var(--text-muted); }
.text-small    { font-size: 12px; }
.text-danger   { color: #991b1b; }
.text-success  { color: #065f46; }
.text-right    { text-align: right; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 1rem; }
.ml-auto { margin-left: auto; }

/* ---- RESPONSIVE ---- */
@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); }
    .main-content { margin-left: 0; }
    .page-inner { padding: 1rem; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
}
