/* ============================================
   NYOBEL CRM - Portal Styles (Client & Agent)
   Modern Design matching Admin Panel
   ============================================ */

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary: #64748b;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    --white: #ffffff;
    --light: #f8fafc;
    --dark: #1e293b;
    --border: #e2e8f0;
    --text: #334155;
    --muted: #94a3b8;
    --sidebar-width: 260px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --radius: 12px;
    --background: #f1f5f9;
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text);
    background: var(--background);
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: none; }

/* ============================================
   LAYOUT
   ============================================ */
.portal-wrapper {
    display: flex;
    min-height: 100vh;
}

/* ============================================
   SIDEBAR
   ============================================ */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    color: var(--white);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
    transition: transform 0.3s ease;
}

/* Agent Portal Sidebar Color */
.agent-portal .sidebar {
    background: linear-gradient(180deg, #1e3a5f 0%, #0c2340 100%);
}

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

.sidebar-header h2 {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.sidebar-header a {
    color: var(--white);
}

.sidebar-header a:hover {
    text-decoration: none;
}

/* Portal Badge */
.portal-badge {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 10px;
}

.portal-badge.agent {
    background: rgba(59, 130, 246, 0.15);
    color: #93c5fd;
}

.portal-badge.client {
    background: rgba(16, 185, 129, 0.15);
    color: #6ee7b7;
}

/* Sidebar Navigation */
.sidebar-nav {
    flex: 1;
    padding: 20px 0;
    overflow-y: auto;
}

.sidebar-nav ul {
    list-style: none;
}

.sidebar-nav li a {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 24px;
    color: rgba(255,255,255,0.65);
    font-weight: 500;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.sidebar-nav li a:hover {
    background: rgba(255,255,255,0.05);
    color: rgba(255,255,255,0.9);
}

.sidebar-nav li.active a {
    background: rgba(255,255,255,0.1);
    color: var(--white);
    border-left-color: var(--primary);
}

.sidebar-nav li a i {
    width: 20px;
    height: 20px;
    opacity: 0.8;
}

.sidebar-nav li.active a i {
    opacity: 1;
}

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

.logout-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    color: rgba(255,255,255,0.6);
    font-weight: 500;
    transition: color 0.2s;
}

.logout-btn:hover {
    color: var(--white);
}

.logout-btn i {
    width: 20px;
    height: 20px;
}

/* ============================================
   MAIN CONTENT
   ============================================ */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    background: var(--background);
    display: flex;
    flex-direction: column;
}

/* Topbar */
.topbar {
    height: 70px;
    background: var(--white);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 30px;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    flex-shrink: 0;
}

.topbar-spacer {
    flex: 1;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.user-name {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    color: var(--text);
    padding: 8px 16px;
    background: var(--light);
    border-radius: 8px;
}

.user-name i {
    width: 18px;
    height: 18px;
    color: var(--muted);
}

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
}

.mobile-menu-btn:hover {
    background: var(--light);
}

/* Page Content */
.page-content {
    padding: 30px;
    min-height: calc(100vh - 70px - 60px);
}

/* Page Header */
.page-header {
    margin-bottom: 30px;
}

.page-header h1 {
    font-size: 26px;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 6px;
    letter-spacing: -0.5px;
}

.page-header p {
    color: var(--muted);
    font-size: 15px;
}

/* ============================================
   STATS CARDS - Modern Style
   ============================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 24px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 20px;
    box-shadow: var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s;
}

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

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon i {
    width: 26px;
    height: 26px;
}

.stat-icon.blue { background: #dbeafe; color: #2563eb; }
.stat-icon.green { background: #d1fae5; color: #059669; }
.stat-icon.yellow { background: #fef3c7; color: #d97706; }
.stat-icon.purple { background: #ede9fe; color: #7c3aed; }
.stat-icon.red { background: #fee2e2; color: #dc2626; }
.stat-icon.cyan { background: #cffafe; color: #0891b2; }

.stat-info h3 {
    font-size: 32px;
    font-weight: 700;
    color: var(--dark);
    line-height: 1;
    margin-bottom: 6px;
}

.stat-info p {
    color: var(--muted);
    font-size: 14px;
    font-weight: 500;
}

/* Mini Stats (smaller version) */
.mini-stats {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.mini-stat {
    background: var(--white);
    padding: 16px 24px;
    border-radius: 10px;
    box-shadow: var(--shadow);
    min-width: 140px;
}

.mini-stat.highlight {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
}

.mini-stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--dark);
    display: block;
}

.mini-stat.highlight .mini-stat-value {
    color: #92400e;
}

.mini-stat-label {
    font-size: 13px;
    color: var(--muted);
    font-weight: 500;
}

/* ============================================
   CARDS
   ============================================ */
.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

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

.card-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--dark);
}

.card-body {
    padding: 24px;
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 24px;
}

/* ============================================
   TABLES
   ============================================ */
.table-responsive {
    overflow-x: auto;
}

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

