/* =============================================
   SHARPFOOTY — REUSABLE UI COMPONENTS
   All classes prefixed with sf- to avoid
   collisions with page-specific styles.
   ============================================= */

/* === CARD === */
.sf-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
}

.sf-card-elevated {
    background: var(--bg-elevated);
}

.sf-card-flush {
    padding: 0;
}

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

.sf-card-title {
    font-size: var(--text-sm);
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* === BADGE / PILL === */
.sf-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: 2px 10px;
    border-radius: 9999px;
    font-size: var(--text-xs);
    font-weight: 700;
    letter-spacing: 0.03em;
    white-space: nowrap;
    line-height: 1.6;
}

.sf-badge-green {
    background: var(--green-dim);
    color: var(--green);
}

.sf-badge-amber {
    background: var(--amber-dim);
    color: var(--amber);
}

.sf-badge-red {
    background: var(--red-dim);
    color: var(--red);
}

.sf-badge-blue {
    background: var(--accent-dim);
    color: var(--accent);
}

.sf-badge-muted {
    background: rgba(107,114,128,0.15);
    color: var(--text-muted);
}

/* Squared variant */
.sf-badge-square {
    border-radius: var(--radius-sm);
}

/* Uppercase variant */
.sf-badge-upper {
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

/* === STAT DISPLAY === */
.sf-stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sf-stat-label {
    font-size: var(--text-xs);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
}

.sf-stat-value {
    font-family: var(--font-mono);
    font-size: var(--text-2xl);
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
    letter-spacing: -0.02em;
}

.sf-stat-value-sm {
    font-size: var(--text-lg);
}

.sf-stat-value-lg {
    font-size: var(--text-3xl);
}

.sf-stat-trend {
    font-size: var(--text-sm);
    font-weight: 600;
    font-family: var(--font-mono);
}

.sf-stat-trend-up { color: var(--green); }
.sf-stat-trend-down { color: var(--red); }
.sf-stat-trend-flat { color: var(--text-muted); }

/* Stat grid layout */
.sf-stat-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-3);
}

.sf-stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    text-align: center;
}

@media (max-width: 1024px) {
    .sf-stat-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
    .sf-stat-grid { grid-template-columns: 1fr; }
}

/* === EDGE INDICATOR === */
.sf-edge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    font-weight: 700;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
}

.sf-edge-positive {
    background: var(--green-dim);
    color: var(--green);
}

.sf-edge-negative {
    background: var(--red-dim);
    color: var(--red);
}

.sf-edge-neutral {
    background: var(--amber-dim);
    color: var(--amber);
}

.sf-edge-label {
    font-size: var(--text-xs);
    font-family: var(--font-body);
    font-weight: 600;
    color: var(--text-muted);
    margin-left: var(--space-1);
}

/* === PROGRESS BAR === */
.sf-progress {
    height: 6px;
    background: var(--bg-elevated);
    border-radius: 3px;
    overflow: hidden;
    position: relative;
}

.sf-progress-bar {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease-out;
}

.sf-progress-green .sf-progress-bar { background: var(--green); }
.sf-progress-amber .sf-progress-bar { background: var(--amber); }
.sf-progress-red .sf-progress-bar { background: var(--red); }
.sf-progress-blue .sf-progress-bar { background: var(--accent); }

/* Larger variant */
.sf-progress-lg { height: 10px; border-radius: 5px; }
.sf-progress-lg .sf-progress-bar { border-radius: 5px; }

/* With label */
.sf-progress-labeled {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.sf-progress-labeled .sf-progress {
    flex: 1;
}

.sf-progress-labeled .sf-progress-text {
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    font-weight: 600;
    min-width: 40px;
    text-align: right;
}

/* === BUTTONS === */
.sf-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: 10px 20px;
    border-radius: var(--radius);
    font-family: var(--font-body);
    font-size: var(--text-sm);
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.15s;
    line-height: 1;
    white-space: nowrap;
    text-decoration: none;
}

.sf-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Primary (blue) */
.sf-btn-primary {
    background: var(--accent);
    color: white;
}
.sf-btn-primary:hover:not(:disabled) {
    background: var(--accent-hover);
    box-shadow: 0 2px 12px rgba(59,130,246,0.3);
}

/* Secondary (outlined) */
.sf-btn-secondary {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.sf-btn-secondary:hover:not(:disabled) {
    border-color: var(--text-muted);
    color: var(--text-primary);
    background: rgba(255,255,255,0.03);
}

/* Ghost (no border) */
.sf-btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}
.sf-btn-ghost:hover:not(:disabled) {
    color: var(--text-primary);
    background: rgba(255,255,255,0.06);
}

/* Danger (red) */
.sf-btn-danger {
    background: var(--red);
    color: white;
}
.sf-btn-danger:hover:not(:disabled) {
    background: #dc2626;
}

