/* ============================================
   PATRIOT TECH SYSTEMS - COMPONENT STYLES
   Cards, Tables, Badges, Alerts, Buttons, Forms,
   Toasts, Skeleton Loaders, Empty States
   ============================================ */

/* ---- METRIC CARDS ---- */
.pt-metric-card {
    background: var(--pt-card-bg);
    border: 1px solid var(--pt-card-border);
    border-radius: var(--pt-card-radius);
    padding: var(--pt-card-padding);
    position: relative;
    overflow: hidden;
    transition: all 0.2s ease;
}

.pt-metric-card:hover {
    border-color: var(--pt-border-accent);
    transform: translateY(-2px);
    box-shadow: var(--pt-shadow-md);
}

.pt-metric-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--pt-gradient-primary);
    opacity: 0;
    transition: opacity 0.2s;
}

.pt-metric-card:hover::before {
    opacity: 1;
}

.pt-metric-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--pt-space-3);
}

.pt-metric-label {
    font-size: var(--pt-text-sm);
    color: var(--pt-text-muted);
    font-weight: var(--pt-font-medium);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.pt-metric-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--pt-radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.pt-metric-icon.primary { background: rgba(58, 123, 213, 0.15); color: var(--pt-color-blue-400); }
.pt-metric-icon.accent  { background: rgba(201, 168, 76, 0.15); color: var(--pt-color-gold-400); }
.pt-metric-icon.success { background: var(--pt-status-success-bg); color: var(--pt-color-green-400); }
.pt-metric-icon.warning { background: var(--pt-status-warning-bg); color: var(--pt-color-yellow-400); }
.pt-metric-icon.danger  { background: var(--pt-status-danger-bg); color: var(--pt-color-red-400); }

.pt-metric-value {
    font-size: var(--pt-text-3xl);
    font-weight: var(--pt-font-bold);
    color: var(--pt-text-primary);
    line-height: 1;
    margin-bottom: var(--pt-space-2);
}

.pt-metric-change {
    display: inline-flex;
    align-items: center;
    gap: var(--pt-space-1);
    font-size: var(--pt-text-sm);
    font-weight: var(--pt-font-semibold);
    padding: 0.15rem var(--pt-space-2);
    border-radius: var(--pt-radius-sm);
}

.pt-metric-change.up   { color: var(--pt-color-green-400); background: var(--pt-status-success-bg); }
.pt-metric-change.down { color: var(--pt-color-red-400); background: var(--pt-status-danger-bg); }
.pt-metric-change.flat { color: var(--pt-text-muted); background: rgba(255,255,255,0.05); }

.pt-metric-subtitle {
    font-size: var(--pt-text-sm);
    color: var(--pt-text-muted);
    margin-top: var(--pt-space-1);
}


/* ---- CARDS (GENERAL) ---- */
.pt-card {
    background: var(--pt-card-bg);
    border: 1px solid var(--pt-card-border);
    border-radius: var(--pt-card-radius);
    padding: var(--pt-card-padding);
}

.pt-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: var(--pt-space-4);
    border-bottom: 1px solid var(--pt-border-default);
    margin-bottom: var(--pt-space-4);
}

.pt-card-title {
    font-size: var(--pt-text-md);
    font-weight: var(--pt-font-semibold);
    color: var(--pt-text-primary);
}

.pt-card-body {
    /* Container for card content */
}

.pt-card-footer {
    padding-top: var(--pt-space-4);
    border-top: 1px solid var(--pt-border-default);
    margin-top: var(--pt-space-4);
}

/* Clickable card variant */
.pt-card-clickable {
    cursor: pointer;
    transition: all 0.2s ease;
}

.pt-card-clickable:hover {
    border-color: var(--pt-border-accent);
    transform: translateY(-2px);
    box-shadow: var(--pt-shadow-md);
}


/* ---- TABLES ---- */
.pt-table-wrapper {
    overflow-x: auto;
    border-radius: var(--pt-card-radius);
    border: 1px solid var(--pt-table-border);
}

.pt-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--pt-text-base);
}

.pt-table thead {
    background: var(--pt-table-header-bg);
}

.pt-table th {
    padding: var(--pt-space-3) var(--pt-space-4);
    text-align: left;
    font-weight: var(--pt-font-semibold);
    font-size: var(--pt-text-sm);
    color: var(--pt-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--pt-table-border);
    white-space: nowrap;
}

