/* ============================================
   Visagan Digital Edge CRM — Stylesheet
   Design: Modern dark sidebar + clean light content
   ============================================ */

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

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #3b82f6;
    --sidebar-bg: #0f172a;
    --sidebar-hover: #1e293b;
    --bg: #f8fafc;
    --card: #ffffff;
    --text: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --success: #16a34a;
    --warning: #f59e0b;
    --danger: #dc2626;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
    --shadow: 0 4px 12px rgba(0,0,0,.08);
    --shadow-lg: 0 10px 30px rgba(15,23,42,.12);
    --radius: 10px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

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

/* ===== SIDEBAR ===== */
.sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    width: 260px;
    background: var(--sidebar-bg);
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    padding: 24px 0;
    z-index: 100;
}
.sidebar-brand {
    display: flex; align-items: center; gap: 12px;
    padding: 0 24px 24px;
    border-bottom: 1px solid #1e293b;
}
.logo-circle {
    width: 44px; height: 44px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    color: white; font-size: 20px;
}
.brand-name { color: white; font-weight: 700; font-size: 17px; }
.brand-sub  { font-size: 12px; color: #64748b; }

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    display: flex; flex-direction: column; gap: 4px;
}
.sidebar-nav a {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 14px;
    color: #94a3b8;
    border-radius: 8px;
    font-weight: 500; font-size: 14px;
    transition: all .15s;
}
.sidebar-nav a:hover { background: var(--sidebar-hover); color: white; }
.sidebar-nav a.active { background: var(--primary); color: white; }
.sidebar-nav i { width: 18px; }

.sidebar-footer {
    padding: 16px 24px 0;
    border-top: 1px solid #1e293b;
}
.user-info {
    display: flex; align-items: center; gap: 12px;
    margin-bottom: 12px;
}
.avatar {
    width: 38px; height: 38px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 600;
}
.user-name { color: white; font-size: 14px; font-weight: 600; }
.user-role { font-size: 12px; color: #64748b; }
.btn-logout {
    display: block;
    padding: 8px;
    background: #1e293b;
    color: #cbd5e1 !important;
    border-radius: 6px;
    text-align: center;
    font-size: 13px;
}
.btn-logout:hover { background: var(--danger); color: white !important; }

/* ===== MAIN CONTENT ===== */
.main-content {
    margin-left: 260px;
    padding: 32px;
    min-height: 100vh;
}

/* ===== AUTH PAGES ===== */
.auth-wrapper {
    min-height: 100vh;
    background: linear-gradient(135deg, #1e3a8a, #2563eb, #3b82f6);
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
}
.auth-card {
    background: white;
    border-radius: 16px;
    padding: 40px;
    width: 100%; max-width: 420px;
    box-shadow: var(--shadow-lg);
}
.auth-logo {
    width: 70px; height: 70px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border-radius: 16px;
    display: flex; align-items: center; justify-content: center;
    color: white; font-size: 30px;
    margin: 0 auto 20px;
}
.auth-title { text-align: center; font-size: 24px; font-weight: 700; }
.auth-sub   { text-align: center; color: var(--text-muted); margin-bottom: 28px; font-size: 14px; }

/* ===== FORMS ===== */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block; margin-bottom: 6px;
    font-size: 13px; font-weight: 600; color: var(--text);
}
.form-control, input[type=text], input[type=email], input[type=password],
input[type=number], input[type=tel], input[type=datetime-local], select, textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    background: white;
    transition: border-color .15s, box-shadow .15s;
    font-family: inherit;
}
.form-control:focus, input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
textarea { resize: vertical; min-height: 90px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 640px) { .form-row { grid-template-columns: 1fr; } }

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 18px;
    border: none; border-radius: 8px;
    font-size: 14px; font-weight: 600;
    cursor: pointer;
    transition: all .15s;
    text-decoration: none;
    font-family: inherit;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); color: white; }
.btn-secondary { background: white; color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #b91c1c; color: white; }
.btn-success { background: var(--success); color: white; }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 13px; }

