/**
 * ParcelHub — Componentes UI reutilizables
 */

/* Page header */
.ph-page-header {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.ph-page-title {
    margin: 0 0 .25rem;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--ph-text);
    letter-spacing: -.02em;
}

.ph-page-subtitle {
    margin: 0;
    color: var(--ph-text-muted);
    font-size: .925rem;
    max-width: 640px;
}

.ph-page-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
}

/* Breadcrumb */
.ph-breadcrumb {
    margin-bottom: 1rem;
}

    .ph-breadcrumb .breadcrumb {
        margin: 0;
        padding: 0;
        background: transparent;
        font-size: .8rem;
    }

    .ph-breadcrumb .breadcrumb-item a {
        color: var(--ph-text-muted);
    }

    .ph-breadcrumb .breadcrumb-item.active {
        color: var(--ph-text);
        font-weight: 500;
    }

/* Stat card (KPI) */
.ph-stat-card {
    background: var(--ph-card);
    border: 1px solid var(--ph-border);
    border-radius: var(--ph-radius-lg);
    padding: 1.15rem 1.25rem;
    height: 100%;
    box-shadow: var(--ph-shadow-sm);
    transition: box-shadow var(--ph-transition), transform var(--ph-transition);
}

    .ph-stat-card:hover {
        box-shadow: var(--ph-shadow);
        transform: translateY(-1px);
    }

.ph-stat-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: .75rem;
    margin-bottom: .75rem;
}

.ph-stat-card-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
}

.ph-stat-card-icon--primary { background: var(--ph-primary-soft); color: var(--ph-primary); }
.ph-stat-card-icon--success { background: var(--ph-success-soft); color: var(--ph-success); }
.ph-stat-card-icon--warning { background: var(--ph-warning-soft); color: var(--ph-warning); }
.ph-stat-card-icon--danger { background: var(--ph-danger-soft); color: var(--ph-danger); }
.ph-stat-card-icon--info { background: var(--ph-info-soft); color: var(--ph-info); }

.ph-stat-card-label {
    font-size: .8rem;
    font-weight: 500;
    color: var(--ph-text-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
}

.ph-stat-card-value {
    font-size: 1.65rem;
    font-weight: 700;
    color: var(--ph-text);
    line-height: 1.2;
}

.ph-stat-card-trend {
    font-size: .75rem;
    font-weight: 600;
    margin-top: .35rem;
}

    .ph-stat-card-trend.up { color: var(--ph-success); }
    .ph-stat-card-trend.down { color: var(--ph-danger); }

/* Panel / card genérica */
.ph-panel {
    background: var(--ph-card);
    border: 1px solid var(--ph-border);
    border-radius: var(--ph-radius-lg);
    box-shadow: var(--ph-shadow-sm);
    display: flex;
    flex-direction: column;
    width: 100%;
}

/* Solo expanden altura completa los paneles dentro de un .row o marcados con .h-100. */
.row > [class*="col"] > .ph-panel,
.ph-panel.h-100 {
    height: 100%;
}

.ph-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--ph-border);
}

.ph-panel-title {
    margin: 0;
    font-size: .95rem;
    font-weight: 600;
}

.ph-panel-body {
    padding: 1.15rem 1.25rem;
    flex: 1 1 auto;
}

.ph-panel-footer {
    padding: .75rem 1.25rem;
    border-top: 1px solid var(--ph-border);
    font-size: .8rem;
    color: var(--ph-text-muted);
}

/* Quick access cards */
.ph-quick-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.15rem;
    background: var(--ph-card);
    border: 1px solid var(--ph-border);
    border-radius: var(--ph-radius);
    transition: border-color var(--ph-transition), box-shadow var(--ph-transition);
    color: inherit;
    height: 100%;
}

    .ph-quick-card:hover {
        border-color: var(--ph-primary);
        box-shadow: var(--ph-shadow);
        text-decoration: none;
        color: inherit;
    }

.ph-quick-card-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: var(--ph-primary-soft);
    color: var(--ph-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.ph-quick-card-title {
    font-weight: 600;
    font-size: .9rem;
    margin: 0 0 .15rem;
}

.ph-quick-card-desc {
    font-size: .78rem;
    color: var(--ph-text-muted);
    margin: 0;
}

/* Chart placeholder */
.ph-chart-placeholder {
    min-height: 200px;
    background: linear-gradient(180deg, var(--ph-bg) 0%, var(--ph-surface) 100%);
    border-radius: var(--ph-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ph-text-muted);
    font-size: .85rem;
    border: 1px dashed var(--ph-border);
}

/* Activity list */
.ph-activity-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.ph-activity-item {
    display: flex;
    gap: .85rem;
    padding: .75rem 0;
    border-bottom: 1px solid var(--ph-border);
}

    .ph-activity-item:last-child {
        border-bottom: none;
    }

.ph-activity-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--ph-primary);
    margin-top: .45rem;
    flex-shrink: 0;
}