.pt-table td {
    padding: var(--pt-space-3) var(--pt-space-4);
    border-bottom: 1px solid var(--pt-table-border);
    color: var(--pt-text-primary);
    vertical-align: middle;
}

.pt-table tbody tr {
    transition: background var(--pt-transition-fast);
}

.pt-table tbody tr:hover {
    background: var(--pt-table-row-hover);
}

.pt-table tbody tr:last-child td {
    border-bottom: none;
}

/* Sortable table headers */
.pt-table th.sortable {
    cursor: pointer;
    user-select: none;
}

.pt-table th.sortable:hover {
    color: var(--pt-text-primary);
}

.pt-table th.sortable::after {
    content: "\F148";
    font-family: "bootstrap-icons";
    margin-left: var(--pt-space-1);
    opacity: 0.3;
    font-size: 0.7rem;
}

.pt-table th.sortable.asc::after {
    content: "\F148";
    opacity: 1;
    color: var(--pt-interactive-accent);
}

.pt-table th.sortable.desc::after {
    content: "\F128";
    opacity: 1;
    color: var(--pt-interactive-accent);
}


/* ---- BADGES ---- */
.pt-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--pt-space-1);
    padding: var(--pt-badge-padding);
    border-radius: var(--pt-badge-radius);
    font-size: var(--pt-badge-font-size);
    font-weight: var(--pt-font-semibold);
    line-height: 1;
    white-space: nowrap;
}

.pt-badge-primary { background: rgba(58, 123, 213, 0.15); color: var(--pt-color-blue-300); }
.pt-badge-accent  { background: rgba(201, 168, 76, 0.15); color: var(--pt-color-gold-300); }
.pt-badge-success { background: var(--pt-status-success-bg); color: var(--pt-color-green-400); }
.pt-badge-warning { background: var(--pt-status-warning-bg); color: var(--pt-color-yellow-400); }
.pt-badge-danger  { background: var(--pt-status-danger-bg); color: var(--pt-color-red-400); }
.pt-badge-info    { background: var(--pt-status-info-bg); color: var(--pt-color-blue-300); }
.pt-badge-muted   { background: rgba(255,255,255,0.06); color: var(--pt-text-muted); }

/* Dot variant */
.pt-badge-dot::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}


/* ---- ALERTS ---- */
.pt-alert {
    display: flex;
    align-items: flex-start;
    gap: var(--pt-space-3);
    padding: var(--pt-space-4);
    border-radius: var(--pt-radius-lg);
    border: 1px solid;
    font-size: var(--pt-text-base);
}

.pt-alert-success { background: var(--pt-status-success-bg); border-color: rgba(16, 185, 129, 0.25); color: var(--pt-color-green-300); }
.pt-alert-warning { background: var(--pt-status-warning-bg); border-color: rgba(245, 158, 11, 0.25); color: var(--pt-color-yellow-300); }
.pt-alert-danger  { background: var(--pt-status-danger-bg); border-color: rgba(239, 68, 68, 0.25); color: var(--pt-color-red-300); }
.pt-alert-info    { background: var(--pt-status-info-bg); border-color: rgba(58, 123, 213, 0.25); color: var(--pt-color-blue-300); }

.pt-alert i {
    font-size: 1.2rem;
    flex-shrink: 0;
    margin-top: 1px;
}

.pt-alert-content {
    flex: 1;
}

.pt-alert-title {
    font-weight: var(--pt-font-semibold);
    margin-bottom: var(--pt-space-1);
}

.pt-alert-dismiss {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    opacity: 0.5;
    padding: var(--pt-space-1);
    font-size: 1rem;
    transition: opacity var(--pt-transition-fast);
}

.pt-alert-dismiss:hover {
    opacity: 1;
}


/* ---- BUTTONS ---- */
.pt-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--pt-space-2);
    padding: var(--pt-btn-padding-y) var(--pt-btn-padding-x);
    border-radius: var(--pt-btn-radius);
    font-size: var(--pt-text-base);
    font-weight: var(--pt-font-medium);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--pt-transition-normal);
    font-family: inherit;
    line-height: 1.5;
    white-space: nowrap;
}

.pt-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pt-btn-primary {
    background: var(--pt-interactive-primary);
    color: var(--pt-color-white);
    border-color: var(--pt-interactive-primary);
}
.pt-btn-primary:hover:not(:disabled) {
    background: var(--pt-interactive-primary-hover);
    border-color: var(--pt-interactive-primary-hover);
}

