/* ===================================================================
   MisanClub CRM — Custom styles (Bootstrap 5 base)
   =================================================================== */

:root {
    --mcrm-sidebar-width: 255px;
    --mcrm-sidebar-bg:    #1a2332;
    --mcrm-sidebar-text:  #a9b4c4;
    --mcrm-sidebar-active:#3b82f6;
    --mcrm-topbar-h:      60px;
    --mcrm-topbar-bg:     #ffffff;
    --mcrm-body-bg:       #f0f2f5;
    --mcrm-primary:       #3b82f6;
    --mcrm-font:          'Inter', system-ui, sans-serif;
}

/* ---- Base ---- */
*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: var(--mcrm-font);
    background: var(--mcrm-body-bg);
    color: #1e293b;
    margin: 0;
}

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

/* ===== SIDEBAR ===== */
.mcrm-sidebar {
    width: var(--mcrm-sidebar-width);
    background: var(--mcrm-sidebar-bg);
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 200;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    transition: transform .25s ease;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,.07);
    text-decoration: none;
    color: #fff;
}
.sidebar-logo .logo-icon {
    width: 34px; height: 34px;
    background: var(--mcrm-primary);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; flex-shrink: 0;
    overflow: hidden;
}
.sidebar-logo .logo-icon img {
    width: 100%; height: 100%;
    object-fit: cover;
    border-radius: 50%;
}
.sidebar-logo .logo-name { font-size: 15px; font-weight: 700; line-height: 1.2; }
.sidebar-logo .logo-name span { font-weight: 300; color: var(--mcrm-sidebar-text); }

/* Nav */
.sidebar-nav { padding: 12px 0; flex: 1; }

.sidebar-section {
    padding: 14px 20px 4px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: rgba(169,180,196,.45);
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 20px;
    color: var(--mcrm-sidebar-text);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition: background .15s, color .15s, border-color .15s;
    position: relative;
}
.sidebar-link i { font-size: 16px; flex-shrink: 0; }
.sidebar-link:hover {
    background: rgba(255,255,255,.06);
    color: #fff;
}
.sidebar-link.active {
    background: rgba(59,130,246,.15);
    color: #fff;
    border-left-color: var(--mcrm-sidebar-active);
}
.sidebar-link .badge-count {
    margin-left: auto;
    background: var(--mcrm-primary);
    color: #fff;
    font-size: 10px;
    padding: 2px 7px;
    border-radius: 10px;
    font-weight: 600;
}

