/* =========================================================
   Pohanohara CSS
   Sistema de Gestión Médica
   Base visual oficial del proyecto
   Framework base sugerido: Bootstrap 5
   ========================================================= */

:root {
    --hm-primary: #2563EB;
    --hm-primary-dark: #1D4ED8;
    --hm-primary-soft: #E0F2FE;

    --hm-success: #10B981;
    --hm-success-soft: #D1FAE5;

    --hm-warning: #F59E0B;
    --hm-warning-soft: #FEF3C7;

    --hm-danger: #EF4444;
    --hm-danger-soft: #FEE2E2;

    --hm-info: #0EA5E9;
    --hm-info-soft: #E0F2FE;

    --hm-text: #111827;
    --hm-text-muted: #6B7280;
    --hm-border: #E5E7EB;
    --hm-bg: #F9FAFB;
    --hm-white: #FFFFFF;

    --hm-radius-sm: 8px;
    --hm-radius-md: 12px;
    --hm-radius-lg: 16px;
    --hm-radius-xl: 20px;

    --hm-shadow-sm: 0 2px 8px rgba(17, 24, 39, 0.06);
    --hm-shadow-md: 0 8px 24px rgba(17, 24, 39, 0.08);
}

/* =========================================================
   Base
   ========================================================= */

html,
body {
    min-height: 100%;
}

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

a {
    color: var(--hm-primary);
}

a:hover {
    color: var(--hm-primary-dark);
}

.hm-app {
    min-height: 100vh;
    background: var(--hm-bg);
}

.hm-layout {
    min-height: 100vh;
}

.hm-content {
    min-width: 0;
}

.hm-main {
    padding: 16px;
    padding-bottom: 86px;
}

.hm-container {
    width: 100%;
    max-width: 1180px;
    margin: 0 auto;
}

.hm-section {
    margin-bottom: 24px;
}

/* =========================================================
   Header
   ========================================================= */

.hm-header {
    background: var(--hm-white);
    border-bottom: 1px solid var(--hm-border);
    padding: 12px 16px;
    position: sticky;
    top: 0;
    z-index: 900;
}

.hm-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    max-width: 1180px;
    margin: 0 auto;
}

.hm-brand {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: var(--hm-text);
    font-weight: 700;
}

.hm-brand img {
    height: 34px;
    width: auto;
}

/* =========================================================
   Page header
   ========================================================= */

.hm-page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 18px;
}

.hm-page-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--hm-text);
    margin: 0;
}

.hm-page-subtitle {
    font-size: 14px;
    color: var(--hm-text-muted);
    margin: 4px 0 0;
}

/* =========================================================
   Cards
   ========================================================= */

.hm-card {
    background: var(--hm-white);
    border: 1px solid var(--hm-border);
    border-radius: var(--hm-radius-lg);
    box-shadow: var(--hm-shadow-sm);
    padding: 16px;
}

.hm-card + .hm-card {
    margin-top: 12px;
}

.hm-card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--hm-text);
    margin: 0 0 4px;
}

.hm-card-text {
    font-size: 14px;
    color: var(--hm-text-muted);
    margin: 0;
}

.hm-card-footer {
    border-top: 1px solid var(--hm-border);
    margin-top: 14px;
    padding-top: 14px;
}

/* =========================================================
   Buttons
   ========================================================= */

.hm-btn-primary,
.hm-btn-secondary,
.hm-btn-success,
.hm-btn-danger {
    border-radius: var(--hm-radius-md);
    padding: 11px 16px;
    font-weight: 600;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    line-height: 1.2;
    transition: all 0.15s ease-in-out;
    cursor: pointer;
}

.hm-btn-primary {
    background: var(--hm-primary);
    border: 1px solid var(--hm-primary);
    color: var(--hm-white);
}

.hm-btn-primary:hover {
    background: var(--hm-primary-dark);
    border-color: var(--hm-primary-dark);
    color: var(--hm-white);
}

.hm-btn-secondary {
    background: var(--hm-white);
    border: 1px solid var(--hm-border);
    color: var(--hm-text);
}

.hm-btn-secondary:hover {
    background: #F3F4F6;
    color: var(--hm-text);
}

.hm-btn-success {
    background: var(--hm-success);
    border: 1px solid var(--hm-success);
    color: var(--hm-white);
}

