/* ═══════════════════════════════════════════════════════════════════════════
   FERRÓN DS — Components
   Reusable UI components for FER System
   ═══════════════════════════════════════════════════════════════════════════ */

/* ─── Buttons ────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--s2);
    padding: 10px 20px;
    border-radius: var(--radius);
    font-family: var(--font-body);
    font-size: var(--text-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s var(--ease);
    white-space: nowrap;
    border: none;
    text-decoration: none;
}
.btn-primary {
    background: var(--amber);
    color: var(--text-inverse);
    border: 1px solid transparent;
    /* Bio-Organic inner glow */
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.10);
}
.btn-primary:hover {
    background: var(--amber-hot);
    box-shadow: var(--amber-glow), inset 0 1px 0 rgba(255,255,255,0.10);
    transform: translateY(-1px);
}
.btn-primary:active { background: var(--amber-dim); transform: translateY(0); }

.btn-ghost {
    background: rgba(255,255,255,0.05);
    color: var(--text-primary);
    border: 1px solid var(--border-default);
    backdrop-filter: blur(8px);
}
.btn-ghost:hover {
    background: rgba(255,255,255,0.09);
    border-color: var(--border-strong);
    transform: translateY(-1px);
}

.btn-danger { background: var(--error-ghost); color: var(--error); border: 1px solid rgba(255,61,113,0.30); }
.btn-danger:hover { background: rgba(255,61,113,0.20); box-shadow: 0 0 15px rgba(255,61,113,0.20); }

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    justify-content: center;
    border-radius: var(--radius);
    background: var(--bg-elevated);
    color: var(--text-muted);
    border: 1px solid var(--border-subtle);
}
.btn-icon:hover { background: var(--amber-ghost); color: var(--amber); border-color: var(--amber-border); }
.btn-sm { padding: 6px 12px; font-size: var(--text-xs); }
.btn-lg { padding: 14px 28px; font-size: var(--text-base); }

/* ─── Cards ──────────────────────────────────────────────────────────────── */
.card {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    padding: var(--s6);
    transition: all 0.3s var(--ease);
    position: relative;
    overflow: hidden;
}
.card-hover:hover {
    background: var(--bg-raised);
    transform: translateY(-3px);
    box-shadow: 0 8px 32px rgba(0,0,0,0.30), var(--amber-ambient);
}
.card-active {
    background: var(--gradient-card-active);
    border-left: 2px solid var(--cyan);
    box-shadow: var(--cyan-glow);
}
.card-glass {
    background: var(--bg-glass);
    backdrop-filter: blur(24px);
    border: 1px solid var(--border-ghost);
}

/* KPI Card */
.kpi-card {
    display: flex;
    flex-direction: column;
    gap: var(--s3);
    padding: var(--s5) var(--s6);
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    transition: all 0.3s var(--ease);
    overflow: hidden;
    position: relative;
}
.kpi-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent 0%, var(--amber-border) 50%, transparent 100%);
}
.kpi-card__label { font-size: var(--text-xs); color: var(--text-muted); font-family: var(--font-data); text-transform: uppercase; letter-spacing: 0.10em; }
.kpi-card__value { font-size: var(--text-display); font-family: var(--font-display); color: var(--text-primary); line-height: 1; }
.kpi-card__delta { font-size: var(--text-xs); display: flex; align-items: center; gap: var(--s1); }
.kpi-card:hover { background: var(--bg-raised); box-shadow: var(--amber-ambient); }

/* Progress bar */
.progress-bar { width: 100%; height: 3px; background: var(--bg-elevated); border-radius: var(--radius-full); overflow: hidden; margin-top: var(--s2); }
.progress-bar__fill { height: 100%; background: var(--amber); border-radius: var(--radius-full); transition: width 0.8s var(--ease); }
.progress-bar__fill--cyan { background: var(--cyan); }
.progress-bar__fill--success { background: var(--success); }

/* ─── Module App Cards (Dashboard Grid) ──────────────────────────────────── */
.app-card {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    padding: var(--s6);
    display: flex;
    flex-direction: column;
    gap: var(--s4);
    cursor: pointer;
    transition: all 0.3s var(--ease-spring);
    border: 1px solid var(--border-subtle);
    text-decoration: none;
    color: inherit;
    position: relative;
    overflow: hidden;
}
.app-card::after {
    content: '→';
    position: absolute;
    bottom: var(--s6); right: var(--s6);
    font-size: var(--text-xl);
    color: var(--amber);
    opacity: 0;
    transform: translateX(-8px);
    transition: all 0.25s var(--ease);
}
.app-card:hover {
    border-color: var(--amber-border);
    box-shadow: var(--amber-glow);
    transform: translateY(-4px);
    background: var(--gradient-card-active);
}
.app-card:hover::after { opacity: 1; transform: translateX(0); }
.app-card__icon {
    width: 48px; height: 48px;
    border-radius: var(--radius-md);
    display: flex; align-items: center; justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}
.app-card__name { font-family: var(--font-body); font-size: var(--text-xl); font-weight: 600; }
.app-card__desc { font-size: var(--text-sm); color: var(--text-muted); }

