/* ============================================
   LeraBot Admin — Modern Theme
   HTMX + Alpine.js + Bootstrap 5
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ---------- CSS Variables ---------- */
:root {
    --sidebar-width: 260px;
    --sidebar-bg: #1a1d23;
    --sidebar-hover: #2a2d35;
    --sidebar-active: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --success-gradient: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    --warning-gradient: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --info-gradient: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    --danger-gradient: linear-gradient(135deg, #f5576c 0%, #ff6b6b 100%);
    --body-bg: #f0f2f5;
    --card-shadow: 0 2px 12px rgba(0,0,0,0.08);
    --card-hover-shadow: 0 8px 25px rgba(0,0,0,0.15);
    --transition-speed: 0.3s;
    --border-radius: 12px;
}

/* ---------- Global ---------- */
* {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

body {
    background-color: var(--body-bg);
    color: #333;
    min-height: 100vh;
}

/* ---------- HTMX Transitions ---------- */
.htmx-swapping {
    opacity: 0;
    transition: opacity var(--transition-speed) ease-out;
}

.htmx-settling {
    opacity: 1;
    transition: opacity var(--transition-speed) ease-in;
}

.htmx-added {
    opacity: 0;
    animation: fadeSlideIn 0.4s ease forwards;
}

@keyframes fadeSlideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeSlideOut {
    from {
        opacity: 1;
        transform: translateX(0);
        max-height: 200px;
    }
    to {
        opacity: 0;
        transform: translateX(30px);
        max-height: 0;
        padding: 0;
        margin: 0;
        overflow: hidden;
    }
}

.removing {
    animation: fadeSlideOut 0.4s ease forwards;
}

/* ---------- HTMX Progress Indicator ---------- */
#htmx-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0;
    height: 3px;
    background: var(--primary-gradient);
    z-index: 9999;
    transition: width 0.4s ease;
    border-radius: 0 2px 2px 0;
}

#htmx-progress.htmx-request {
    width: 90%;
    transition: width 8s cubic-bezier(0.1, 0.05, 0, 1);
}

#htmx-progress.htmx-request.done {
    width: 100%;
    transition: width 0.1s ease;
    opacity: 0;
    transition: width 0.1s ease, opacity 0.3s ease 0.1s;
}

/* ---------- Sidebar ---------- */
.sidebar {
    width: var(--sidebar-width) !important;
    height: 100vh;
    position: fixed !important;
    top: 0;
    left: 0;
    background: var(--sidebar-bg) !important;
    color: #a0a4b0;
    padding: 0 !important;
    overflow-y: auto;
    z-index: 1040;
    transition: transform var(--transition-speed) ease;
    border-right: 1px solid rgba(255,255,255,0.05);
}

.sidebar-brand {
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-brand a {
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: #fff !important;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-brand .brand-icon {
    width: 36px;
    height: 36px;
    background: var(--primary-gradient);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: #fff;
    flex-shrink: 0;
}

.sidebar-nav {
    padding: 16px 12px;
    list-style: none;
    margin: 0;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 16px;
    color: #a0a4b0 !important;
    border-radius: 8px;
    font-size: 0.925rem;
    font-weight: 500;
    transition: all 0.2s ease;
    text-decoration: none;
    margin-bottom: 4px;
}

.sidebar-nav .nav-link:hover {
    color: #fff !important;
    background: var(--sidebar-hover);
}

.sidebar-nav .nav-link.active {
    color: #fff !important;
    background: var(--sidebar-active);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.sidebar-nav .nav-link i {
    width: 20px;
    text-align: center;
    font-size: 1rem;
}

.sidebar-footer {
    padding: 16px 12px;
    border-top: 1px solid rgba(255,255,255,0.08);
    margin-top: auto;
}

.sidebar-footer a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 16px;
    color: #a0a4b0 !important;
    border-radius: 8px;
    font-size: 0.925rem;
    font-weight: 500;
    transition: all 0.2s ease;
    text-decoration: none;
}

.sidebar-footer a:hover {
    color: #f5576c !important;
    background: rgba(245, 87, 108, 0.1);
}

/* ---------- Content Area ---------- */
.content {
    margin-left: var(--sidebar-width) !important;
    padding: 28px 32px !important;
    min-height: 100vh;
    transition: margin-left var(--transition-speed) ease;
}

/* ---------- Mobile Sidebar ---------- */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 1050;
    width: 44px;
    height: 44px;
    border-radius: 10px;
    border: none;
    background: var(--sidebar-bg);
    color: #fff;
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    transition: all 0.2s ease;
}

.sidebar-toggle:hover {
    transform: scale(1.05);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1035;
    opacity: 0;
    transition: opacity var(--transition-speed) ease;
}

.sidebar-overlay.show {
    opacity: 1;
}

@media (max-width: 991px) {
    .sidebar-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.show {
        transform: translateX(0);
    }
    
    .sidebar-overlay.show {
        display: block;
        opacity: 1;
    }
    
    .content {
        margin-left: 0 !important;
        padding: 20px 16px !important;
        padding-top: 72px !important;
    }
}

/* ---------- Cards ---------- */
.card {
    border: none;
    border-radius: var(--border-radius) !important;
    box-shadow: var(--card-shadow);
    transition: all var(--transition-speed) ease;
    overflow: hidden;
}

