/* ============================================================
   Components — Buttons
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-full);
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all var(--dur-fast) var(--ease);
    white-space: nowrap;
    text-decoration: none;
}

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

.btn-primary {
    background: linear-gradient(135deg, var(--accent), hsl(30, 100%, 50%));
    color: #fff;
    box-shadow: var(--shadow-sm);
}
.btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: var(--shadow-glow);
}
.btn-primary:active:not(:disabled) { transform: scale(0.97); }

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
}
.btn-secondary:hover:not(:disabled) {
    background: var(--bg-surface);
    border-color: var(--border-hover);
}

.btn-danger {
    background: hsl(0, 84%, 25%);
    color: var(--status-danger);
    border: 1px solid hsla(0, 84%, 60%, 0.3);
}
.btn-danger:hover:not(:disabled) {
    background: hsl(0, 84%, 30%);
    border-color: hsl(0, 84%, 60%);
}

.btn-success {
    background: hsl(142, 71%, 20%);
    color: var(--status-active);
    border: 1px solid hsla(142, 71%, 45%, 0.3);
}
.btn-success:hover:not(:disabled) { background: hsl(142, 71%, 25%); }

.btn-warning {
    background: hsl(38, 92%, 20%);
    color: var(--status-warning);
    border: 1px solid hsla(38, 92%, 50%, 0.3);
}
.btn-warning:hover:not(:disabled) { background: hsl(38, 92%, 25%); }

.btn-sm { padding: 6px 14px; font-size: var(--text-xs); }
.btn-lg { padding: 14px 32px; font-size: var(--text-base); }
.btn-icon { width: 38px; height: 38px; padding: 0; border-radius: var(--radius-md); }
.btn-icon-sm { width: 30px; height: 30px; padding: 0; border-radius: var(--radius-sm); font-size: var(--text-xs); }

/* Loading state */
.btn.loading { pointer-events: none; }
.btn.loading .btn-text { opacity: 0; }
.btn.loading::after {
    content: '';
    width: 14px; height: 14px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    position: absolute;
}

/* ============================================================
   Components — Cards
   ============================================================ */

/* Stat Card */
.stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    position: relative;
    overflow: hidden;
    transition: transform var(--dur-normal) var(--ease), box-shadow var(--dur-normal) var(--ease);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.stat-card::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 4px;
}
.stat-card.active::before  { background: var(--status-active); }
.stat-card.idle::before    { background: var(--status-idle); }
.stat-card.danger::before  { background: var(--status-danger); }
.stat-card.info::before    { background: var(--accent); }

.stat-card-label {
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.stat-card-value {
    font-size: var(--text-3xl);
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1;
}

.stat-card-sub {
    font-size: var(--text-xs);
    color: var(--text-secondary);
    margin-top: 8px;
}

/* Device Card */
.device-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: box-shadow var(--dur-normal) var(--ease), transform var(--dur-normal) var(--ease);
    animation: fadeInUp var(--dur-slow) var(--ease);
}
.device-card:hover { box-shadow: var(--shadow-md); }

.device-card.status-active  { border-left: 4px solid var(--status-active); }
.device-card.status-warning { border-left: 4px solid var(--status-warning);
                               animation: pulseWarning 2s ease-in-out infinite; }
.device-card.status-expired { border-left: 4px solid var(--status-danger);
                               animation: blinkDanger 1s ease-in-out infinite; }
.device-card.status-idle    { border-left: 4px solid var(--status-idle); opacity: 0.85; }
.device-card.status-offline { border-left: 4px solid var(--status-offline); opacity: 0.6; }

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

.device-card-name {
    font-weight: 700;
    font-size: var(--text-base);
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: 600;
}

.status-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
}

.status-badge.active  { background: hsla(142, 71%, 45%, 0.15); color: var(--status-active); }
.status-badge.active .status-dot { background: var(--status-active); animation: livePulse 2s ease-in-out infinite; }
.status-badge.warning { background: hsla(38, 92%, 50%, 0.15); color: var(--status-warning); }
.status-badge.warning .status-dot { background: var(--status-warning); }
.status-badge.expired { background: hsla(0, 84%, 60%, 0.15); color: var(--status-danger); }
.status-badge.expired .status-dot { background: var(--status-danger); animation: livePulse 0.8s ease-in-out infinite; }
.status-badge.idle    { background: hsla(215, 20%, 45%, 0.15); color: var(--status-idle); }
.status-badge.idle .status-dot { background: var(--status-idle); }
.status-badge.offline { background: hsla(0, 0%, 40%, 0.15); color: var(--status-offline); }
.status-badge.offline .status-dot { background: var(--status-offline); }

.device-card-body { padding: 16px; }

/* Countdown timer */
.device-countdown {
    font-family: var(--font-mono);
    font-size: 2.5rem;
    font-weight: 700;
    text-align: center;
    letter-spacing: -0.02em;
    padding: 8px 0;
    color: var(--text-primary);
    transition: color var(--dur-slow) var(--ease);
}
.device-countdown.warning { color: var(--status-warning); }
.device-countdown.expired { color: var(--status-danger); }

/* Progress bar */
.progress-wrap { margin: 8px 0; }
.progress-bar-track {
    height: 6px;
    background: var(--bg-surface);
    border-radius: var(--radius-full);
    overflow: hidden;
}
.progress-bar-fill {
    height: 100%;
    border-radius: var(--radius-full);
    background: linear-gradient(90deg, var(--status-active), hsl(160, 70%, 55%));
    transition: width 1s linear;
}
.progress-bar-fill.warning { background: linear-gradient(90deg, var(--status-warning), hsl(45, 90%, 55%)); }
.progress-bar-fill.expired { background: var(--status-danger); }

.progress-pct {
    font-size: var(--text-xs);
    color: var(--text-secondary);
    text-align: right;
    margin-top: 4px;
}

.device-info-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin: 4px 0;
}

.device-times {
    display: flex;
    justify-content: space-between;
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}

.device-card-actions {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    background: var(--bg-primary);
}

/* General card */
.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

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

.card-title {
    font-weight: 700;
    font-size: var(--text-base);
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-body { padding: 20px; }
