/* ============================================
   ALL MEDICAL — Admin Panel Standalone
   ============================================ */
:root {
    --primary: #0a2a5e;
    --primary-light: #1642a0;
    --accent: #d0a64a;
    --accent-light: #e6bc5e;
    --success: #28a745;
    --warning: #fd7e14;
    --danger: #dc3545;
    --info: #17a2b8;
    --gray: #6c757d;
    --text: #1a1a2e;
    --text-light: #666;
    --text-muted: #999;
    --bg: #f0f2f5;
    --bg-white: #fff;
    --bg-alt: #f7f9fc;
    --border: #e0e6ee;
    --sidebar-w: 260px;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(0,0,0,.06);
    --shadow-lg: 0 8px 24px rgba(10,42,94,.1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif; color: var(--text); background: var(--bg); line-height: 1.5; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-light); }

/* === APP LAYOUT (solo admin/cliente panel) === */
body.wp-admin .am-app, body:not(.wp-admin):not(.home):not(.page):not(.single) .am-app,
.am-login-page .am-app, .admin-page .am-app { display: flex; min-height: 100vh; height: 100vh; overflow: hidden; }
.am-app { display: flex; min-height: 100vh; }

/* === SIDEBAR === */
.am-sidebar { width: var(--sidebar-w); min-width: var(--sidebar-w); background: var(--primary); color: #fff; display: flex; flex-direction: column; height: 100vh; overflow-y: auto; position: sticky; top: 0; }
.am-sidebar-logo { padding: 1.8em 1.5em; border-bottom: 1px solid rgba(255,255,255,.1); }
.am-logo-text { font-size: 1.3em; font-weight: 800; letter-spacing: 1px; }
.am-logo-sub { display: block; font-size: .72em; opacity: .5; margin-top: .2em; letter-spacing: .5px; text-transform: uppercase; }

.am-sidebar-nav { flex: 1; padding: 1em 0; overflow-y: auto; }
.am-nav-item { display: flex; align-items: center; gap: .8em; padding: .85em 1.5em; color: rgba(255,255,255,.7); font-size: .92em; font-weight: 500; transition: all .15s; border-left: 3px solid transparent; }
.am-nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.am-nav-item.active { background: rgba(255,255,255,.12); color: var(--accent); border-left-color: var(--accent); font-weight: 600; }
.am-nav-icon { width: 22px; text-align: center; font-size: 1.1em; }
.am-nav-divider { height: 1px; background: rgba(255,255,255,.1); margin: .8em 1.5em; }

.am-sidebar-user { padding: 1em 1.5em; border-top: 1px solid rgba(255,255,255,.1); display: flex; align-items: center; justify-content: space-between; }
.am-user-name { font-weight: 600; font-size: .9em; }
.am-user-role { font-size: .75em; opacity: .6; text-transform: uppercase; letter-spacing: .5px; }
.am-logout-btn { color: rgba(255,255,255,.5); font-size: 1.2em; padding: .3em; }
.am-logout-btn:hover { color: #fff; }

/* === MAIN === */
.am-main { flex: 1; padding: 2em 2.5em; overflow-y: auto; height: 100vh; }

/* === PAGE HEADER === */
.am-page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2em; }
.am-page-header h1 { font-size: 1.8em; font-weight: 700; color: var(--primary); }
.am-header-actions { display: flex; gap: .8em; align-items: center; }

/* === KPI CARDS === */
.am-kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1.2em; margin-bottom: 2em; }
.am-kpi { background: var(--bg-white); padding: 1.5em; border-radius: var(--radius); box-shadow: var(--shadow); position: relative; overflow: hidden; border-top: 3px solid var(--border); }
.am-kpi.kpi-blue { border-top-color: var(--primary); }
.am-kpi.kpi-green { border-top-color: var(--success); }
.am-kpi.kpi-orange { border-top-color: var(--warning); }
.am-kpi.kpi-red { border-top-color: var(--danger); }
.am-kpi.kpi-gold { border-top-color: var(--accent); }
.am-kpi-label { font-size: .78em; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; font-weight: 600; }
.am-kpi-value { font-size: 2.4em; font-weight: 800; color: var(--primary); line-height: 1.1; margin: .15em 0; }
.am-kpi-sub { font-size: .82em; color: var(--text-light); }

/* === TABLE CARD === */
.am-card { background: var(--bg-white); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; margin-bottom: 2em; }
.am-card-header { display: flex; justify-content: space-between; align-items: center; padding: 1.2em 1.5em; border-bottom: 1px solid var(--border); }
.am-card-header h2 { margin: 0; font-size: 1.1em; color: var(--primary); font-weight: 700; }
.am-card-body { padding: 1.5em; }
.am-card-filters { display: flex; gap: .5em; align-items: center; flex-wrap: wrap; }

