/* public/assets/css/style.css */

/* ============================================
   CSS VARIABLES & RESET
   ============================================ */
:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #a5b4fc;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;

    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;

    --sidebar-width: 260px;
    --sidebar-collapsed: 64px;
    --topbar-height: 60px;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);
    --transition: all 0.2s ease;
}

*, *::before, *::after {
    margin: 0; padding: 0; box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 14px;
    color: var(--gray-800);
    background: var(--gray-50);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* ============================================
   SIDEBAR
   ============================================ */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--gray-900);
    color: white;
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    top: 0;
    z-index: 100;
    transition: var(--transition);
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.logo { display: flex; align-items: center; gap: 12px; }
.logo-icon {
    width: 36px; height: 36px;
    background: var(--primary);
    border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 18px; color: white;
}
.logo-icon.large { width: 56px; height: 56px; font-size: 28px; border-radius: var(--radius-lg); }
.logo-text { font-weight: 700; font-size: 16px; }

.sidebar-toggle {
    background: none; border: none; color: var(--gray-400);
    cursor: pointer; padding: 4px; border-radius: 4px;
}
.sidebar-toggle:hover { color: white; background: rgba(255,255,255,0.1); }

.sidebar-nav {
    flex: 1;
    padding: 12px 8px;
    overflow-y: auto;
}

.nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 16px; color: var(--gray-400);
    border-radius: var(--radius); margin-bottom: 2px;
    transition: var(--transition); font-size: 13px; font-weight: 500;
}
.nav-item:hover { color: white; background: rgba(255,255,255,0.08); }
.nav-item.active { color: white; background: var(--primary); }

.nav-divider { height: 1px; background: rgba(255,255,255,0.08); margin: 12px 16px; }
.nav-label { padding: 8px 16px; font-size: 11px; font-weight: 600; text-transform: uppercase; color: var(--gray-500); letter-spacing: 0.5px; }

.badge {
    background: var(--danger); color: white; font-size: 11px; font-weight: 600;
    padding: 2px 8px; border-radius: 10px; margin-left: auto;
}

.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.user-info { display: flex; align-items: center; gap: 10px; }
.user-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--primary); display: flex;
    align-items: center; justify-content: center;
    font-weight: 600; font-size: 13px; color: white;
}
.user-details { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 600; color: white; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--gray-400); }

/* ============================================
   MAIN CONTENT
   ============================================ */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: var(--transition);
}

.top-bar {
    height: var(--topbar-height);
    background: white;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.top-bar-title { flex: 1; }
.top-bar-title h1 { font-size: 18px; font-weight: 700; color: var(--gray-900); }
.top-bar-actions { display: flex; align-items: center; gap: 12px; }
.mobile-menu-btn { display: none; }

.plan-badge {
    background: var(--primary-light); color: var(--primary-dark);
    font-size: 11px; font-weight: 600; padding: 4px 12px;
    border-radius: 20px;
}

.content-wrapper { padding: 24px; flex: 1; }

/* ============================================
   CARDS & COMPONENTS
   ============================================ */
.card {
    background: white; border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm); border: 1px solid var(--gray-200);
    margin-bottom: 20px; overflow: hidden;
}
.card-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px; border-bottom: 1px solid var(--gray-100);
}
.card-header h3 { font-size: 15px; font-weight: 600; color: var(--gray-900); }
.card-body { padding: 20px; }

