/* =========================================
   UI KIT (Reusable Components)
   ========================================= */

:root {
    /* Color Palette */
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #f59e0b;
    
    /* Surfaces & Text */
    --bg-main: #f3f4f6;
    --bg-surface: #ffffff;
    --text-main: #1f2937;
    --text-muted: #6b7280;
    --border-color: #e5e7eb;
    
    /* Metrics */
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;
    --transition: 0.2s ease;
}

/* --- Base --- */
* { box-sizing: border-box; }
.hidden { display: none !important; }

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all var(--transition);
    text-decoration: none;
    font-family: inherit;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn:hover:not(:disabled) {
    filter: brightness(95%);
}

.btn-primary { background: var(--primary); color: white; }
.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--bg-surface); border-color: var(--danger); color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: #fef2f2; }
.btn-outline { background: var(--bg-surface); border-color: var(--border-color); color: var(--text-main); }
.btn-outline:hover:not(:disabled) { background: #f9fafb; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn-ghost:hover:not(:disabled) { background: #f3f4f6; color: var(--text-main); }

/* --- Forms & Inputs --- */
.form-control {
    display: block;
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 14px;
    font-family: inherit;
    background: var(--bg-surface);
    color: var(--text-main);
    transition: border-color var(--transition);
}

.form-control:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
    font-family: monospace;
}

.error-text {
    color: var(--danger);
    font-size: 13px;
    margin-top: 5px;
}

/* --- Cards / Panels --- */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    overflow: hidden;
}

.card-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
}

.card-body {
    padding: 20px;
}

.card-footer {
    padding: 15px 20px;
    background: #fafafa;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* --- Modals --- */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(2px);
}

.modal {
    background: var(--bg-surface);
    padding: 25px;
    border-radius: var(--radius-lg);
    width: 400px;
    max-width: 90vw;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    max-height: 90vh;
    overflow-y: auto;
}

.modal-lg { width: 600px; }
.modal-title { margin: 0 0 10px 0; font-size: 18px; }

/* --- Spinners --- */
.spinner {
    border: 3px solid rgba(0, 0, 0, 0.1);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border-left-color: var(--primary);
    animation: spin 1s linear infinite;
}

@keyframes spin { 
    0% { transform: rotate(0deg); } 
    100% { transform: rotate(360deg); } 
}

/* --- Badges --- */
.badge {
    display: inline-flex;
    align-items: center;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 9999px;
    white-space: nowrap;
}

.badge-danger { background: var(--danger); color: white; }
.badge-success { background: var(--success); color: white; }
.badge-warning { background: var(--warning); color: white; }
.badge-outline-danger {
    background: #fef2f2;
    border: 1px solid #fca5a5;
    color: var(--danger);
}
.badge-outline-danger.active {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
}

/* --- Toasts --- */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #333;
    color: white;
    padding: 12px 24px;
    border-radius: var(--radius-md);
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s ease;
    pointer-events: none;
    z-index: 2000;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}