/* ─── Badges ─────────────────────────────────────────────────────────────── */
.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-family: var(--font-data);
    font-weight: 600;
    white-space: nowrap;
}
.badge::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: 0.7; }
.badge-active    { background: var(--success-ghost); color: var(--success); }
.badge-inactive  { background: var(--error-ghost);   color: var(--error); }
.badge-pending   { background: var(--warning-ghost);  color: var(--warning); }
.badge-checkin   { background: var(--cyan-ghost);     color: var(--cyan); }
.badge-device    { background: var(--amber-ghost);    color: var(--amber); }

/* ─── Data Table ─────────────────────────────────────────────────────────── */
.data-table-wrapper {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    overflow: hidden;
}
.data-table { width: 100%; border-collapse: collapse; }
.data-table thead th {
    background: var(--bg-elevated);
    font-family: var(--font-data);
    font-size: var(--text-xs);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.10em;
    color: var(--text-muted);
    padding: var(--s3) var(--s4);
    text-align: left;
    white-space: nowrap;
    border-bottom: 1px solid var(--border-default);
}
.data-table tbody tr {
    border-bottom: 1px solid var(--border-subtle);
    transition: background 0.15s ease;
}
.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody tr:hover { background: var(--bg-raised); }
.data-table tbody tr.selected {
    background: var(--amber-ghost);
    border-left: 2px solid var(--amber);
}
.data-table td {
    padding: var(--s3) var(--s4);
    font-size: var(--text-sm);
    vertical-align: middle;
    color: var(--text-primary);
}
.data-table .td-mono { font-family: var(--font-data); font-size: var(--text-xs); color: var(--text-secondary); }

/* ─── Avatar ─────────────────────────────────────────────────────────────── */
.avatar {
    width: 36px; height: 36px;
    border-radius: var(--radius-full);
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-display);
    font-size: var(--text-xs);
    font-weight: 700;
    flex-shrink: 0;
    overflow: hidden;
    color: var(--text-inverse);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { width: 28px; height: 28px; font-size: 10px; }
.avatar-lg { width: 56px; height: 56px; font-size: var(--text-lg); }
.avatar-xl { width: 96px; height: 96px; font-size: var(--text-3xl); }
.avatar-biometric { position: relative; }
.avatar-biometric::after {
    content: '🧬';
    position: absolute;
    bottom: -2px; right: -2px;
    font-size: 10px;
    background: var(--bg-surface);
    border-radius: 50%;
    width: 14px; height: 14px;
    display: flex; align-items: center; justify-content: center;
}

/* ─── Form Inputs ────────────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: var(--s2); }
.form-label {
    font-size: var(--text-xs);
    font-family: var(--font-data);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    font-weight: 500;
}
.input, .select, .textarea {
    background: var(--bg-overlay);
    border: 1px solid var(--border-default);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: var(--text-sm);
    padding: 10px 14px;
    transition: all 0.2s ease;
    width: 100%;
    outline: none;
}
.input::placeholder, .textarea::placeholder { color: var(--text-disabled); }
.input:focus, .select:focus, .textarea:focus {
    border-color: var(--amber);
    box-shadow: 0 0 0 3px var(--amber-ghost);
}
.input-error { border-color: var(--error) !important; }
.input-success { border-color: var(--success) !important; }
.select { appearance: none; cursor: pointer; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%238899AA' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14L2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; background-size: 10px; padding-right: 32px; }
.textarea { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s4); }


/* ─── Modal / Drawer ─────────────────────────────────────────────────────── */
.modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(8,11,15,0.75);
    backdrop-filter: blur(4px);
    z-index: 100;
    display: flex; align-items: center; justify-content: center;
    animation: fadeIn 0.2s ease;
}
.modal {
    background: var(--bg-surface);
    border-radius: var(--radius-xl);
    padding: var(--s8);
    max-width: 560px;
    width: calc(100% - 2rem);
    max-height: 90vh;
    overflow-y: auto;
    border: 1px solid var(--border-ghost);
    box-shadow: 0 32px 64px rgba(0,0,0,0.50), var(--amber-ambient);
    animation: slideUp 0.3s var(--ease);
}
.modal__header { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--s6); }
.modal__title { font-size: var(--text-xl); font-weight: 700; font-family: var(--font-display); }
.modal__close { width: 32px; height: 32px; border-radius: var(--radius); background: var(--bg-elevated); color: var(--text-muted); display: flex; align-items: center; justify-content: center; cursor: pointer; transition: all 0.2s ease; }
.modal__close:hover { background: var(--error-ghost); color: var(--error); }

.drawer {
    position: fixed; top: 0; right: 0; bottom: 0;
    width: 380px;
    background: var(--bg-surface);
    border-left: 1px solid var(--border-ghost);
    z-index: 90;
    overflow-y: auto;
    transform: translateX(100%);
    transition: transform 0.35s var(--ease);
    box-shadow: -16px 0 48px rgba(0,0,0,0.30);
}
.drawer.open { transform: translateX(0); }

