/**
 * FILE: admin/css/acm-admin.css
 *
 * Augmenta Clinic Manager — Admin Stylesheet
 * Brand: Augmenta Health (teal/green primary, white background)
 * Accessibility: WCAG AA (min contrast 4.5:1 body, 3:1 large text)
 *
 * @package AugmentaClinicManager
 */

/* ── CSS Custom Properties ──────────────────────────────────────────────── */
:root {
    /* Brand colors */
    --acm-primary:        #01696F;  /* Teal */
    --acm-primary-dark:   #0C4E54;
    --acm-primary-light:  #E6F4F4;
    --acm-secondary:      #437A22;  /* Green */
    --acm-accent-blue:    #006494;
    --acm-accent-indigo:  #4B3FA0;
    --acm-accent-purple:  #7A39BB;
    --acm-accent-orange:  #C05A00;
    --acm-accent-red:     #A12C7B;
    --acm-accent-grey:    #606060;
    --acm-accent-teal:    #1B8A8F;

    /* Semantic */
    --acm-success:        #437A22;
    --acm-warning:        #964219;
    --acm-danger:         #A12C7B;
    --acm-info:           #006494;

    /* Neutrals */
    --acm-bg:             #FFFFFF;
    --acm-surface:        #F7F6F2;
    --acm-border:         #D4D1CA;
    --acm-text:           #28251D;
    --acm-text-muted:     #7A7974;
    --acm-text-faint:     #BAB9B4;

    /* Spacing */
    --acm-radius:         6px;
    --acm-radius-lg:      10px;
    --acm-shadow:         0 1px 4px rgba(0,0,0,0.10);
    --acm-shadow-md:      0 2px 10px rgba(0,0,0,0.12);

    /* Font */
    --acm-font:           -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
    --acm-font-mono:      Consolas, "SFMono-Regular", Menlo, monospace;
    --acm-font-size-base: 14px;
    --acm-line-height:    1.6;
}

.acm-portal {
	background: #fff;
	border: 1px solid var(--acm-border);
	border-radius: 8px;
	box-shadow: var(--acm-shadow);
	font-family: var(--acm-font);
	margin: 24px 0;
	max-width: 1100px;
	padding: 28px;
}

.acm-portal h2 {
	color: var(--acm-text);
	font-size: 28px;
	line-height: 1.2;
	margin: 0;
}

.acm-portal-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
	gap: 16px;
	margin-top: 22px;
}

.acm-portal-card {
	align-items: flex-start;
	background: var(--acm-surface);
	border: 1px solid var(--acm-border);
	border-radius: 8px;
	color: var(--acm-text);
	display: flex;
	gap: 14px;
	min-height: 120px;
	padding: 18px;
	text-decoration: none;
	transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}

.acm-portal-card:focus,
.acm-portal-card:hover {
	border-color: var(--acm-primary);
	box-shadow: 0 0 0 1px var(--acm-primary);
	color: var(--acm-text);
	transform: translateY(-1px);
}

.acm-portal-icon {
	align-items: center;
	background: var(--acm-primary-light);
	border-radius: 8px;
	color: var(--acm-primary);
	display: inline-flex;
	flex: 0 0 42px;
	height: 42px;
	justify-content: center;
	margin-top: 2px;
	width: 42px;
}

.acm-portal-icon.dashicons {
	font-size: 24px;
	line-height: 42px;
	width: 42px;
}

.acm-portal-card strong,
.acm-portal-card span {
	display: block;
}

.acm-portal-card strong {
	font-size: 17px;
	line-height: 1.35;
}

.acm-portal-card span {
	color: var(--acm-text-muted);
	margin-top: 6px;
}

.acm-portal-card-copy {
	min-width: 0;
}

/* ── Base Layout ────────────────────────────────────────────────────────── */
.acm-dashboard,
.acm-export-page,
.acm-templates-page,
.acm-backups-page,
.acm-consultant-dashboard {
    font-family: var(--acm-font);
    font-size:   var(--acm-font-size-base);
    color:       var(--acm-text);
    line-height: var(--acm-line-height);
    max-width:   1400px;
}