.pt-btn-accent {
    background: var(--pt-gradient-gold);
    color: var(--pt-color-navy-800);
    border-color: var(--pt-interactive-accent);
    font-weight: var(--pt-font-semibold);
}
.pt-btn-accent:hover:not(:disabled) {
    filter: brightness(1.1);
}

.pt-btn-outline {
    background: transparent;
    color: var(--pt-text-secondary);
    border-color: var(--pt-border-default);
}
.pt-btn-outline:hover:not(:disabled) {
    background: var(--pt-bg-surface);
    color: var(--pt-text-primary);
    border-color: var(--pt-border-accent);
}

.pt-btn-ghost {
    background: transparent;
    color: var(--pt-text-secondary);
    border-color: transparent;
}
.pt-btn-ghost:hover:not(:disabled) {
    background: var(--pt-bg-surface);
    color: var(--pt-text-primary);
}

.pt-btn-danger {
    background: var(--pt-status-danger);
    color: var(--pt-color-white);
    border-color: var(--pt-status-danger);
}
.pt-btn-danger:hover:not(:disabled) {
    background: var(--pt-color-red-600);
    border-color: var(--pt-color-red-600);
}

.pt-btn-sm {
    padding: 0.25rem 0.75rem;
    font-size: var(--pt-text-sm);
}

.pt-btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: var(--pt-text-md);
}


/* ---- FORM INPUTS ---- */
.pt-input {
    background: var(--pt-input-bg);
    border: 1px solid var(--pt-input-border);
    border-radius: var(--pt-input-radius);
    padding: var(--pt-input-padding);
    color: var(--pt-text-primary);
    font-size: var(--pt-text-base);
    font-family: inherit;
    transition: border-color var(--pt-transition-normal);
    width: 100%;
}

.pt-input:focus {
    border-color: var(--pt-border-focus);
    outline: none;
    box-shadow: 0 0 0 3px rgba(58, 123, 213, 0.15);
}

.pt-input::placeholder {
    color: var(--pt-text-muted);
}

.pt-select {
    appearance: none;
    background: var(--pt-input-bg);
    border: 1px solid var(--pt-input-border);
    border-radius: var(--pt-input-radius);
    padding: var(--pt-input-padding);
    padding-right: var(--pt-space-10);
    color: var(--pt-text-primary);
    font-size: var(--pt-text-base);
    font-family: inherit;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%235A7A9A' d='M6 8.825L1.175 4 2.238 2.938 6 6.7 9.763 2.937 10.825 4z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

.pt-select:focus {
    border-color: var(--pt-border-focus);
    outline: none;
    box-shadow: 0 0 0 3px rgba(58, 123, 213, 0.15);
}

.pt-label {
    display: block;
    font-size: var(--pt-text-sm);
    font-weight: var(--pt-font-medium);
    color: var(--pt-text-secondary);
    margin-bottom: var(--pt-space-2);
}

.pt-form-group {
    margin-bottom: var(--pt-space-4);
}

.pt-form-help {
    font-size: var(--pt-text-sm);
    color: var(--pt-text-muted);
    margin-top: var(--pt-space-1);
}

.pt-form-error {
    font-size: var(--pt-text-sm);
    color: var(--pt-status-danger);
    margin-top: var(--pt-space-1);
}

.pt-input.error {
    border-color: var(--pt-status-danger);
}

.pt-input.error:focus {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}


/* ---- TOAST NOTIFICATIONS ---- */
.pt-toast-container {
    position: fixed;
    top: var(--pt-space-4);
    right: var(--pt-space-4);
    z-index: var(--pt-z-toast);
    display: flex;
    flex-direction: column;
    gap: var(--pt-space-3);
    max-width: 420px;
}

.pt-toast {
    display: flex;
    align-items: flex-start;
    gap: var(--pt-space-3);
    padding: var(--pt-space-4);
    background: var(--pt-toast-bg);
    border: 1px solid var(--pt-toast-border);
    border-radius: var(--pt-toast-radius);
    box-shadow: var(--pt-shadow-lg);
    animation: ptToastIn 0.3s ease forwards;
    min-width: 320px;
}

.pt-toast.removing {
    animation: ptToastOut 0.25s ease forwards;
}

.pt-toast-success { border-left: 3px solid var(--pt-status-success); }
.pt-toast-warning { border-left: 3px solid var(--pt-status-warning); }
.pt-toast-danger  { border-left: 3px solid var(--pt-status-danger); }
.pt-toast-info    { border-left: 3px solid var(--pt-status-info); }

.pt-toast-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
    margin-top: 1px;
}

