/* =============================================
   KineApp — Components (Buttons, Cards, Modals, Forms, Tables, Alerts)
   ============================================= */

/* ══════════════════════════════════════════════
   BUTTONS
   ══════════════════════════════════════════════ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-5);
    font-size: var(--fs-base);
    font-weight: var(--fw-semibold);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    cursor: pointer;
    white-space: nowrap;
    line-height: 1;
    position: relative;
    overflow: hidden;
}

.btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0);
    transition: background var(--transition-fast);
}

.btn:hover::after {
    background: rgba(255, 255, 255, 0.08);
}

.btn:active {
    transform: scale(0.97);
}

.btn svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* Button Variants */
.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: white;
    box-shadow: 0 4px 14px var(--primary-glow);
}

.btn-primary:hover {
    box-shadow: 0 6px 20px var(--primary-glow);
    transform: translateY(-1px);
}

.btn-accent {
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    color: white;
}

.btn-success {
    background: linear-gradient(135deg, var(--success), var(--available-hover));
    color: white;
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger), var(--unavailable-hover));
    color: white;
}

.btn-outline {
    background: transparent;
    border: 1.5px solid var(--surface-border);
    color: var(--text-secondary);
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover {
    background: var(--surface-hover);
    color: var(--text);
}

/* Button Sizes */
.btn-sm {
    padding: var(--space-2) var(--space-3);
    font-size: var(--fs-sm);
}

.btn-sm svg {
    width: 14px;
    height: 14px;
}

.btn-lg {
    padding: var(--space-4) var(--space-8);
    font-size: var(--fs-md);
}

.btn-icon {
    padding: var(--space-3);
    width: 40px;
    height: 40px;
}

.btn-icon svg {
    width: 20px;
    height: 20px;
}

.btn-block {
    width: 100%;
}

/* ══════════════════════════════════════════════
   CARDS
   ══════════════════════════════════════════════ */

.card {
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    transition: all var(--transition-base);
}

.card:hover {
    border-color: rgba(148, 163, 184, 0.2);
}

.card-glass {
    background: var(--surface-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: var(--shadow-glass);
}

.card-interactive {
    cursor: pointer;
}

.card-interactive:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

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

.card-header h3 {
    font-size: var(--fs-lg);
    font-weight: var(--fw-semibold);
}

.card-body {
    flex: 1;
}

.card-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-3);
    margin-top: var(--space-5);
    padding-top: var(--space-4);
    border-top: 1px solid var(--surface-border);
}

/* ── Stat Cards ── */
.stat-card {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-5);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon svg {
    width: 24px;
    height: 24px;
    color: white;
}