.table th {
    padding: 14px 16px;
    text-align: left;
    font-weight: 600;
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: var(--light);
    border-bottom: 1px solid var(--border);
}

.table td {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

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

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

.table tbody tr:last-child td {
    border-bottom: none;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn i {
    width: 18px;
    height: 18px;
}

.btn-sm {
    padding: 8px 14px;
    font-size: 13px;
}

.btn-sm i {
    width: 16px;
    height: 16px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--white);
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.3);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(37, 99, 235, 0.4);
}

.btn-outline {
    background: var(--white);
    border: 1px solid var(--border);
    color: var(--text);
}

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

.btn-success {
    background: linear-gradient(135deg, var(--success) 0%, #059669 100%);
    color: var(--white);
}

.btn-danger {
    background: var(--white);
    border: 1px solid #fecaca;
    color: var(--danger);
}

.btn-danger:hover {
    background: #fef2f2;
}

/* ============================================
   FORMS
   ============================================ */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text);
    font-size: 14px;
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    color: var(--text);
    background: var(--white);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-control::placeholder {
    color: var(--muted);
}

select.form-control {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 12px center;
    background-repeat: no-repeat;
    background-size: 16px;
    padding-right: 40px;
}

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

/* Filters Form */
.filters-form {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    align-items: center;
}

.filter-group {
    min-width: 180px;
}

.filter-group.flex-2 {
    flex: 2;
    min-width: 280px;
}

/* ============================================
   BADGES
   ============================================ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    text-transform: capitalize;
}

.badge-pending, .badge-new { background: #fef3c7; color: #92400e; }
.badge-active, .badge-approved, .badge-confirmed, .badge-converted, .badge-contacted { background: #d1fae5; color: #065f46; }
.badge-inactive, .badge-closed, .badge-completed { background: #f1f5f9; color: #475569; }
.badge-lead, .badge-scheduled, .badge-reviewed { background: #dbeafe; color: #1e40af; }
.badge-prospect { background: #ede9fe; color: #5b21b6; }
.badge-rejected, .badge-cancelled, .badge-error { background: #fee2e2; color: #991b1b; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }

/* ============================================
   LIST ITEMS
   ============================================ */
.list-items {
    display: flex;
    flex-direction: column;
}

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

.list-item:last-child {
    border-bottom: none;
}

.list-item-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.list-item-info strong {
    color: var(--dark);
    font-weight: 600;
}

.list-item-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
}

/* ============================================
   EMPTY STATE
   ============================================ */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--muted);
}

.empty-state i {
    width: 64px;
    height: 64px;
    margin-bottom: 20px;
    opacity: 0.4;
    stroke-width: 1.5;
}

.empty-state h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--dark);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 15px;
    max-width: 300px;
    margin: 0 auto;
}

/* ============================================
   ALERTS
   ============================================ */
.alert {
    padding: 16px 20px;
    border-radius: 10px;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 500;
}

.alert-success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-warning {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
}

.alert-info {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

/* ============================================
   TIMELINE
   ============================================ */
.timeline {
    position: relative;
    padding-left: 30px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border);
}

.timeline-item {
    position: relative;
    padding-bottom: 24px;
}

.timeline-item:last-child {
    padding-bottom: 0;
}

.timeline-dot {
    position: absolute;
    left: -30px;
    top: 4px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary);
    border: 3px solid var(--white);
    box-shadow: var(--shadow);
}

.timeline-content {
    background: var(--light);
    padding: 16px;
    border-radius: 10px;
}

.timeline-action {
    font-weight: 600;
    color: var(--dark);
    margin-bottom: 4px;
}

.timeline-desc {
    color: var(--muted);
    font-size: 14px;
    margin-bottom: 8px;
}

.timeline-date {
    font-size: 12px;
    color: var(--muted);
}

/* ============================================
   UTILITIES
   ============================================ */
.text-muted { color: var(--muted); }
.text-center { text-align: center; }
.text-sm { font-size: 12px; }
.mb-20 { margin-bottom: 20px; }
.mt-20 { margin-top: 20px; }
.d-block { display: block; }

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.show {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .mobile-menu-btn {
        display: flex;
    }
    
    .page-content {
        padding: 20px;
    }
    
    .topbar {
        padding: 0 20px;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }
    
    .stat-card {
        padding: 16px;
    }
    
    .stat-icon {
        width: 48px;
        height: 48px;
    }
    
    .stat-info h3 {
        font-size: 24px;
    }
    
    .filters-form {
        flex-direction: column;
        align-items: stretch;
    }
    
    .filter-group,
    .filter-group.flex-2 {
        width: 100%;
        min-width: 100%;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .mini-stats {
        flex-direction: column;
    }
    
    .mini-stat {
        width: 100%;
    }
}

/* Portal & Agent Footer - Sticky */
.portal-footer,
.agent-footer {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 16px 24px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    font-size: 0.8rem;
    color: #64748b;
    flex-shrink: 0;
    margin-top: auto;
}
.portal-footer p,
.agent-footer p {
    margin: 0;
}