.pt-toast-success .pt-toast-icon { color: var(--pt-status-success); }
.pt-toast-warning .pt-toast-icon { color: var(--pt-status-warning); }
.pt-toast-danger  .pt-toast-icon { color: var(--pt-status-danger); }
.pt-toast-info    .pt-toast-icon { color: var(--pt-status-info); }

.pt-toast-body {
    flex: 1;
}

.pt-toast-title {
    font-weight: var(--pt-font-semibold);
    font-size: var(--pt-text-base);
    color: var(--pt-text-primary);
    margin-bottom: var(--pt-space-1);
}

.pt-toast-message {
    font-size: var(--pt-text-sm);
    color: var(--pt-text-secondary);
}

.pt-toast-close {
    background: none;
    border: none;
    color: var(--pt-text-muted);
    cursor: pointer;
    padding: var(--pt-space-1);
    font-size: 1rem;
    transition: color var(--pt-transition-fast);
}

.pt-toast-close:hover {
    color: var(--pt-text-primary);
}

@keyframes ptToastIn {
    from { opacity: 0; transform: translateX(30px); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes ptToastOut {
    from { opacity: 1; transform: translateX(0); }
    to   { opacity: 0; transform: translateX(30px); }
}


/* ---- SKELETON LOADERS ---- */
.pt-skeleton {
    background: linear-gradient(90deg,
        var(--pt-bg-surface) 25%,
        var(--pt-bg-surface-hover) 37%,
        var(--pt-bg-surface) 63%
    );
    background-size: 200% 100%;
    animation: ptSkeleton 1.5s ease infinite;
    border-radius: var(--pt-radius-md);
}

.pt-skeleton-text {
    height: 1em;
    margin-bottom: var(--pt-space-2);
}

.pt-skeleton-text:last-child {
    width: 70%;
}

.pt-skeleton-heading {
    height: 1.5em;
    width: 40%;
    margin-bottom: var(--pt-space-3);
}

.pt-skeleton-card {
    height: 120px;
}

.pt-skeleton-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

@keyframes ptSkeleton {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}


/* ---- EMPTY STATES ---- */
.pt-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--pt-space-12) var(--pt-space-8);
    text-align: center;
}

.pt-empty-state-icon {
    font-size: 3rem;
    color: var(--pt-text-muted);
    opacity: 0.5;
    margin-bottom: var(--pt-space-4);
}

.pt-empty-state-title {
    font-size: var(--pt-text-lg);
    font-weight: var(--pt-font-semibold);
    color: var(--pt-text-primary);
    margin-bottom: var(--pt-space-2);
}

.pt-empty-state-text {
    font-size: var(--pt-text-base);
    color: var(--pt-text-muted);
    max-width: 400px;
    margin-bottom: var(--pt-space-6);
}


/* ---- PROGRESS BARS ---- */
.pt-progress {
    height: 6px;
    background: var(--pt-bg-surface);
    border-radius: var(--pt-radius-full);
    overflow: hidden;
}

.pt-progress-bar {
    height: 100%;
    border-radius: var(--pt-radius-full);
    transition: width 0.5s ease;
    background: var(--pt-interactive-primary);
}

.pt-progress-bar.accent { background: var(--pt-gradient-gold); }
.pt-progress-bar.success { background: var(--pt-status-success); }
.pt-progress-bar.warning { background: var(--pt-status-warning); }
.pt-progress-bar.danger { background: var(--pt-status-danger); }


/* ---- HEALTH GRADES (C-Suite specific but reusable) ---- */
.pt-grade {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: var(--pt-radius-md);
    font-weight: var(--pt-font-bold);
    font-size: var(--pt-text-lg);
}

.pt-grade-a { background: var(--pt-status-success-bg); color: var(--pt-color-green-400); }
.pt-grade-b { background: rgba(58, 123, 213, 0.12); color: var(--pt-color-blue-400); }
.pt-grade-c { background: var(--pt-status-warning-bg); color: var(--pt-color-yellow-400); }
.pt-grade-d { background: rgba(249, 115, 22, 0.12); color: #F97316; }
.pt-grade-f { background: var(--pt-status-danger-bg); color: var(--pt-color-red-400); }


/* ---- PRODUCT SWITCHER MODAL ---- */
.pt-product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: var(--pt-space-3);
}