/* === TABLE === */
table.am-table { width: 100%; border-collapse: collapse; font-size: .88em; }
table.am-table thead th { background: var(--bg-alt); padding: .75em 1em; text-align: left; font-weight: 600; color: var(--text-light); border-bottom: 2px solid var(--border); font-size: .8em; text-transform: uppercase; letter-spacing: .3px; white-space: nowrap; }
table.am-table tbody td { padding: .75em 1em; border-bottom: 1px solid #f5f5f5; vertical-align: middle; }
table.am-table tbody tr:hover { background: var(--bg-alt); }
table.am-table tbody tr.am-row-active { background: #e8f0fe; border-left: 3px solid var(--primary); }

/* === BADGES === */
.am-badge { display: inline-block; padding: 3px 12px; border-radius: 20px; font-size: .78em; font-weight: 600; letter-spacing: .3px; }
.am-badge-green { color: var(--success); background: #e6f9ed; border: 1px solid var(--success); }
.am-badge-orange { color: var(--warning); background: #fff3e0; border: 1px solid var(--warning); }
.am-badge-red { color: var(--danger); background: #fde8ea; border: 1px solid var(--danger); }
.am-badge-gray { color: var(--gray); background: #f0f0f0; border: 1px solid var(--gray); }
.am-badge-blue { color: var(--primary); background: #e0ecff; border: 1px solid var(--primary); }
.am-badge-cyan { color: var(--info); background: #e0f7fa; border: 1px solid var(--info); }
.am-badge-gold { color: #856404; background: #fff3cd; border: 1px solid var(--accent); }

/* === INLINE EDIT === */
.am-inline { border: 1px solid transparent; padding: 5px 8px; border-radius: 6px; background: transparent; font-family: inherit; font-size: inherit; transition: all .15s; }
.am-inline:hover { border-color: var(--border); background: var(--bg-alt); }
.am-inline:focus { border-color: var(--primary); background: var(--bg-white); outline: none; box-shadow: 0 0 0 2px rgba(10,42,94,.12); }
.am-inline-saved { animation: flash-ok .6s; }
@keyframes flash-ok { 0% { background: #d4edda; } 100% { background: transparent; } }

/* === BUTTONS === */
.am-btn { display: inline-flex; align-items: center; gap: .4em; padding: .6em 1.2em; border-radius: 6px; font-size: .88em; font-weight: 600; font-family: inherit; cursor: pointer; border: 2px solid transparent; transition: all .15s; text-decoration: none !important; }
.am-btn-primary { background: var(--primary); color: #fff !important; border-color: var(--primary); }
.am-btn-primary:hover { background: var(--primary-light); border-color: var(--primary-light); }
.am-btn-gold { background: var(--accent); color: var(--primary) !important; border-color: var(--accent); }
.am-btn-gold:hover { background: var(--accent-light); }
.am-btn-outline { background: transparent; color: var(--primary) !important; border-color: var(--border); }
.am-btn-outline:hover { border-color: var(--primary); background: var(--bg-alt); }
.am-btn-danger { background: var(--danger); color: #fff !important; border-color: var(--danger); }
.am-btn-sm { padding: .4em .8em; font-size: .82em; }
.am-btn-icon { padding: .5em .6em; }

/* === FORMS === */
.am-input, .am-select, .am-textarea { padding: .7em; border: 1px solid var(--border); border-radius: 6px; font-size: .92em; font-family: inherit; width: 100%; background: var(--bg-white); }
.am-input:focus, .am-select:focus, .am-textarea:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 2px rgba(10,42,94,.1); }
.am-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1em; }
.am-form-grid .full { grid-column: 1 / -1; }
.am-form-group { display: flex; flex-direction: column; gap: .3em; }
.am-form-group label { font-size: .8em; font-weight: 600; color: var(--text-light); text-transform: uppercase; letter-spacing: .3px; }

/* === MODAL === */
.am-modal-overlay { display: none; position: fixed; inset: 0; background: rgba(10,42,94,.5); z-index: 10000; justify-content: center; align-items: flex-start; padding: 3vh 1em; overflow-y: auto; }
.am-modal-overlay.active { display: flex; animation: amFadeIn .18s ease; }
@keyframes amFadeIn { from { opacity: 0; } to { opacity: 1; } }
.am-modal { background: var(--bg-white); border-radius: 12px; width: 100%; max-width: 700px; max-height: 94vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.25); animation: amSlideDown .22s ease; }
.am-modal-lg { max-width: 900px; }
.am-modal-xl { max-width: 1150px; }
@keyframes amSlideDown { from { transform: translateY(-20px); opacity: .6; } to { transform: translateY(0); opacity: 1; } }
.am-modal-header { display: flex; justify-content: space-between; align-items: center; padding: 1.2em 1.5em; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--bg-white); border-radius: 12px 12px 0 0; z-index: 2; }
.am-modal-header h3 { margin: 0; color: var(--primary); font-size: 1.2em; }
.am-modal-close { background: none; border: none; font-size: 1.8em; cursor: pointer; color: var(--text-muted); line-height: 1; }
.am-modal-close:hover { color: var(--text); }
.am-modal-body { padding: 1.5em; }
.am-modal-footer { padding: 1em 1.5em; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: .8em; position: sticky; bottom: 0; background: var(--bg-white); }

/* Tabs dentro modal */
.am-tabs { display: flex; gap: .2em; border-bottom: 2px solid var(--border); margin-bottom: 1.5em; }
.am-tab-btn { background: none; border: none; padding: .8em 1.4em; font-family: inherit; font-size: .88em; font-weight: 600; color: var(--text-light); cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -2px; transition: all .15s; }
.am-tab-btn:hover { color: var(--primary); }
.am-tab-btn.active { color: var(--primary); border-bottom-color: var(--accent); }
.am-tab-pane { animation: amFadeIn .2s ease; }

/* === ALERTS === */
.am-alert { padding: 1em 1.5em; border-radius: 8px; margin-bottom: 1em; display: flex; align-items: center; gap: .8em; font-size: .92em; }
.am-alert-warning { background: #fff3cd; color: #856404; border: 1px solid #ffc107; }
.am-alert-danger { background: #fde8ea; color: #721c24; border: 1px solid #f5c6cb; }
.am-alert-info { background: #e0ecff; color: var(--primary); border: 1px solid #b8d4fe; }
.am-alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }

/* === PROGRESS BAR === */
.am-progress { height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; }
.am-progress-fill { height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--primary), var(--accent)); }

/* === TOAST === */
.am-toast { position: fixed; bottom: 2em; right: 2em; padding: 1em 1.5em; border-radius: 8px; color: #fff; font-size: .92em; font-weight: 500; box-shadow: 0 8px 24px rgba(0,0,0,.2); z-index: 100001; transform: translateY(100px); opacity: 0; transition: all .3s; }
.am-toast.show { transform: translateY(0); opacity: 1; }
.am-toast.success { background: var(--success); }
.am-toast.error { background: var(--danger); }
.am-toast.info { background: var(--primary); }

/* === LOGIN === */
.am-login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%); }
.am-login-box { background: var(--bg-white); padding: 3em; border-radius: 16px; width: 100%; max-width: 420px; box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.am-login-box h1 { color: var(--primary); text-align: center; font-size: 1.6em; margin-bottom: .3em; }
.am-login-box .am-login-sub { text-align: center; color: var(--text-muted); margin-bottom: 2em; font-size: .9em; }
.am-login-box .am-login-error { background: #fde8ea; color: var(--danger); padding: .8em; border-radius: 6px; margin-bottom: 1em; font-size: .9em; text-align: center; }
.am-login-form { display: flex; flex-direction: column; gap: 1.2em; }
.am-login-form label { font-weight: 600; font-size: .85em; color: var(--text-light); display: flex; flex-direction: column; gap: .4em; }
.am-login-form input { padding: .9em; border: 1px solid var(--border); border-radius: 8px; font-size: 1em; font-family: inherit; }
.am-login-form input:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px rgba(10,42,94,.1); }
.am-login-form button { padding: 1em; background: var(--primary); color: #fff; border: none; border-radius: 8px; font-size: 1em; font-weight: 700; cursor: pointer; font-family: inherit; }
.am-login-form button:hover { background: var(--primary-light); }

/* === GRID UTILS === */
.am-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5em; }
.am-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1.5em; }

/* === RESPONSIVE === */
@media (max-width: 1024px) {
    .am-sidebar { width: 70px; min-width: 70px; }
    .am-sidebar .am-nav-label, .am-sidebar .am-logo-sub, .am-sidebar .am-user-info { display: none; }
    .am-sidebar .am-logo-text { font-size: .9em; text-align: center; }
    .am-sidebar .am-nav-item { justify-content: center; padding: 1em; }
    .am-main { padding: 1.5em; }
    .am-kpi-grid { grid-template-columns: 1fr 1fr; }
    .am-form-grid { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
    .am-sidebar { display: none; }
    .am-main { margin-left: 0; }
}