/* ─── Stepper (Wizard) ───────────────────────────────────────────────────── */
.stepper { display: flex; align-items: center; gap: 0; margin-bottom: var(--s8); }
.step {
    display: flex; flex-direction: column; align-items: center;
    gap: var(--s2); flex: 1; position: relative;
}
.step:not(:last-child)::after {
    content: '';
    position: absolute;
    top: 16px; left: 50%; width: 100%;
    height: 1px; background: var(--border-default);
    z-index: 0;
}
.step.done::after    { background: var(--success); }
.step.active::after  { background: var(--border-default); }
.step__dot {
    width: 32px; height: 32px;
    border-radius: var(--radius-full);
    display: flex; align-items: center; justify-content: center;
    font-size: var(--text-xs); font-family: var(--font-data); font-weight: 700;
    position: relative; z-index: 1;
    border: 2px solid var(--border-default);
    background: var(--bg-void);
    color: var(--text-muted);
    transition: all 0.3s var(--ease);
}
.step.active .step__dot  { border-color: var(--amber); color: var(--amber); box-shadow: var(--amber-glow); background: var(--amber-ghost); }
.step.done .step__dot    { border-color: var(--success); color: var(--success); background: var(--success-ghost); }
.step__label { font-size: var(--text-xs); color: var(--text-muted); text-align: center; }
.step.active .step__label { color: var(--amber); }
.step.done .step__label   { color: var(--success); }

/* ─── Alerts / Notifications ─────────────────────────────────────────────── */
.alert {
    padding: var(--s3) var(--s4);
    border-radius: var(--radius);
    font-size: var(--text-sm);
    display: flex; align-items: center; gap: var(--s3);
    border: 1px solid transparent;
}
.alert-success { background: var(--success-ghost); color: var(--success); border-color: rgba(0,230,118,0.20); }
.alert-error   { background: var(--error-ghost);   color: var(--error);   border-color: rgba(255,61,113,0.20); }
.alert-warning { background: var(--warning-ghost);  color: var(--warning); border-color: rgba(255,214,0,0.20); }
.alert-info    { background: var(--cyan-ghost);     color: var(--cyan);    border-color: rgba(0,217,255,0.20); }

/* ─── Divider ────────────────────────────────────────────────────────────── */
.divider { height: 1px; background: var(--border-subtle); margin: var(--s6) 0; }
.divider-text { display: flex; align-items: center; gap: var(--s4); color: var(--text-muted); font-size: var(--text-xs); font-family: var(--font-data); text-transform: uppercase; letter-spacing: 0.08em; }
.divider-text::before, .divider-text::after { content: ''; flex: 1; height: 1px; background: var(--border-subtle); }

/* ─── Navigation Tabs ────────────────────────────────────────────────────── */
.tabs { display: flex; gap: var(--s1); border-bottom: 1px solid var(--border-subtle); margin-bottom: var(--s6); }
.tab {
    padding: var(--s3) var(--s5);
    font-size: var(--text-sm); font-family: var(--font-body); font-weight: 500;
    color: var(--text-muted); cursor: pointer;
    border-bottom: 2px solid transparent; margin-bottom: -1px;
    transition: all 0.2s ease;
    white-space: nowrap;
}
.tab:hover { color: var(--text-primary); }
.tab.active { color: var(--amber); border-bottom-color: var(--amber); }

/* ─── Search Bar ─────────────────────────────────────────────────────────── */
.search-bar {
    position: relative; flex: 1;
}
.search-bar__icon {
    position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
    color: var(--text-muted); pointer-events: none; font-size: 14px;
}
.search-bar .input { padding-left: 36px; }

/* ─── Chip / Tag ─────────────────────────────────────────────────────────── */
.chip {
    display: inline-flex; align-items: center; gap: var(--s1);
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: var(--text-xs); font-weight: 500;
    background: var(--bg-elevated);
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
    cursor: pointer; transition: all 0.15s ease;
}
.chip:hover { border-color: var(--amber-border); color: var(--amber); background: var(--amber-ghost); }
.chip.selected { background: var(--amber-ghost); color: var(--amber); border-color: var(--amber-border); }

/* ─── Loading Spinner ────────────────────────────────────────────────────── */
.spinner {
    width: 20px; height: 20px;
    border: 2px solid var(--border-default);
    border-top-color: var(--amber);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Tooltip ────────────────────────────────────────────────────────────── */
[data-tooltip] { position: relative; }
[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px); left: 50%;
    transform: translateX(-50%);
    background: var(--bg-overlay);
    color: var(--text-primary);
    padding: 4px 10px;
    border-radius: var(--radius);
    font-size: var(--text-xs);
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
    border: 1px solid var(--border-default);
    z-index: 50;
}
[data-tooltip]:hover::after { opacity: 1; }

/* ─── Empty State ────────────────────────────────────────────────────────── */
.empty-state {
    display: flex; flex-direction: column; align-items: center;
    justify-content: center; gap: var(--s4);
    padding: var(--s16);
    text-align: center;
    color: var(--text-muted);
}
.empty-state__icon { font-size: 48px; opacity: 0.4; }
.empty-state__title { font-size: var(--text-xl); font-weight: 600; color: var(--text-secondary); }
.empty-state__desc  { font-size: var(--text-sm); max-width: 320px; }