.hm-btn-success:hover {
    filter: brightness(0.95);
    color: var(--hm-white);
}

.hm-btn-danger {
    background: var(--hm-danger);
    border: 1px solid var(--hm-danger);
    color: var(--hm-white);
}

.hm-btn-danger:hover {
    filter: brightness(0.95);
    color: var(--hm-white);
}

.hm-btn-block {
    width: 100%;
}

/* =========================================================
   Quick actions
   ========================================================= */

.hm-quick-actions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.hm-action-card {
    background: var(--hm-white);
    border: 1px solid var(--hm-border);
    border-radius: var(--hm-radius-lg);
    padding: 14px;
    text-decoration: none;
    color: var(--hm-text);
    box-shadow: var(--hm-shadow-sm);
    transition: all 0.15s ease-in-out;
}

.hm-action-card:hover {
    transform: translateY(-1px);
    box-shadow: var(--hm-shadow-md);
    color: var(--hm-text);
}

.hm-action-card-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: var(--hm-primary-soft);
    color: var(--hm-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
    font-weight: 700;
}

.hm-action-card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--hm-text);
}

.hm-action-card-text {
    font-size: 12px;
    color: var(--hm-text-muted);
    margin-top: 2px;
}

/* =========================================================
   Forms
   ========================================================= */

.hm-form-group {
    margin-bottom: 14px;
}

.hm-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--hm-text);
    margin-bottom: 6px;
}

.hm-input,
.hm-select,
.hm-textarea {
    width: 100%;
    border: 1px solid var(--hm-border);
    border-radius: var(--hm-radius-md);
    padding: 11px 12px;
    font-size: 15px;
    background: var(--hm-white);
    color: var(--hm-text);
}

.hm-input:focus,
.hm-select:focus,
.hm-textarea:focus {
    outline: none;
    border-color: var(--hm-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.hm-textarea {
    min-height: 110px;
    resize: vertical;
}

.hm-help {
    font-size: 12px;
    color: var(--hm-text-muted);
    margin-top: 4px;
}

.hm-error {
    font-size: 12px;
    color: var(--hm-danger);
    margin-top: 4px;
}

.hm-search-box {
    position: relative;
}

.hm-search-box .hm-input {
    padding-left: 40px;
}

.hm-search-icon {
    position: absolute;
    left: 13px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--hm-text-muted);
}

/* =========================================================
   Patient components
   ========================================================= */

.hm-patient-header {
    background: var(--hm-white);
    border: 1px solid var(--hm-border);
    border-radius: var(--hm-radius-xl);
    padding: 16px;
    box-shadow: var(--hm-shadow-sm);
}

.hm-patient-name {
    font-size: 22px;
    font-weight: 700;
    color: var(--hm-text);
    margin: 0;
}

.hm-patient-meta {
    font-size: 14px;
    color: var(--hm-text-muted);
    margin-top: 4px;
}

.hm-patient-actions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-top: 14px;
}

.hm-patient-card {
    display: flex;
    gap: 12px;
    align-items: center;
    background: var(--hm-white);
    border: 1px solid var(--hm-border);
    border-radius: var(--hm-radius-lg);
    box-shadow: var(--hm-shadow-sm);
    padding: 14px;
    text-decoration: none;
    color: var(--hm-text);
}

.hm-patient-card:hover {
    color: var(--hm-text);
    box-shadow: var(--hm-shadow-md);
}

.hm-patient-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--hm-primary-soft);
    color: var(--hm-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    flex: 0 0 auto;
}

/* =========================================================
   Badges
   ========================================================= */

.hm-badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 5px 10px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
}

.hm-badge-success {
    background: var(--hm-success-soft);
    color: #047857;
}

.hm-badge-warning {
    background: var(--hm-warning-soft);
    color: #92400E;
}

.hm-badge-danger {
    background: var(--hm-danger-soft);
    color: #B91C1C;
}

.hm-badge-info {
    background: var(--hm-info-soft);
    color: #0369A1;
}

.hm-badge-muted {
    background: #F3F4F6;
    color: var(--hm-text-muted);
}

/* =========================================================
   Agenda / appointments
   ========================================================= */