.ph-activity-text {
    font-size: .875rem;
    margin: 0 0 .15rem;
}

.ph-activity-time {
    font-size: .75rem;
    color: var(--ph-text-muted);
}

/* Integration status */
.ph-integration-item {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .65rem 0;
    border-bottom: 1px solid var(--ph-border);
}

    .ph-integration-item:last-child {
        border-bottom: none;
    }

.ph-integration-logo {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--ph-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .65rem;
    color: var(--ph-text-muted);
}

/* Badges de estado */
.ph-badge {
    display: inline-flex;
    align-items: center;
    padding: .2em .55em;
    font-size: .72rem;
    font-weight: 600;
    border-radius: 6px;
    text-transform: uppercase;
    letter-spacing: .03em;
}

.ph-badge--success { background: var(--ph-success-soft); color: var(--ph-success); }
.ph-badge--warning { background: var(--ph-warning-soft); color: var(--ph-warning); }
.ph-badge--danger { background: var(--ph-danger-soft); color: var(--ph-danger); }
.ph-badge--info { background: var(--ph-info-soft); color: var(--ph-info); }
.ph-badge--neutral { background: var(--ph-bg); color: var(--ph-text-muted); border: 1px solid var(--ph-border); }

/* Tablas estándar */
.ph-table-card .ph-panel-body {
    padding: 0;
}

.ph-table-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--ph-border);
}

.ph-table-filters {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    flex: 1 1 auto;
}

.ph-table-filter-input {
    min-width: 140px;
    max-width: 200px;
    font-size: .85rem;
    padding: .4rem .75rem;
    border: 1px solid var(--ph-border);
    border-radius: 8px;
}

.ph-table-wrap {
    overflow-x: auto;
}

.ph-table {
    width: 100%;
    margin: 0;
    font-size: .875rem;
}

    .ph-table thead th {
        background: var(--ph-bg);
        color: var(--ph-text-muted);
        font-weight: 600;
        font-size: .75rem;
        text-transform: uppercase;
        letter-spacing: .04em;
        padding: .75rem 1rem;
        border-bottom: 1px solid var(--ph-border);
        white-space: nowrap;
    }

    .ph-table tbody td {
        padding: .8rem 1rem;
        border-bottom: 1px solid var(--ph-border);
        vertical-align: middle;
    }

    .ph-table tbody tr {
        transition: background var(--ph-transition);
    }

    .ph-table tbody tr:hover {
        background: rgba(var(--ph-primary-rgb), .04);
    }

    .ph-table.is-loading tbody {
        opacity: .45;
        pointer-events: none;
    }

.ph-table-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .75rem 1.25rem;
    border-top: 1px solid var(--ph-border);
    font-size: .8rem;
    color: var(--ph-text-muted);
}

/* Empty state */
.ph-empty-state {
    text-align: center;
    padding: 2.5rem 1.5rem;
}

.ph-empty-state-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 1rem;
    border-radius: 50%;
    background: var(--ph-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    color: var(--ph-text-muted);
}

.ph-empty-state--error .ph-empty-state-icon {
    background: var(--ph-danger-soft);
    color: var(--ph-danger);
}

.ph-empty-state--warning .ph-empty-state-icon {
    background: var(--ph-warning-soft);
    color: var(--ph-warning);
}

.ph-empty-state-title {
    font-size: 1.05rem;
    font-weight: 600;
    margin: 0 0 .35rem;
}

.ph-empty-state-text {
    color: var(--ph-text-muted);
    font-size: .9rem;
    margin: 0 0 1rem;
    max-width: 360px;
    margin-left: auto;
    margin-right: auto;
}

/* Loading overlay global */
.ph-loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .35);
    backdrop-filter: blur(2px);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 1rem;
}

    .ph-loading-overlay.is-visible {
        display: flex;
    }

.ph-loading-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid rgba(255, 255, 255, .3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: ph-spin .7s linear infinite;
}

.ph-loading-text {
    color: #fff;
    font-size: .9rem;
    font-weight: 500;
}

@keyframes ph-spin {
    to { transform: rotate(360deg); }
}