.card-header {
    border-bottom: none;
    font-weight: 600;
    padding: 16px 20px;
}

.card-body {
    padding: 20px;
}

/* ---------- Stat Cards (Dashboard) ---------- */
.stat-card {
    border: none;
    border-radius: var(--border-radius) !important;
    color: #fff;
    position: relative;
    overflow: hidden;
    transition: all var(--transition-speed) ease;
    cursor: default;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--card-hover-shadow);
}

.stat-card .stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    background: rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
}

.stat-card .stat-label {
    font-size: 0.85rem;
    opacity: 0.85;
    font-weight: 500;
}

.stat-card.bg-gradient-primary { background: var(--primary-gradient); }
.stat-card.bg-gradient-success { background: var(--success-gradient); }
.stat-card.bg-gradient-warning { background: var(--warning-gradient); }
.stat-card.bg-gradient-info    { background: var(--info-gradient); }

/* ---------- Tables ---------- */
.table {
    border-collapse: separate;
    border-spacing: 0;
}

.table thead th {
    background: #f8f9fc;
    border-bottom: 2px solid #e3e6f0;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #6c757d;
    padding: 12px 16px;
}

.table tbody td {
    padding: 14px 16px;
    vertical-align: middle;
    border-bottom: 1px solid #f0f2f5;
}

.table tbody tr {
    transition: background 0.15s ease;
}

.table-hover tbody tr:hover {
    background: #f8f9fc;
}

/* ---------- Buttons ---------- */
.btn {
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.9rem;
    padding: 8px 18px;
    transition: all 0.2s ease;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: var(--primary-gradient);
    border: none;
}

.btn-primary:hover {
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    background: var(--primary-gradient);
}

.btn-success {
    background: var(--success-gradient);
    border: none;
}

.btn-success:hover {
    box-shadow: 0 4px 12px rgba(17, 153, 142, 0.4);
}

/* ---------- Forms ---------- */
.form-control, .form-select {
    border-radius: 8px;
    border: 1.5px solid #dee2e6;
    padding: 10px 14px;
    font-size: 0.925rem;
    transition: all 0.2s ease;
}

.form-control:focus, .form-select:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

.form-label {
    font-weight: 500;
    font-size: 0.875rem;
    color: #495057;
    margin-bottom: 6px;
}

/* ---------- Badges ---------- */
.badge {
    font-weight: 500;
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 0.78rem;
}

/* ---------- Toast Notifications ---------- */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast-item {
    padding: 14px 20px;
    border-radius: 10px;
    color: #fff;
    font-weight: 500;
    font-size: 0.9rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    gap: 10px;
    animation: toastIn 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    cursor: pointer;
    max-width: 360px;
}

.toast-item.toast-success { background: linear-gradient(135deg, #11998e, #38ef7d); }
.toast-item.toast-error   { background: linear-gradient(135deg, #f5576c, #ff6b6b); }
.toast-item.toast-info    { background: linear-gradient(135deg, #667eea, #764ba2); }

.toast-item.toast-out {
    animation: toastOut 0.3s ease forwards;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

@keyframes toastOut {
    to {
        opacity: 0;
        transform: translateX(30px) scale(0.95);
    }
}

/* ---------- Breadcrumb ---------- */
.breadcrumb {
    background: transparent;
    padding: 0;
    margin-bottom: 16px;
}

.breadcrumb-item a {
    color: #667eea;
    text-decoration: none;
    font-weight: 500;
}

.breadcrumb-item.active {
    color: #6c757d;
}

/* ---------- Page Header ---------- */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.page-header h2 {
    font-weight: 700;
    font-size: 1.5rem;
    color: #1a1d23;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.page-header h2 i {
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* ---------- List Group (Steps) ---------- */
.list-group-item {
    border: 1px solid #e9ecef;
    border-radius: 10px !important;
    margin-bottom: 8px;
    padding: 14px 16px;
    transition: all 0.2s ease;
}

.list-group-item:hover {
    border-color: #667eea;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.1);
}

/* ---------- Search Box ---------- */
.search-box {
    position: relative;
    max-width: 320px;
}

.search-box input {
    padding-left: 40px;
    border-radius: 10px;
    background: #fff;
}

.search-box .search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: #adb5bd;
    font-size: 0.9rem;
}

/* ---------- Loading Overlay ---------- */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,0.85);
    backdrop-filter: blur(4px);
    z-index: 1050;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    gap: 16px;
}

.loading-overlay .spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #e9ecef;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ---------- Empty State ---------- */
.empty-state {
    text-align: center;
    padding: 40px;
    color: #adb5bd;
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.5;
}

/* ---------- Confirm Modal ---------- */
.modal-confirm .modal-content {
    border: none;
    border-radius: var(--border-radius);
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.modal-confirm .modal-header {
    border-bottom: none;
    padding-bottom: 0;
}

.modal-confirm .modal-footer {
    border-top: none;
    padding-top: 0;
}

/* ---------- Dashed Card (Add New) ---------- */
.card-dashed {
    border: 2px dashed #dee2e6 !important;
    background: transparent;
    transition: all 0.2s ease;
    cursor: pointer;
}

.card-dashed:hover {
    border-color: #667eea !important;
    background: rgba(102, 126, 234, 0.04);
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #aaa;
}

/* ---------- Animate on View ---------- */
[x-cloak] {
    display: none !important;
}