.hm-appointment-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.hm-appointment-card {
    background: var(--hm-white);
    border: 1px solid var(--hm-border);
    border-radius: var(--hm-radius-lg);
    padding: 14px;
    display: flex;
    gap: 12px;
    align-items: flex-start;
    box-shadow: var(--hm-shadow-sm);
}

.hm-appointment-time {
    min-width: 58px;
    font-weight: 700;
    color: var(--hm-primary);
}

.hm-appointment-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--hm-text);
}

.hm-appointment-meta {
    font-size: 13px;
    color: var(--hm-text-muted);
}

/* =========================================================
   Tables
   ========================================================= */

.hm-table {
    width: 100%;
    background: var(--hm-white);
    border-radius: var(--hm-radius-lg);
    overflow: hidden;
    border: 1px solid var(--hm-border);
}

.hm-table th {
    font-size: 12px;
    color: var(--hm-text-muted);
    font-weight: 600;
    background: #F3F4F6;
    border-bottom: 1px solid var(--hm-border);
}

.hm-table td {
    font-size: 14px;
    vertical-align: middle;
    border-bottom: 1px solid var(--hm-border);
}

.hm-table tr:last-child td {
    border-bottom: 0;
}

/* =========================================================
   Sidebar desktop
   ========================================================= */

.hm-sidebar {
    width: 260px;
    background: var(--hm-white);
    border-right: 1px solid var(--hm-border);
    min-height: 100vh;
    padding: 18px;
    position: sticky;
    top: 0;
}

.hm-sidebar-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    color: var(--hm-text);
    text-decoration: none;
    margin-bottom: 22px;
}

.hm-sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--hm-text-muted);
    text-decoration: none;
    padding: 10px 12px;
    border-radius: var(--hm-radius-md);
    font-weight: 500;
    margin-bottom: 4px;
}

.hm-sidebar-link.active,
.hm-sidebar-link:hover {
    background: var(--hm-primary-soft);
    color: var(--hm-primary);
}

/* =========================================================
   Bottom navigation mobile
   ========================================================= */

.hm-bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--hm-white);
    border-top: 1px solid var(--hm-border);
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    z-index: 1000;
    padding: 6px 4px;
    box-shadow: 0 -4px 16px rgba(17, 24, 39, 0.06);
}

.hm-bottom-nav a {
    text-decoration: none;
    color: var(--hm-text-muted);
    font-size: 11px;
    text-align: center;
    padding: 6px 2px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.hm-bottom-nav a.active {
    color: var(--hm-primary);
    font-weight: 600;
}

.hm-bottom-nav-icon {
    font-size: 18px;
    line-height: 1;
}

/* =========================================================
   Alerts
   ========================================================= */

.hm-alert {
    border-radius: var(--hm-radius-lg);
    padding: 14px 16px;
    border: 1px solid transparent;
    font-size: 14px;
}

.hm-alert-success {
    background: var(--hm-success-soft);
    color: #047857;
    border-color: #A7F3D0;
}

.hm-alert-danger {
    background: var(--hm-danger-soft);
    color: #B91C1C;
    border-color: #FECACA;
}

.hm-alert-info {
    background: var(--hm-info-soft);
    color: #0369A1;
    border-color: #BAE6FD;
}

.hm-alert-warning {
    background: var(--hm-warning-soft);
    color: #92400E;
    border-color: #FDE68A;
}

/* =========================================================
   Login
   ========================================================= */

.hm-login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, var(--hm-bg), var(--hm-primary-soft));
}

.hm-login-card {
    width: 100%;
    max-width: 420px;
    background: var(--hm-white);
    border: 1px solid var(--hm-border);
    border-radius: var(--hm-radius-xl);
    box-shadow: var(--hm-shadow-md);
    padding: 24px;
}

.hm-login-title {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 6px;
}

.hm-login-subtitle {
    color: var(--hm-text-muted);
    margin-bottom: 20px;
}

/* =========================================================
   Print styles
   ========================================================= */

.hm-print-page {
    background: var(--hm-white);
    color: var(--hm-text);
    padding: 24px;
    border-radius: var(--hm-radius-lg);
    border: 1px solid var(--hm-border);
}

.hm-print-header {
    border-bottom: 1px solid var(--hm-border);
    padding-bottom: 12px;
    margin-bottom: 16px;
}