.stat-icon.primary { background: linear-gradient(135deg, var(--primary), #3b82f6); }
.stat-icon.accent { background: linear-gradient(135deg, var(--accent), #22d3ee); }
.stat-icon.success { background: linear-gradient(135deg, var(--success), #10b981); }
.stat-icon.warning { background: linear-gradient(135deg, var(--warning), #fbbf24); }
.stat-icon.danger { background: linear-gradient(135deg, var(--danger), #f87171); }

.stat-info h4 {
    font-size: var(--fs-2xl);
    font-weight: var(--fw-extrabold);
    line-height: 1;
    margin-bottom: var(--space-1);
}

.stat-info p {
    font-size: var(--fs-sm);
    color: var(--text-secondary);
}

/* ══════════════════════════════════════════════
   FORMS
   ══════════════════════════════════════════════ */

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

.form-label {
    display: block;
    font-size: var(--fs-sm);
    font-weight: var(--fw-semibold);
    color: var(--text-secondary);
    margin-bottom: var(--space-2);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    background: var(--bg-dark);
    border: 1.5px solid var(--surface-border);
    border-radius: var(--radius-md);
    padding: var(--space-3) var(--space-4);
    color: var(--text);
    font-size: var(--fs-base);
    transition: all var(--transition-fast);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-input::placeholder,
.form-textarea::placeholder {
    color: var(--text-muted);
}

.form-textarea {
    resize: vertical;
    min-height: 100px;
}

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right var(--space-3) center;
    padding-right: var(--space-10);
}

.form-select option {
    background: var(--surface);
    color: var(--text);
}

.form-helper {
    font-size: var(--fs-xs);
    color: var(--text-muted);
    margin-top: var(--space-1);
}

.form-error {
    font-size: var(--fs-xs);
    color: var(--danger);
    margin-top: var(--space-1);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-4);
}

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

/* ── Toggle Switch ── */
.toggle {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    cursor: pointer;
}

.toggle-track {
    width: 44px;
    height: 24px;
    background: var(--surface-active);
    border-radius: var(--radius-full);
    position: relative;
    transition: background var(--transition-fast);
}

.toggle-track::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    background: white;
    border-radius: 50%;
    top: 3px;
    left: 3px;
    transition: transform var(--transition-fast);
}

.toggle.active .toggle-track {
    background: var(--primary);
}

.toggle.active .toggle-track::after {
    transform: translateX(20px);
}

/* ── File Upload ── */
.file-upload {
    border: 2px dashed var(--surface-border);
    border-radius: var(--radius-md);
    padding: var(--space-8) var(--space-6);
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.file-upload:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.file-upload svg {
    width: 40px;
    height: 40px;
    margin: 0 auto var(--space-3);
    color: var(--text-muted);
}

.file-upload p {
    font-size: var(--fs-sm);
    color: var(--text-muted);
}

/* ══════════════════════════════════════════════
   MODALS
   ══════════════════════════════════════════════ */

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: var(--z-modal-backdrop);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
    animation: fadeIn 200ms ease;
}

.modal {
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    animation: scaleIn 300ms cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: var(--z-modal);
}

.modal-lg {
    max-width: 720px;
}

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

.modal-header h3 {
    font-size: var(--fs-lg);
    font-weight: var(--fw-semibold);
}

.modal-close {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background: var(--surface-hover);
    color: var(--text);
}

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

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

/* ══════════════════════════════════════════════
   TABLES
   ══════════════════════════════════════════════ */

.table-container {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--surface-border);
}

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

.table thead {
    background: rgba(26, 86, 219, 0.1);
}

.table th {
    padding: var(--space-3) var(--space-4);
    font-size: var(--fs-xs);
    font-weight: var(--fw-semibold);
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-align: left;
    white-space: nowrap;
}

.table td {
    padding: var(--space-3) var(--space-4);
    font-size: var(--fs-base);
    border-top: 1px solid var(--surface-border);
    vertical-align: middle;
}

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

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

/* ══════════════════════════════════════════════
   BADGES & TAGS
   ══════════════════════════════════════════════ */

.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: 2px var(--space-3);
    font-size: var(--fs-xs);
    font-weight: var(--fw-semibold);
    border-radius: var(--radius-full);
    white-space: nowrap;
}

.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-accent { background: var(--accent-light); color: var(--accent); }
.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-info { background: var(--info-light); color: var(--info); }

.tag {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-1) var(--space-3);
    font-size: var(--fs-xs);
    font-weight: var(--fw-medium);
    border-radius: var(--radius-sm);
    background: var(--surface-active);
    color: var(--text-secondary);
}

/* ══════════════════════════════════════════════
   ALERTS / TOAST
   ══════════════════════════════════════════════ */

.alert {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-4);
    border-radius: var(--radius-md);
    border-left: 4px solid;
    margin-bottom: var(--space-4);
}

.alert-info {
    background: var(--info-light);
    border-left-color: var(--info);
}

.alert-success {
    background: var(--success-light);
    border-left-color: var(--success);
}

.alert-warning {
    background: var(--warning-light);
    border-left-color: var(--warning);
}

.alert-danger {
    background: var(--danger-light);
    border-left-color: var(--danger);
}

.alert svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    margin-top: 1px;
}

.alert-content p {
    font-size: var(--fs-sm);
    color: var(--text);
}

/* ── Toast notifications ── */
.toast-container {
    position: fixed;
    top: var(--space-4);
    right: var(--space-4);
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.toast {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-md);
    padding: var(--space-3) var(--space-5);
    box-shadow: var(--shadow-lg);
    animation: slideInRight 300ms ease;
    min-width: 280px;
    max-width: 400px;
}

.toast.toast-exit {
    animation: slideOutRight 300ms ease forwards;
}

@keyframes slideOutRight {
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

.toast svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.toast-success svg { color: var(--success); }
.toast-danger svg { color: var(--danger); }
.toast-warning svg { color: var(--warning); }
.toast-info svg { color: var(--info); }

.toast-message {
    flex: 1;
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
}

.toast-close {
    color: var(--text-muted);
    cursor: pointer;
    padding: var(--space-1);
}

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

/* ══════════════════════════════════════════════
   SEARCH BAR
   ══════════════════════════════════════════════ */

.search-bar {
    position: relative;
    width: 100%;
    max-width: 400px;
}

.search-bar svg {
    position: absolute;
    left: var(--space-3);
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--text-muted);
}

.search-bar input {
    width: 100%;
    background: var(--bg-dark);
    border: 1.5px solid var(--surface-border);
    border-radius: var(--radius-md);
    padding: var(--space-3) var(--space-4) var(--space-3) var(--space-10);
    color: var(--text);
    transition: all var(--transition-fast);
}

.search-bar input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* ══════════════════════════════════════════════
   EMPTY STATE
   ══════════════════════════════════════════════ */

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-16) var(--space-6);
    text-align: center;
}

.empty-state svg {
    width: 64px;
    height: 64px;
    color: var(--text-muted);
    margin-bottom: var(--space-4);
    opacity: 0.5;
}

.empty-state h4 {
    font-size: var(--fs-lg);
    color: var(--text-secondary);
    margin-bottom: var(--space-2);
}

.empty-state p {
    font-size: var(--fs-sm);
    color: var(--text-muted);
    max-width: 320px;
    margin-bottom: var(--space-6);
}

/* ══════════════════════════════════════════════
   TABS
   ══════════════════════════════════════════════ */

.tabs {
    display: flex;
    gap: var(--space-1);
    background: var(--bg-dark);
    border-radius: var(--radius-md);
    padding: var(--space-1);
    border: 1px solid var(--surface-border);
}

.tab {
    flex: 1;
    padding: var(--space-2) var(--space-4);
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    text-align: center;
    cursor: pointer;
}

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

.tab.active {
    background: var(--primary);
    color: white;
    box-shadow: var(--shadow-sm);
}

/* ══════════════════════════════════════════════
   LOADING SPINNER
   ══════════════════════════════════════════════ */

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--surface-border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.spinner-lg {
    width: 40px;
    height: 40px;
    border-width: 4px;
}

/* ══════════════════════════════════════════════
   AVATAR
   ══════════════════════════════════════════════ */

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: var(--fw-bold);
    font-size: var(--fs-sm);
    color: white;
    flex-shrink: 0;
    background: linear-gradient(135deg, var(--primary), var(--accent));
}

.avatar-sm {
    width: 32px;
    height: 32px;
    font-size: var(--fs-xs);
}

.avatar-lg {
    width: 56px;
    height: 56px;
    font-size: var(--fs-lg);
}

/* ══════════════════════════════════════════════
   DIVIDER
   ══════════════════════════════════════════════ */

.divider {
    height: 1px;
    background: var(--surface-border);
    margin: var(--space-4) 0;
}