/* Toasts */
.ph-toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: .5rem;
    max-width: 360px;
    pointer-events: none;
}

.ph-toast {
    display: flex;
    align-items: flex-start;
    gap: .65rem;
    padding: .85rem 1rem;
    background: var(--ph-surface);
    border: 1px solid var(--ph-border);
    border-radius: var(--ph-radius);
    box-shadow: var(--ph-shadow-lg);
    pointer-events: auto;
    animation: ph-toast-in .35s ease;
    border-left: 4px solid var(--ph-primary);
}

    .ph-toast.is-hiding {
        animation: ph-toast-out .3s ease forwards;
    }

    .ph-toast--success { border-left-color: var(--ph-success); }
    .ph-toast--warning { border-left-color: var(--ph-warning); }
    .ph-toast--error { border-left-color: var(--ph-danger); }
    .ph-toast--info { border-left-color: var(--ph-info); }

.ph-toast-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
}

.ph-toast--success .ph-toast-icon { color: var(--ph-success); }
.ph-toast--warning .ph-toast-icon { color: var(--ph-warning); }
.ph-toast--error .ph-toast-icon { color: var(--ph-danger); }
.ph-toast--info .ph-toast-icon { color: var(--ph-info); }

.ph-toast-body {
    flex: 1 1 auto;
    font-size: .875rem;
}

.ph-toast-close {
    background: none;
    border: none;
    color: var(--ph-text-muted);
    padding: 0;
    line-height: 1;
    cursor: pointer;
}