/* Sidebar bottom: user info */
.sidebar-user {
    padding: 14px 20px;
    border-top: 1px solid rgba(255,255,255,.07);
    display: flex;
    align-items: center;
    gap: 10px;
}
.sidebar-user .user-avatar {
    width: 32px; height: 32px;
    background: var(--mcrm-primary);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 700; font-size: 13px;
    flex-shrink: 0;
}
.sidebar-user .user-name  { font-size: 13px; color: #fff; font-weight: 600; line-height: 1.3; }
.sidebar-user .user-role  { font-size: 11px; color: var(--mcrm-sidebar-text); }
.sidebar-user .logout-btn {
    margin-left: auto;
    color: var(--mcrm-sidebar-text);
    font-size: 17px;
    text-decoration: none;
    transition: color .15s;
}
.sidebar-user .logout-btn:hover { color: #ef4444; }

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

/* ===== TOPBAR ===== */
.mcrm-topbar {
    height: var(--mcrm-topbar-h);
    background: var(--mcrm-topbar-bg);
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    padding: 0 24px;
    position: sticky;
    top: 0; z-index: 100;
    gap: 16px;
}
.topbar-toggle {
    display: none;
    background: none; border: none;
    font-size: 20px; color: #64748b; cursor: pointer;
    padding: 4px;
}
.topbar-title { font-size: 15px; font-weight: 600; color: #1e293b; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }

/* ===== PAGE CONTENT ===== */
.mcrm-content {
    padding: 24px;
    flex: 1;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}
.page-header h1 {
    font-size: 20px;
    font-weight: 700;
    color: #1e293b;
    margin: 0;
}
.page-header .breadcrumb { font-size: 12.5px; margin: 0; }

/* ===== CARDS ===== */
.card {
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.card-header {
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    border-radius: 10px 10px 0 0 !important;
    padding: 14px 18px;
    font-weight: 600;
    font-size: 14px;
}

/* KPI cards */
.kpi-card {
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    background: #fff;
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.kpi-icon {
    width: 48px; height: 48px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px; flex-shrink: 0;
}
.kpi-icon.blue   { background: #eff6ff; color: #3b82f6; }
.kpi-icon.green  { background: #f0fdf4; color: #22c55e; }
.kpi-icon.orange { background: #fff7ed; color: #f97316; }
.kpi-icon.purple { background: #faf5ff; color: #a855f7; }
.kpi-icon.red    { background: #fef2f2; color: #ef4444; }
.kpi-icon.teal   { background: #f0fdfa; color: #14b8a6; }
.kpi-icon.indigo { background: #eef2ff; color: #6366f1; }
.kpi-icon.pink   { background: #fdf2f8; color: #ec4899; }
.kpi-icon.amber  { background: #fffbeb; color: #d97706; }
.kpi-label { font-size: 12px; color: #64748b; font-weight: 500; }
.kpi-value { font-size: 24px; font-weight: 700; color: #1e293b; line-height: 1.2; }
.kpi-sub   { font-size: 11px; color: #94a3b8; font-weight: 600; margin-top: 2px; }

/* ===== TABLES ===== */
.table thead th {
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #64748b;
    background: #f8fafc;
    border-bottom: 1px solid #e5e7eb;
}
.table td { font-size: 13.5px; vertical-align: middle; }

/* ===== BADGES ===== */
.badge { font-size: 11.5px; font-weight: 600; padding: 4px 9px; border-radius: 6px; }

/* ===== FORMS ===== */
.form-label { font-size: 13px; font-weight: 600; color: #374151; margin-bottom: 5px; }
.form-control, .form-select {
    font-size: 14px;
    border-color: #d1d5db;
    border-radius: 7px;
}
.form-control:focus, .form-select:focus {
    border-color: var(--mcrm-primary);
    box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}
.form-text { font-size: 12px; }

/* Permissions grid */
.perm-grid { border: 1px solid #e5e7eb; border-radius: 8px; overflow: hidden; }
.perm-grid table { margin: 0; }
.perm-grid thead th { padding: 10px 14px; font-size: 11px; }
.perm-grid td, .perm-grid th { padding: 9px 14px; }
.perm-module-name { font-weight: 600; font-size: 13px; color: #374151; }
.perm-inherited { opacity: .45; }

/* ===== BUTTONS ===== */
.btn { font-size: 13.5px; font-weight: 600; border-radius: 7px; }
.btn-primary { background: var(--mcrm-primary); border-color: var(--mcrm-primary); }
.btn-primary:hover { background: #2563eb; border-color: #2563eb; }
.btn-sm { font-size: 12.5px; }

/* ===== ALERTS ===== */
.alert { border-radius: 8px; font-size: 13.5px; }

/* ===== LOGIN PAGE ===== */
.login-page {
    background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--mcrm-font);
}
.login-card {
    background: #fff;
    border-radius: 14px;
    padding: 40px 36px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.login-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 24px;
    color: #1e293b;
    text-decoration: none;
}
.login-logo .logo-icon {
    width: 38px; height: 38px;
    background: var(--mcrm-primary);
    border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 20px;
    overflow: hidden;
}
.login-logo .logo-icon img {
    width: 100%; height: 100%;
    object-fit: cover;
    border-radius: 50%;
}
.login-logo .logo-text { font-size: 17px; font-weight: 700; }
.login-logo .logo-text span { font-weight: 300; color: #64748b; }
.login-title    { font-size: 22px; font-weight: 700; color: #1e293b; margin: 0 0 4px; }
.login-subtitle { font-size: 13.5px; color: #64748b; margin-bottom: 22px; }

/* ===== INSTALL PAGE ===== */
.install-page { background: var(--mcrm-body-bg); min-height: 100vh; padding: 40px 0; }
.install-card {
    max-width: 580px;
    margin: 0 auto;
    background: #fff;
    border-radius: 12px;
    padding: 36px;
    box-shadow: 0 4px 20px rgba(0,0,0,.08);
}
.install-step {
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 16px 18px;
    margin-bottom: 12px;
    font-size: 13.5px;
}
.install-step.ok    { border-left: 4px solid #22c55e; }
.install-step.error { border-left: 4px solid #ef4444; }

/* ===== RECOVER / RESET PAGES ===== */
.auth-page {
    background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 100%);
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
}
.auth-card {
    background: #fff;
    border-radius: 14px;
    padding: 36px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0,0,0,.25);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .mcrm-sidebar {
        transform: translateX(-100%);
    }
    .mcrm-sidebar.open {
        transform: translateX(0);
    }
    .mcrm-main {
        margin-left: 0;
    }
    .topbar-toggle { display: block; }
    .mcrm-content  { padding: 16px; }
    .sidebar-overlay {
        display: none;
        position: fixed; inset: 0;
        background: rgba(0,0,0,.5);
        z-index: 199;
    }
    .sidebar-overlay.open { display: block; }
}