.acm-dashboard-header {
    display:     flex;
    align-items: center;
    gap:         16px;
    margin:      16px 0 24px;
    flex-wrap:   wrap;
}

.acm-today-date {
    font-size:  13px;
    color:      var(--acm-text-muted);
    font-weight:500;
}

.acm-ml-auto { margin-left: auto; }
.acm-ml-2    { margin-left: 8px; }
.acm-muted   { color: var(--acm-text-muted); font-style: italic; }

.notice.notice-success p:first-child::before,
.notice.notice-error p:first-child::before {
    border-radius: 50%;
    color: #fff;
    display: inline-flex;
    font-size: 12px;
    font-weight: 700;
    height: 18px;
    justify-content: center;
    line-height: 18px;
    margin-right: 8px;
    vertical-align: 1px;
    width: 18px;
}

.notice.notice-success p:first-child::before {
    background: var(--acm-success);
    content: "\2713";
}

.notice.notice-error p:first-child::before {
    background: var(--acm-danger);
    content: "\00d7";
}

/* ── Stat Cards ─────────────────────────────────────────────────────────── */
.acm-stats-grid {
    display:               grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap:                   16px;
    margin-bottom:         28px;
}

.acm-stat-card {
    background:    var(--acm-bg);
    border:        1px solid var(--acm-border);
    border-radius: var(--acm-radius-lg);
    padding:       20px 16px 16px;
    box-shadow:    var(--acm-shadow);
    border-top:    4px solid var(--acm-primary);
    transition:    box-shadow 0.15s ease;
}

.acm-stat-card:hover { box-shadow: var(--acm-shadow-md); }

.acm-stat-value {
    font-size:   32px;
    font-weight: 700;
    color:       var(--acm-text);
    line-height: 1.1;
}

.acm-stat-sub {
    font-size:   13px;
    color:       var(--acm-text-muted);
    margin-top:  2px;
}