.hm-print-title {
    font-size: 22px;
    font-weight: 700;
    margin: 0;
}

.hm-print-section {
    margin-bottom: 16px;
}

.hm-print-label {
    font-weight: 700;
}

@media print {
    body {
        background: #ffffff !important;
        color: #000000 !important;
        font-family: Arial, sans-serif !important;
        font-size: 12pt !important;
    }

    .hm-sidebar,
    .hm-bottom-nav,
    .hm-header,
    .hm-no-print,
    .btn,
    button {
        display: none !important;
    }

    .hm-main,
    .hm-container,
    .hm-content {
        padding: 0 !important;
        margin: 0 !important;
        max-width: none !important;
        width: 100% !important;
    }

    .hm-print-page {
        width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
        box-shadow: none !important;
        border: none !important;
        border-radius: 0 !important;
    }

    .hm-print-title {
        font-size: 18pt !important;
        font-weight: bold !important;
        margin-bottom: 12px !important;
    }

    .hm-print-section {
        margin-bottom: 14px !important;
    }
}

/* =========================================================
   Responsive
   ========================================================= */

@media (min-width: 768px) {
    .hm-main {
        padding: 24px;
        padding-bottom: 24px;
    }

    .hm-quick-actions {
        grid-template-columns: repeat(4, 1fr);
    }

    .hm-patient-actions {
        grid-template-columns: repeat(4, 1fr);
    }

    .hm-page-title {
        font-size: 28px;
    }
}

@media (min-width: 992px) {
    .hm-layout {
        display: flex;
    }

    .hm-content {
        flex: 1;
    }

    .hm-bottom-nav {
        display: none;
    }
}

@media (max-width: 767.98px) {
    .hm-page-header {
        flex-direction: column;
        align-items: stretch;
    }

    .hm-page-header .hm-btn-primary,
    .hm-page-header .hm-btn-secondary {
        width: 100%;
    }

    .hm-table-mobile-cards thead {
        display: none;
    }

    .hm-table-mobile-cards,
    .hm-table-mobile-cards tbody,
    .hm-table-mobile-cards tr,
    .hm-table-mobile-cards td {
        display: block;
        width: 100%;
    }

    .hm-table-mobile-cards tr {
        background: var(--hm-white);
        border: 1px solid var(--hm-border);
        border-radius: var(--hm-radius-lg);
        padding: 12px;
        margin-bottom: 10px;
        box-shadow: var(--hm-shadow-sm);
    }

    .hm-table-mobile-cards td {
        border: 0;
        padding: 4px 0;
    }
}

/* Bases y condiciones (pantalla obligatoria de aceptación y consulta) */
.hm-terms-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; background: var(--hm-bg, #f4f8ff); }
.hm-terms-progress { position: fixed; top: 0; left: 0; right: 0; height: 4px; background: rgba(0,0,0,.08); z-index: 10; }
.hm-terms-progress > div { height: 100%; width: 0; background: var(--hm-primary, #0b2d5b); transition: width .15s; }
.hm-terms-card { width: 100%; max-width: 760px; background: #fff; border-radius: 14px; box-shadow: 0 6px 24px rgba(0,0,0,.08); padding: 20px; }
.hm-terms-scroll { max-height: 58vh; overflow-y: auto; padding-right: 8px; margin-bottom: 14px; line-height: 1.55; }
.hm-terms-h { font-size: 1.05rem; margin: 18px 0 6px; }
.hm-terms-actions .hm-check { display: flex; gap: 10px; align-items: flex-start; min-height: 44px; font-size: 1rem; }
.hm-terms-actions .hm-check input { width: 22px; height: 22px; flex: none; }
.hm-sus-banner { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 10px 14px; margin-bottom: 14px; border-radius: 10px; font-size: .95rem; }
.hm-sus-banner.aviso { background: #fff7e0; color: #6b4f00; }
.hm-sus-banner.gracia { background: #ffe8e6; color: #8a1c14; }
@media print { .hm-terms-scroll { max-height: none; overflow: visible; } }

/* Instalar como aplicación (login): el botón se muestra solo si el navegador lo permite */
#instalar[hidden], #instalar-ayuda[hidden] { display: none; }