/* ===== PAGE HEADER ===== */
.page-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 28px;
    flex-wrap: wrap; gap: 16px;
}
.page-title { font-size: 26px; font-weight: 700; }
.page-sub   { color: var(--text-muted); font-size: 14px; margin-top: 4px; }

/* ===== CARDS ===== */
.card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}
.card-title { font-size: 16px; font-weight: 600; margin-bottom: 16px; }

/* ===== STATS GRID ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}
.stat-card {
    background: var(--card);
    padding: 22px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    display: flex; align-items: center; gap: 16px;
}
.stat-icon {
    width: 52px; height: 52px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px; color: white;
}
.stat-icon.blue   { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.stat-icon.green  { background: linear-gradient(135deg, #10b981, #059669); }
.stat-icon.orange { background: linear-gradient(135deg, #f59e0b, #d97706); }
.stat-icon.purple { background: linear-gradient(135deg, #a855f7, #9333ea); }
.stat-icon.red    { background: linear-gradient(135deg, #ef4444, #dc2626); }
.stat-value { font-size: 24px; font-weight: 700; }
.stat-label { font-size: 13px; color: var(--text-muted); }

/* ===== TABLES ===== */
.table-wrapper { overflow-x: auto; }
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
table th {
    text-align: left;
    padding: 12px 14px;
    background: var(--bg);
    font-weight: 600;
    color: var(--text-muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .5px;
    border-bottom: 1px solid var(--border);
}
table td {
    padding: 14px;
    border-bottom: 1px solid var(--border);
}
table tr:hover td { background: #f8fafc; }
table tr:last-child td { border-bottom: none; }

/* ===== BADGES ===== */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}
.badge-blue   { background: #dbeafe; color: #1e40af; }
.badge-green  { background: #dcfce7; color: #166534; }
.badge-red    { background: #fee2e2; color: #991b1b; }
.badge-amber  { background: #fef3c7; color: #92400e; }
.badge-orange { background: #ffedd5; color: #9a3412; }
.badge-purple { background: #ede9fe; color: #5b21b6; }
.badge-cyan   { background: #cffafe; color: #155e75; }
.badge-gray   { background: #f1f5f9; color: #475569; }

/* ===== FLASH MESSAGES ===== */
.flash {
    padding: 12px 18px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 14px;
    font-weight: 500;
}
.flash-success { background: #dcfce7; color: #166534; border: 1px solid #86efac; }
.flash-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.flash-info    { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }

/* ===== FILTERS BAR ===== */
.filters {
    display: flex; gap: 12px; flex-wrap: wrap;
    margin-bottom: 20px;
    align-items: center;
}
.filters input, .filters select { width: auto; min-width: 160px; }
.search-box { flex: 1; min-width: 240px; }

/* ===== DETAIL PAGE ===== */
.detail-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
}
@media (max-width: 900px) { .detail-grid { grid-template-columns: 1fr; } }

.info-row {
    display: flex; justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}
.info-row:last-child { border-bottom: none; }
.info-label { color: var(--text-muted); }
.info-value { font-weight: 500; }

/* ===== TIMELINE ===== */
.timeline-item {
    padding: 14px;
    border-left: 3px solid var(--primary);
    background: var(--bg);
    margin-bottom: 12px;
    border-radius: 0 8px 8px 0;
}
.timeline-meta {
    display: flex; justify-content: space-between;
    font-size: 12px; color: var(--text-muted);
    margin-bottom: 6px;
}

/* ===== TABS (for auth) ===== */
.tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
}
.tab-btn {
    flex: 1;
    padding: 10px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 14px;
}
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); transition: transform .2s; }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; padding: 20px; }
    .mobile-toggle { display: block !important; }
}
.mobile-toggle {
    display: none;
    position: fixed; top: 16px; left: 16px;
    z-index: 200;
    background: var(--sidebar-bg);
    color: white;
    border: none;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 18px;
    cursor: pointer;
}

/* ===== UTILITIES ===== */
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.mt-2 { margin-top: 8px; } .mt-3 { margin-top: 16px; } .mt-4 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 16px; }
.flex { display: flex; gap: 8px; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-2 { gap: 12px; }