/* Success (green) */
.sf-btn-success {
    background: var(--green);
    color: #0f1724;
}
.sf-btn-success:hover:not(:disabled) {
    background: #16a34a;
}

/* Sizes */
.sf-btn-xs {
    padding: 4px 10px;
    font-size: var(--text-xs);
    border-radius: var(--radius-sm);
}

.sf-btn-sm {
    padding: 6px 14px;
    font-size: var(--text-xs);
}

.sf-btn-lg {
    padding: 14px 28px;
    font-size: var(--text-base);
    border-radius: var(--radius-lg);
}

/* Full width */
.sf-btn-full { width: 100%; }

/* === MODAL === */
.sf-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
    backdrop-filter: blur(4px);
}

.sf-modal-overlay.open {
    opacity: 1;
    visibility: visible;
}

.sf-modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: var(--space-6);
    max-width: 520px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    transform: scale(0.95) translateY(8px);
    transition: transform 0.2s;
}

.sf-modal-overlay.open .sf-modal {
    transform: scale(1) translateY(0);
}

.sf-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-4);
}

.sf-modal-title {
    font-size: var(--text-lg);
    font-weight: 700;
}

.sf-modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 24px;
    padding: var(--space-1);
    line-height: 1;
    border-radius: var(--radius);
    transition: color 0.15s, background 0.15s;
}

.sf-modal-close:hover {
    color: var(--text-primary);
    background: rgba(255,255,255,0.06);
}

.sf-modal-body {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    line-height: 1.7;
}

.sf-modal-footer {
    display: flex;
    gap: var(--space-3);
    justify-content: flex-end;
    margin-top: var(--space-6);
    padding-top: var(--space-4);
    border-top: 1px solid var(--border);
}

/* === TABLE === */
.sf-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    background: var(--bg-card);
    position: relative;
}

/* Scroll shadow hint on right edge */
.sf-table-wrap.has-scroll::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 24px;
    background: linear-gradient(to right, transparent, var(--bg-card));
    pointer-events: none;
    border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
}

.sf-table {
    width: 100%;
    border-collapse: collapse;
}

.sf-table th {
    font-size: var(--text-xs);
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    text-align: left;
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border);
    background: var(--bg-elevated);
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 2;
}

.sf-table td {
    padding: var(--space-3) var(--space-4);
    font-size: var(--text-sm);
    border-bottom: 1px solid rgba(45,58,74,0.4);
    vertical-align: middle;
}

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

.sf-table tbody tr {
    transition: background 0.1s;
}

.sf-table tbody tr:hover td {
    background: rgba(255,255,255,0.02);
}

/* Sortable header */
.sf-table th.sortable {
    cursor: pointer;
    user-select: none;
    transition: color 0.15s;
}

.sf-table th.sortable:hover {
    color: var(--text-secondary);
}

.sf-table th.sorted {
    color: var(--accent);
}

.sf-table .sort-icon {
    font-size: 8px;
    margin-left: 2px;
    opacity: 0.5;
}

.sf-table th.sorted .sort-icon {
    opacity: 1;
    color: var(--accent);
}

/* Alignment helpers */
.sf-table .right { text-align: right; }
.sf-table .center { text-align: center; }
.sf-table .mono { font-family: var(--font-mono); }

/* Mobile stacked variant */
@media (max-width: 640px) {
    .sf-table-stack thead { display: none; }

    .sf-table-stack tbody tr {
        display: block;
        border-bottom: 1px solid var(--border);
        padding: var(--space-3) var(--space-4);
    }

    .sf-table-stack tbody tr:last-child {
        border-bottom: none;
    }

    .sf-table-stack td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: var(--space-1) 0;
        border-bottom: none;
    }

    .sf-table-stack td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-muted);
        font-size: var(--text-xs);
        text-transform: uppercase;
        letter-spacing: 0.04em;
    }

    .sf-table-stack td.right,
    .sf-table-stack td.center {
        text-align: right;
    }
}

/* === FORM ELEMENTS === */
.sf-input {
    width: 100%;
    padding: 10px var(--space-4);
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: var(--text-sm);
    outline: none;
    transition: border-color 0.15s;
}

.sf-input:focus {
    border-color: var(--accent);
}

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

.sf-select {
    padding: 10px var(--space-8) 10px var(--space-4);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-family: var(--font-body);
    font-size: var(--text-sm);
    font-weight: 600;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%236b7280'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    outline: none;
}

.sf-select:focus {
    border-color: var(--accent);
}

/* === UTILITY CLASSES === */
.text-green { color: var(--green) !important; }
.text-red { color: var(--red) !important; }
.text-amber { color: var(--amber) !important; }
.text-accent { color: var(--accent) !important; }
.text-muted { color: var(--text-muted) !important; }
.text-secondary { color: var(--text-secondary) !important; }

.font-mono { font-family: var(--font-mono) !important; }
.font-bold { font-weight: 700 !important; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