@keyframes ph-toast-in {
    from { opacity: 0; transform: translateX(100%); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes ph-toast-out {
    to { opacity: 0; transform: translateX(100%); }
}

/* Info table (health, detalle) */
.ph-info-table {
    width: 100%;
}

    .ph-info-table th {
        text-align: left;
        font-weight: 600;
        color: var(--ph-text-muted);
        padding: .5rem .75rem;
        width: 220px;
        vertical-align: top;
    }

    .ph-info-table td {
        padding: .5rem .75rem;
        word-break: break-word;
    }

.ph-status-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: .35rem;
    vertical-align: middle;
}

    .ph-status-dot.healthy {
        background: var(--ph-success);
        box-shadow: 0 0 0 4px rgba(22, 163, 74, .15);
    }

    .ph-status-dot.unhealthy {
        background: var(--ph-danger);
        box-shadow: 0 0 0 4px rgba(220, 38, 38, .15);
    }

/* Confirm dialog */
.ph-confirm-modal .modal-content {
    border: none;
    border-radius: var(--ph-radius-lg);
    box-shadow: var(--ph-shadow-lg);
}

.ph-confirm-modal .modal-header {
    border-bottom: 1px solid var(--ph-border);
}

/* Login (mantiene estilos de autenticación) */
.ph-login-body {
    min-height: 100vh;
    background: linear-gradient(135deg, #111827 0%, var(--ph-primary) 55%, #3b82f6 100%);
}

.ph-login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.ph-login-card {
    width: 100%;
    max-width: 420px;
    background: var(--ph-surface);
    border-radius: var(--ph-radius-lg);
    padding: 2rem 2rem 1.5rem;
    box-shadow: var(--ph-shadow-lg);
}

.ph-login-brand { text-align: center; margin-bottom: 1.75rem; }

.ph-login-logo {
    display: inline-flex;
    width: 56px;
    height: 56px;
    background: var(--ph-primary);
    color: #fff;
    font-weight: 700;
    font-size: 1.25rem;
    border-radius: 14px;
    align-items: center;
    justify-content: center;
    margin-bottom: .75rem;
}

.ph-login-logo--image {
    width: 84px;
    height: 84px;
    background: transparent;
    border-radius: 18px;
    object-fit: contain;
    margin-bottom: 1rem;
    box-shadow: 0 8px 20px rgba(37, 99, 235, .18);
}

@media (max-width: 480px) {
    .ph-login-logo--image { width: 72px; height: 72px; }
}

.ph-login-title { font-size: 1.5rem; font-weight: 700; margin: 0; }

.ph-login-brandmark {
    font-size: 1.875rem;
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: -0.015em;
    margin-bottom: .5rem;
}

.ph-login-title-parcel { color: var(--ph-dark); }
.ph-login-title-hub { color: var(--ph-primary); }

@media (max-width: 480px) {
    .ph-login-brandmark { font-size: 1.625rem; }
}

.ph-login-subtitle { margin: .25rem 0 0; color: var(--ph-text-muted); font-size: .9rem; }
.ph-login-label { font-weight: 500; font-size: .875rem; }
.ph-login-input { border-radius: 8px; padding: .6rem .85rem; }
.ph-login-btn { border-radius: 8px; padding: .65rem; font-weight: 600; }
.ph-login-alert { border-radius: 8px; font-size: .875rem; margin-bottom: 1rem; }
.ph-login-footer-text { text-align: center; margin-top: 1.25rem; font-size: .75rem; color: var(--ph-text-muted); }
.ph-login-link {
    color: var(--ph-primary);
    font-size: .875rem;
    text-decoration: none;
    font-weight: 500;
}
.ph-login-link:hover { text-decoration: underline; color: var(--ph-primary); }
.ph-access-denied-icon {
    font-size: 3rem;
    line-height: 1;
    margin-bottom: .5rem;
    color: var(--ph-danger, #dc3545);
}

.ph-access-denied-status {
    display: inline-block;
    background: rgba(220, 53, 69, .1);
    color: var(--ph-danger, #dc3545);
    font-weight: 600;
    font-size: .75rem;
    letter-spacing: .08em;
    text-transform: uppercase;
    padding: .25rem .65rem;
    border-radius: 999px;
}

/* ── Módulo Tracking ───────────────────────────────────── */
.ph-tracking-page {
    display: block;
    width: 100%;
}

.ph-tracking-summary {
    border-left: 4px solid var(--ph-primary);
}

.ph-tracking-number-label,
.ph-tracking-meta-label {
    font-size: .75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--ph-text-muted);
    margin-bottom: .25rem;
}

.ph-tracking-number-value {
    font-size: 1.25rem;
    font-weight: 700;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    word-break: break-all;
}

.ph-tracking-carrier {
    font-size: .8rem;
}

/* Timeline enterprise */
.ph-tracking-timeline {
    list-style: none;
    margin: 0;
    padding: 0;
    position: relative;
}

.ph-tracking-timeline-item {
    display: flex;
    gap: 1.15rem;
    padding-bottom: 1.75rem;
    position: relative;
}

    .ph-tracking-timeline-item:last-child {
        padding-bottom: 0;
    }

    .ph-tracking-timeline-item:not(:last-child)::before {
        content: "";
        position: absolute;
        left: 17px;
        top: 38px;
        bottom: 0;
        width: 2px;
        background: var(--ph-border);
    }

.ph-tracking-timeline-marker {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--ph-bg);
    border: 2px solid var(--ph-border);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    z-index: 1;
    color: var(--ph-text-muted);
    font-size: 1rem;
}

.ph-tracking-timeline-item.is-current .ph-tracking-timeline-marker {
    background: var(--ph-primary-soft);
    border-color: var(--ph-primary);
    color: var(--ph-primary);
    box-shadow: 0 0 0 4px rgba(var(--ph-primary-rgb), .12);
}

.ph-tracking-timeline-content {
    flex: 1 1 auto;
    background: var(--ph-surface);
    border: 1px solid var(--ph-border);
    border-radius: var(--ph-radius);
    padding: .9rem 1rem;
    box-shadow: var(--ph-shadow-sm);
}

.ph-tracking-timeline-item.is-current .ph-tracking-timeline-content {
    border-color: var(--ph-primary);
    background: linear-gradient(180deg, var(--ph-primary-soft) 0%, var(--ph-surface) 100%);
}

.ph-tracking-timeline-date {
    font-size: .8rem;
    color: var(--ph-text-muted);
}

.ph-tracking-timeline-desc {
    font-size: .925rem;
    color: var(--ph-text);
    margin: 0;
}

.ph-tracking-timeline-location {
    font-size: .8rem;
    color: var(--ph-text-muted);
}

.ph-tracking-timeline-code {
    font-family: var(--ph-mono, "SFMono-Regular", Consolas, monospace);
    font-size: .75rem;
    color: var(--ph-text-muted);
    background: var(--ph-bg);
    padding: .15rem .4rem;
    border-radius: 4px;
    border: 1px solid var(--ph-border);
}

.ph-tracking-timeline-image-link {
    font-size: .8rem;
    color: var(--ph-primary);
    text-decoration: none;
    border: 1px dashed var(--ph-border);
    border-radius: 6px;
    padding: .35rem .65rem;
    background: var(--ph-bg);
    transition: background var(--ph-transition);
}

    .ph-tracking-timeline-image-link:hover {
        background: var(--ph-primary-soft);
        text-decoration: none;
    }

@media (max-width: 575.98px) {
    .ph-tracking-number-value {
        font-size: 1rem;
    }
}