.acm-stat-label {
    font-size:   12px;
    color:       var(--acm-text-muted);
    margin-top:  8px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* Stat card color variants */
.acm-stat-blue   { border-top-color: var(--acm-accent-blue); }
.acm-stat-teal   { border-top-color: var(--acm-primary); }
.acm-stat-green  { border-top-color: var(--acm-secondary); }
.acm-stat-red    { border-top-color: var(--acm-danger); }
.acm-stat-orange { border-top-color: var(--acm-accent-orange); }
.acm-stat-grey   { border-top-color: var(--acm-accent-grey); }
.acm-stat-purple { border-top-color: var(--acm-accent-purple); }
.acm-stat-indigo { border-top-color: var(--acm-accent-indigo); }

/* ── Status Badges ──────────────────────────────────────────────────────── */
.acm-badge {
    display:       inline-block;
    padding:       3px 10px;
    border-radius: 99px;
    font-size:     11px;
    font-weight:   700;
    letter-spacing:0.03em;
    text-transform:uppercase;
    white-space:   nowrap;
}

.acm-badge-scheduled     { background: #E3F0FB; color: #005B9A; }
.acm-badge-completed     { background: #E6F3DC; color: #2D5E0E; }
.acm-badge-cancelled     { background: #FDECEA; color: #8B1A1A; }
.acm-badge-no_show       { background: #F0EDED; color: #4A4A4A; }
.acm-badge-follow_up_due { background: #F3E8FF; color: #5B1FA0; }
.acm-badge-rescheduled   { background: #FFF4E0; color: #7A4500; }
.acm-badge-paid          { background: #E6F3DC; color: #2D5E0E; }
.acm-badge-pending       { background: #FFF4E0; color: #7A4500; }
.acm-badge-draft         { background: #F0F4FF; color: #1A3F8B; }
.acm-badge-finalized     { background: #E3F0FB; color: #005B9A; }

/* ── Risk Level Indicators ──────────────────────────────────────────────── */
.acm-risk-low      { color: var(--acm-success); }
.acm-risk-moderate { color: var(--acm-warning); }
.acm-risk-high     { color: var(--acm-danger);  font-weight: 600; }

/* ── Dashboard Layout ───────────────────────────────────────────────────── */
.acm-dashboard-columns {
    display:               grid;
    grid-template-columns: 2fr 1fr;
    gap:                   24px;
    margin-bottom:         28px;
}

@media (max-width: 1024px) {
    .acm-dashboard-columns { grid-template-columns: 1fr; }
}

.acm-col-wide  { /* default */ }
.acm-col-narrow { /* default */ }

/* ── Dashboard Sections ─────────────────────────────────────────────────── */
.acm-dashboard-section {
    background:    var(--acm-bg);
    border:        1px solid var(--acm-border);
    border-radius: var(--acm-radius-lg);
    padding:       20px;
    margin-bottom: 24px;
    box-shadow:    var(--acm-shadow);
}

.acm-dashboard-section h2 {
    font-size:     16px;
    font-weight:   700;
    margin:        0 0 16px;
    padding-bottom:10px;
    border-bottom: 1px solid var(--acm-border);
    color:         var(--acm-text);
    display:       flex;
    align-items:   center;
    gap:           8px;
}

/* ── Tables ─────────────────────────────────────────────────────────────── */
.acm-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.acm-table {
    min-width:   600px;
    font-size:   13px;
    border:      1px solid var(--acm-border);
    border-radius: var(--acm-radius);
}

.acm-table th {
    background:  var(--acm-surface);
    font-weight: 700;
    font-size:   12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color:       var(--acm-text-muted);
    padding:     10px 12px;
    white-space: nowrap;
}

.acm-table td {
    padding:     10px 12px;
    vertical-align: middle;
    border-top:  1px solid var(--acm-border);
}

.acm-table tr:hover td { background: #FAFAF8; }

.acm-action-buttons {
    display:    flex;
    gap:        6px;
    flex-wrap:  wrap;
    align-items:center;
}

/* ── Forms ──────────────────────────────────────────────────────────────── */
.form-table.acm-two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
}

@media (max-width: 768px) {
    .form-table.acm-two-col { grid-template-columns: 1fr; }
}

.acm-form-actions {
    margin-top: 20px;
    display:    flex;
    gap:        10px;
    align-items:center;
    flex-wrap:  wrap;
    padding:    16px 0;
    border-top: 1px solid var(--acm-border);
}

.acm-section-sep {
    border:    none;
    border-top:1px solid var(--acm-border);
    margin:    24px 0;
}

/* ── Tab Navigation ─────────────────────────────────────────────────────── */
.acm-tabs {
    display:     flex;
    gap:         0;
    border-bottom: 2px solid var(--acm-border);
    margin-bottom: 20px;
    flex-wrap:   wrap;
}

.acm-tab-link {
    padding:       10px 18px;
    font-size:     13px;
    font-weight:   600;
    color:         var(--acm-text-muted);
    border:        none;
    background:    none;
    cursor:        pointer;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    text-decoration: none;
    transition:    color 0.15s, border-color 0.15s;
}

.acm-tab-link:hover,
.acm-tab-link:focus {
    color:         var(--acm-primary);
    border-bottom-color: var(--acm-primary);
    outline:       none;
}

.acm-tab-link.acm-tab-active {
    color:         var(--acm-primary);
    border-bottom-color: var(--acm-primary);
}

.acm-tab-panel { display: none; }
.acm-tab-panel.acm-tab-panel-active { display: block; }

/* ── Modal Overlay ──────────────────────────────────────────────────────── */
.acm-modal {
    position: fixed;
    inset:    0;
    z-index:  100000;
    display:  flex;
    align-items: center;
    justify-content: center;
}

.acm-modal[hidden] { display: none; }

.acm-modal-backdrop {
    position: absolute;
    inset:    0;
    background: rgba(0, 0, 0, 0.55);
}

.acm-modal-inner {
    position:      relative;
    background:    var(--acm-bg);
    border-radius: var(--acm-radius-lg);
    box-shadow:    var(--acm-shadow-md);
    max-width:     560px;
    width:         calc(100% - 48px);
    max-height:    85vh;
    overflow-y:    auto;
    z-index:       1;
    display:       flex;
    flex-direction:column;
}

.acm-modal-danger .acm-modal-header { background: #FDF0F0; border-bottom: 1px solid #F5C6C6; }

.acm-modal-header {
    display:       flex;
    align-items:   center;
    justify-content: space-between;
    padding:       16px 20px;
    border-bottom: 1px solid var(--acm-border);
}

.acm-modal-header h3 { margin: 0; font-size: 16px; }

.acm-modal-close {
    background:  none;
    border:      none;
    font-size:   22px;
    cursor:      pointer;
    color:       var(--acm-text-muted);
    padding:     0 4px;
    line-height: 1;
}

.acm-modal-close:hover { color: var(--acm-text); }
.acm-modal-close:focus { outline: 2px solid var(--acm-primary); border-radius: 2px; }

.acm-modal-body   { padding: 20px; flex: 1; }
.acm-modal-footer {
    display:     flex;
    gap:         10px;
    padding:     16px 20px;
    border-top:  1px solid var(--acm-border);
    justify-content: flex-end;
    flex-wrap:   wrap;
}

.acm-btn-danger { background: var(--acm-danger) !important; border-color: var(--acm-danger) !important; color: #fff !important; }
.acm-btn-danger:hover { background: #8A225F !important; border-color: #8A225F !important; }

/* ── Loading Spinner ────────────────────────────────────────────────────── */
@keyframes acm-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

.acm-spinner {
    display:      inline-block;
    width:        20px;
    height:       20px;
    border:       3px solid var(--acm-border);
    border-top-color: var(--acm-primary);
    border-radius:50%;
    animation:    acm-spin 0.7s linear infinite;
    vertical-align: middle;
}

button.acm-loading::after {
    content:      '';
    display:      inline-block;
    width:        14px;
    height:       14px;
    border:       2px solid rgba(255,255,255,0.4);
    border-top-color: #fff;
    border-radius:50%;
    animation:    acm-spin 0.7s linear infinite;
    margin-left:  8px;
    vertical-align: middle;
}

/* ── Audit List ─────────────────────────────────────────────────────────── */
.acm-audit-list {
    list-style: none;
    margin:     0;
    padding:    0;
}

.acm-audit-item {
    padding:       10px 12px;
    border-radius: var(--acm-radius);
    margin-bottom: 6px;
    background:    var(--acm-surface);
    display:       flex;
    flex-direction:column;
    gap:           3px;
    border-left:   3px solid var(--acm-border);
}

.acm-audit-item.acm-risk-high { border-left-color: var(--acm-danger); background: #FDF0F0; }
.acm-audit-action { font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
.acm-audit-meta   { font-size: 11px; color: var(--acm-text-muted); }

/* ── Pending Notes Banner ───────────────────────────────────────────────── */
.acm-pending-notes-banner { border-left: 4px solid #D97706 !important; background: #FEF9F0 !important; }

/* ── Finalized Note Indicator ───────────────────────────────────────────── */
.acm-note-finalized {
    position: relative;
}

.acm-note-finalized::before {
    content:        '\f160';  /* dashicons-lock */
    font-family:    dashicons;
    display:        inline-block;
    color:          var(--acm-info);
    font-size:      14px;
    vertical-align: middle;
    margin-right:   5px;
}

.acm-note-readonly {
    background:     #F0F8FF;
    border:         1px solid #C3E0F5;
    border-radius:  var(--acm-radius);
    cursor:         not-allowed;
    color:          var(--acm-text-muted);
}

/* ── Card component ─────────────────────────────────────────────────────── */
.card.acm-schedule-card,
.card.acm-export-controls {
    padding:   20px 24px;
    border:    1px solid var(--acm-border);
    box-shadow:var(--acm-shadow);
}

/* ── Placeholder guide ──────────────────────────────────────────────────── */
.acm-placeholder-guide {
    background:    var(--acm-surface);
    border:        1px solid var(--acm-border);
    border-radius: var(--acm-radius);
    padding:       10px 16px;
    margin-bottom: 16px;
    font-size:     12px;
    line-height:   2;
}

.acm-placeholder-guide code {
    background:    #E8F0E9;
    color:         #1B4332;
    padding:       2px 6px;
    border-radius: 3px;
    margin:        2px;
    display:       inline-block;
    font-family:   var(--acm-font-mono);
}

/* ── Template form ──────────────────────────────────────────────────────── */
.acm-template-body {
    font-family: var(--acm-font-mono) !important;
    font-size:   12px !important;
}

/* ── Report preview ─────────────────────────────────────────────────────── */
.acm-report-preview {
    margin-top:    20px;
    padding:       16px;
    border:        1px solid var(--acm-border);
    border-radius: var(--acm-radius);
    min-height:    80px;
    background:    var(--acm-surface);
}

/* ── Restore meta list ──────────────────────────────────────────────────── */
.acm-restore-meta {
    list-style: none;
    padding:    0;
    margin:     12px 0 0;
}

.acm-restore-meta li {
    padding:    6px 0;
    border-bottom: 1px solid var(--acm-border);
    font-size:  13px;
}

.acm-restore-meta li:last-child { border-bottom: none; }

/* ── Safety / Privacy banners ───────────────────────────────────────────── */
.acm-safety-banner { border-left: 4px solid var(--acm-warning) !important; }

/* ── Inline form ────────────────────────────────────────────────────────── */
.acm-inline-form { display: inline-block; margin-bottom: 16px; }

/* ── Focus indicators (accessibility) ──────────────────────────────────── */
.acm-dashboard a:focus,
.acm-dashboard button:focus,
.acm-dashboard input:focus,
.acm-dashboard select:focus,
.acm-dashboard textarea:focus {
    outline:       2px solid var(--acm-primary);
    outline-offset:2px;
}

/* ── Quick-note button ──────────────────────────────────────────────────── */
.acm-quick-note-btn {
    background:   var(--acm-primary) !important;
    border-color: var(--acm-primary-dark) !important;
    color:        #fff !important;
}

.acm-quick-note-btn:hover {
    background:   var(--acm-primary-dark) !important;
}

/* ── Pending payments total ─────────────────────────────────────────────── */
.acm-pending-total {
    font-size:   15px;
    font-weight: 600;
    color:       var(--acm-danger);
}

/* ── Export action buttons ──────────────────────────────────────────────── */
.acm-export-actions {
    display:    flex;
    gap:        10px;
    margin-top: 16px;
    flex-wrap:  wrap;
}

/* ── Responsive: collapse tables on small screens ───────────────────────── */
@media (max-width: 768px) {
    .acm-stats-grid        { grid-template-columns: repeat(2, 1fr); }
    .acm-table             { font-size: 12px; }
    .acm-table th,
    .acm-table td          { padding: 8px 8px; }
    .acm-action-buttons    { flex-direction: column; align-items: flex-start; }
    .acm-dashboard-header  { flex-direction: column; align-items: flex-start; }
    .acm-modal-inner       { width: calc(100% - 24px); }
}

@media (max-width: 480px) {
    .acm-stats-grid        { grid-template-columns: 1fr; }
    .acm-stat-card         { padding: 16px 12px; }
    .acm-stat-value        { font-size: 26px; }
}

/* ── Print styles ───────────────────────────────────────────────────────── */
@media print {
    #adminmenuback,
    #adminmenuwrap,
    #wpadminbar,
    .acm-dashboard-header button,
    .acm-export-actions,
    .acm-action-buttons,
    .acm-modal,
    .acm-pending-notes-banner a {
        display: none !important;
    }

    body,
    .wrap {
        margin:  0 !important;
        padding: 0 !important;
    }

    .acm-dashboard-section {
        border:     1px solid #ccc;
        box-shadow: none;
        page-break-inside: avoid;
        margin-bottom: 16px;
    }

    .acm-stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .acm-table { font-size: 11px; }
    .acm-table th, .acm-table td { padding: 6px 8px; }

    a { text-decoration: none; color: inherit; }
}