.pt-product-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--pt-space-2);
    padding: var(--pt-space-4);
    border: 1px solid var(--pt-border-default);
    border-radius: var(--pt-radius-lg);
    background: var(--pt-bg-surface);
    cursor: pointer;
    transition: all var(--pt-transition-normal);
    text-decoration: none;
    text-align: center;
}

.pt-product-card:hover {
    border-color: var(--pt-border-accent);
    background: var(--pt-bg-surface-hover);
    transform: translateY(-2px);
    box-shadow: var(--pt-shadow-md);
}

.pt-product-card.current {
    border-color: var(--pt-interactive-accent);
    background: rgba(201, 168, 76, 0.08);
}

.pt-product-card-icon {
    font-size: 1.5rem;
    color: var(--pt-interactive-primary);
}

.pt-product-card.current .pt-product-card-icon {
    color: var(--pt-interactive-accent);
}

.pt-product-card-name {
    font-size: var(--pt-text-sm);
    font-weight: var(--pt-font-medium);
    color: var(--pt-text-primary);
}


/* ---- MODAL / DIALOG ---- */
.pt-modal-backdrop {
    position: fixed;
    inset: 0;
    background: var(--pt-bg-overlay);
    z-index: var(--pt-z-overlay);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all var(--pt-transition-normal);
}

.pt-modal-backdrop.active {
    opacity: 1;
    visibility: visible;
}

.pt-modal {
    background: var(--pt-bg-elevated);
    border: 1px solid var(--pt-border-default);
    border-radius: var(--pt-radius-xl);
    width: 90%;
    max-width: 560px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--pt-shadow-xl);
    transform: scale(0.95);
    transition: transform var(--pt-transition-normal);
}

.pt-modal-backdrop.active .pt-modal {
    transform: scale(1);
}

.pt-modal-header {
    padding: var(--pt-space-5) var(--pt-space-6);
    border-bottom: 1px solid var(--pt-border-default);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.pt-modal-title {
    font-size: var(--pt-text-lg);
    font-weight: var(--pt-font-semibold);
    color: var(--pt-text-primary);
}

.pt-modal-body {
    padding: var(--pt-space-6);
}

.pt-modal-footer {
    padding: var(--pt-space-4) var(--pt-space-6);
    border-top: 1px solid var(--pt-border-default);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--pt-space-3);
}


/* ---- TABS ---- */
.pt-tabs {
    display: flex;
    border-bottom: 1px solid var(--pt-border-default);
    gap: 0;
}

.pt-tab {
    padding: var(--pt-space-3) var(--pt-space-4);
    font-size: var(--pt-text-base);
    font-weight: var(--pt-font-medium);
    color: var(--pt-text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all var(--pt-transition-normal);
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
    font-family: inherit;
}

.pt-tab:hover {
    color: var(--pt-text-primary);
}

.pt-tab.active {
    color: var(--pt-interactive-accent);
    border-bottom-color: var(--pt-interactive-accent);
}


/* ---- DROPDOWN ---- */
.pt-dropdown {
    position: relative;
    display: inline-block;
}

.pt-dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    min-width: 200px;
    background: var(--pt-bg-elevated);
    border: 1px solid var(--pt-border-default);
    border-radius: var(--pt-radius-lg);
    box-shadow: var(--pt-shadow-lg);
    z-index: var(--pt-z-dropdown);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all var(--pt-transition-normal);
    padding: var(--pt-space-2);
}

.pt-dropdown-menu.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.pt-dropdown-item {
    display: flex;
    align-items: center;
    gap: var(--pt-space-3);
    padding: var(--pt-space-2) var(--pt-space-3);
    border-radius: var(--pt-radius-md);
    color: var(--pt-text-secondary);
    cursor: pointer;
    font-size: var(--pt-text-base);
    transition: all var(--pt-transition-fast);
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-family: inherit;
}

.pt-dropdown-item:hover {
    background: var(--pt-bg-surface);
    color: var(--pt-text-primary);
}

.pt-dropdown-divider {
    height: 1px;
    background: var(--pt-border-default);
    margin: var(--pt-space-2) 0;
}