/* KPI Cards */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 20px; }
.kpi-row.compact { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.kpi-card {
    background: white; border-radius: var(--radius-lg); padding: 20px;
    box-shadow: var(--shadow-sm); border: 1px solid var(--gray-200);
    display: flex; align-items: center; gap: 14px;
}
.kpi-card.mini { padding: 12px; text-align: center; flex-direction: column; gap: 4px; }
.kpi-icon {
    width: 44px; height: 44px; border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.kpi-icon.blue { background: #eff6ff; color: var(--info); }
.kpi-icon.green { background: #ecfdf5; color: var(--success); }
.kpi-icon.purple { background: #f5f3ff; color: var(--primary); }
.kpi-icon.orange { background: #fffbeb; color: var(--warning); }
.kpi-icon.teal { background: #f0fdfa; color: #14b8a6; }
.kpi-icon.pink { background: #fdf2f8; color: #ec4899; }

.kpi-value { font-size: 24px; font-weight: 700; color: var(--gray-900); }
.kpi-card.mini .kpi-value { font-size: 20px; }
.kpi-label { font-size: 12px; color: var(--gray-500); font-weight: 500; }

/* Rate Cards */
.rate-cards { display: flex; gap: 20px; flex-wrap: wrap; }
.rate-card { flex: 1; min-width: 140px; }
.rate-value { font-size: 28px; font-weight: 700; color: var(--gray-900); }
.rate-label { font-size: 12px; color: var(--gray-500); margin: 4px 0 8px; }
.rate-bar { height: 6px; background: var(--gray-100); border-radius: 3px; overflow: hidden; }
.rate-fill { height: 100%; border-radius: 3px; transition: width 0.5s ease; }
.rate-fill.green { background: var(--success); }
.rate-fill.purple { background: var(--primary); }
.rate-fill.blue { background: var(--info); }

/* ============================================
   BUTTONS
   ============================================ */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 16px; font-size: 13px; font-weight: 500;
    border-radius: var(--radius); border: 1px solid transparent;
    cursor: pointer; transition: var(--transition);
    font-family: inherit; line-height: 1.4;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: white; }
.btn-warning { background: var(--warning); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-outline { background: white; border-color: var(--gray-300); color: var(--gray-700); }
.btn-outline:hover { background: var(--gray-50); border-color: var(--gray-400); }
.btn-full { width: 100%; justify-content: center; padding: 10px; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 11px; }
.btn-icon {
    background: none; border: none; cursor: pointer; padding: 6px;
    border-radius: var(--radius); color: var(--gray-500); transition: var(--transition);
}
.btn-icon:hover { background: var(--gray-100); color: var(--gray-700); }

/* ============================================
   FORMS
   ============================================ */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; color: var(--gray-700); margin-bottom: 6px; }
.form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: 9px 12px; font-size: 13px;
    border: 1px solid var(--gray-300); border-radius: var(--radius);
    background: white; color: var(--gray-800);
    font-family: inherit; transition: var(--transition);
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}
.form-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; font-size: 13px; }
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.checkbox-label { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }

/* ============================================
   TABLES
   ============================================ */
.table-wrapper { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th {
    text-align: left; padding: 10px 16px; font-size: 11px;
    font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;
    color: var(--gray-500); background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
}
.table td { padding: 12px 16px; border-bottom: 1px solid var(--gray-100); font-size: 13px; }
.table tr:hover td { background: var(--gray-50); }
.cell-primary { font-weight: 500; color: var(--gray-900); }
.cell-secondary { font-size: 12px; color: var(--gray-500); }

/* Status Badges */
.status-badge {
    display: inline-block; padding: 3px 10px; border-radius: 20px;
    font-size: 11px; font-weight: 600; text-transform: capitalize;
}
.status-badge.draft { background: var(--gray-100); color: var(--gray-600); }
.status-badge.scheduled { background: #eff6ff; color: #2563eb; }
.status-badge.running { background: #ecfdf5; color: #059669; }
.status-badge.paused { background: #fffbeb; color: #d97706; }
.status-badge.completed { background: #f0fdf4; color: #16a34a; }
.status-badge.cancelled, .status-badge.failed { background: #fef2f2; color: #dc2626; }

.tag {
    display: inline-block; padding: 2px 8px; border-radius: 4px;
    font-size: 11px; font-weight: 500; background: var(--gray-100); color: var(--gray-600);
}

.action-buttons { display: flex; gap: 4px; }

/* ============================================
   TOOLBAR & FILTERS
   ============================================ */
.toolbar {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 16px; flex-wrap: wrap; gap: 12px;
}
.toolbar-actions { display: flex; gap: 8px; }
.filter-group { display: flex; gap: 8px; }
.filter-group select {
    padding: 7px 12px; font-size: 13px; border: 1px solid var(--gray-300);
    border-radius: var(--radius); background: white; font-family: inherit;
}

.period-selector { display: flex; gap: 4px; background: var(--gray-100); padding: 3px; border-radius: var(--radius); }
.period-btn {
    padding: 6px 14px; font-size: 12px; font-weight: 500;
    border: none; border-radius: 6px; cursor: pointer;
    background: transparent; color: var(--gray-600); transition: var(--transition);
}
.period-btn.active { background: white; color: var(--gray-900); box-shadow: var(--shadow-sm); }

/* ============================================
   PAGE HEADER
   ============================================ */
.page-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 24px; flex-wrap: wrap; gap: 16px;
}
.page-header h2 { font-size: 22px; font-weight: 700; color: var(--gray-900); }
.subtitle { font-size: 13px; color: var(--gray-500); margin-top: 4px; }

/* ============================================
   CONVERSATIONS LIST
   ============================================ */
.conversation-list { max-height: 400px; overflow-y: auto; }
.conversation-item {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 16px; cursor: pointer; border-bottom: 1px solid var(--gray-100);
    transition: var(--transition);
}
.conversation-item:hover { background: var(--gray-50); }
.conv-avatar {
    width: 40px; height: 40px; border-radius: 50%;
    background: var(--primary-light); color: var(--primary-dark);
    display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 16px; flex-shrink: 0;
}
.conv-info { flex: 1; min-width: 0; }
.conv-name { font-weight: 600; font-size: 13px; color: var(--gray-900); }
.conv-preview { font-size: 12px; color: var(--gray-500); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-meta { text-align: right; flex-shrink: 0; }
.conv-time { font-size: 11px; color: var(--gray-400); }

/* ============================================
   CHARTS (Fallback)
   ============================================ */
.bar-chart { display: flex; align-items: flex-end; gap: 4px; height: 200px; padding: 10px 0; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; justify-content: flex-end; }
.bar { width: 100%; max-width: 30px; background: var(--primary); border-radius: 3px 3px 0 0; transition: height 0.3s ease; min-height: 2px; }
.bar-label { font-size: 9px; color: var(--gray-400); margin-top: 4px; writing-mode: vertical-rl; }

/* ============================================
   MODAL
   ============================================ */
.modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5); z-index: 1000;
    display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-content {
    background: white; border-radius: var(--radius-lg); width: 100%; max-width: 640px;
    max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg);
}
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 20px 24px; border-bottom: 1px solid var(--gray-200);
}
.modal-header h3 { font-size: 17px; font-weight: 600; }
.modal-body { padding: 24px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding-top: 16px; border-top: 1px solid var(--gray-100); }

/* ============================================
   TOASTS
   ============================================ */
.toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; }
.toast {
    padding: 12px 20px; border-radius: var(--radius); color: white;
    font-size: 13px; font-weight: 500; box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease; min-width: 280px;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.info { background: var(--info); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ============================================
   AUTH PAGE
   ============================================ */
.auth-page {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
}
.auth-container { display: flex; gap: 40px; max-width: 1000px; width: 100%; align-items: center; }
.auth-card {
    background: white; border-radius: var(--radius-lg); padding: 40px;
    box-shadow: var(--shadow-lg); flex: 1; max-width: 460px;
}
.auth-header { text-align: center; margin-bottom: 32px; }
.auth-header h1 { font-size: 22px; font-weight: 700; color: var(--gray-900); margin-top: 16px; }
.auth-header p { color: var(--gray-500); font-size: 14px; margin-top: 6px; }
.auth-form h2 { font-size: 20px; font-weight: 700; margin-bottom: 6px; color: var(--gray-900); }
.auth-form .subtitle { font-size: 13px; color: var(--gray-500); margin-bottom: 20px; }
.auth-footer { text-align: center; margin-top: 20px; font-size: 13px; color: var(--gray-500); }
.auth-features { flex: 1; color: white; display: flex; align-items: center; }
.feature-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.feature-item { background: rgba(255,255,255,0.15); border-radius: var(--radius-lg); padding: 24px; backdrop-filter: blur(10px); }
.feature-icon { font-size: 28px; margin-bottom: 10px; }
.feature-item h3 { font-size: 15px; font-weight: 600; margin-bottom: 6px; }
.feature-item p { font-size: 13px; opacity: 0.85; line-height: 1.5; }

/* ============================================
   PAGINATION
   ============================================ */
.pagination { display: flex; align-items: center; justify-content: center; gap: 4px; padding: 16px; }
.pagination button {
    padding: 6px 12px; font-size: 12px; border: 1px solid var(--gray-300);
    border-radius: var(--radius); background: white; cursor: pointer; font-family: inherit;
}
.pagination button.active { background: var(--primary); color: white; border-color: var(--primary); }
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }

/* ============================================
   UTILITIES
   ============================================ */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
.text-center { text-align: center; }
.text-muted { color: var(--gray-400); }
.mt-4 { margin-top: 16px; }
.p-4 { padding: 16px; }
.icon-sm { width: 18px; height: 18px; }
.icon-xs { width: 14px; height: 14px; }
.error-list { list-style: disc; padding-left: 20px; font-size: 13px; color: var(--danger); }
.error-list li { margin-bottom: 4px; }

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1024px) {
    .grid-2 { grid-template-columns: 1fr; }
    .form-row-2 { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .mobile-menu-btn { display: block; }
    .auth-container { flex-direction: column; }
    .auth-features { display: none; }
    .feature-grid { grid-template-columns: 1fr; }
    .kpi-row { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
    .kpi-row { grid-template-columns: 1fr; }
    .content-wrapper { padding: 16px; }
    .auth-card { padding: 24px; }
}