/* =============================================
   PCE Social CRM — Core Stylesheet
   ============================================= */

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

:root {
    --brand:       #4F46E5;
    --brand-light: #EEF2FF;
    --sidebar-w:   240px;
    --sidebar-bg:  #1E1E2D;
    --sidebar-txt: #A0A3BD;
    --sidebar-act: #ffffff;
    --bg:          #F8F9FB;
    --white:       #ffffff;
    --border:      #E4E6EF;
    --text:        #181C32;
    --muted:       #7E8299;
    --danger:      #F64E60;
    --success:     #1BC5BD;
    --warning:     #FFA800;
    --radius:      10px;
    --shadow:      0 2px 12px rgba(0,0,0,.08);
}

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

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

/* ---- Layout ---- */
.app-wrapper { display: flex; min-height: 100vh; }

/* ---- Sidebar ---- */
.sidebar {
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
}

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

.sidebar-brand-text {
    color: #fff;
    font-weight: 700;
    font-size: 16px;
    letter-spacing: -.3px;
}

.sidebar-logo { max-height: 36px; max-width: 160px; }

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

.nav-item { position: relative; }

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: var(--sidebar-txt);
    border-radius: 0;
    transition: background .15s, color .15s;
    cursor: pointer;
    font-size: 13.5px;
    font-weight: 500;
}

.nav-link svg { width: 17px; height: 17px; flex-shrink: 0; }
.nav-link .chevron { margin-left: auto; width: 14px; height: 14px; transition: transform .2s; }
.nav-item.open > .nav-link .chevron { transform: rotate(180deg); }

.nav-link:hover, .nav-item.active > .nav-link {
    color: var(--sidebar-act);
    background: rgba(255,255,255,.06);
    text-decoration: none;
}

.nav-item.active > .nav-link { border-left: 3px solid var(--brand); padding-left: 17px; }

/* Sub-nav */
.nav-sub { list-style: none; overflow: hidden; max-height: 0; transition: max-height .25s ease; }
.nav-item.open > .nav-sub { max-height: 400px; }

.nav-sub-link {
    display: block;
    padding: 8px 20px 8px 47px;
    color: var(--sidebar-txt);
    font-size: 13px;
    transition: color .15s;
}

.nav-sub-link:hover,
.nav-sub-item.active .nav-sub-link { color: var(--sidebar-act); text-decoration: none; }

/* Sidebar footer */
.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,.06);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-user { flex: 1; min-width: 0; }
.sidebar-user-name { display: block; color: #fff; font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { display: block; color: var(--sidebar-txt); font-size: 11px; }

.sidebar-logout { color: var(--sidebar-txt); display: flex; }
.sidebar-logout:hover { color: var(--danger); }
.sidebar-logout svg { width: 18px; height: 18px; }

/* ---- Main Content ---- */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    background: var(--white);
    border-bottom: 1px solid var(--border);
    padding: 0 28px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-title { font-size: 18px; font-weight: 700; color: var(--text); }
.topbar-actions { display: flex; gap: 12px; align-items: center; }

.page-body { padding: 28px; flex: 1; }

/* ---- Cards ---- */
.card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

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

.card-title { font-weight: 700; font-size: 15px; }
.card-body { padding: 22px; }

/* ---- Stats Grid ---- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 18px; margin-bottom: 24px; }

.stat-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 22px;
    display: flex;
    align-items: center;
    gap: 16px;
}

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

.stat-icon svg { width: 22px; height: 22px; }
.stat-icon.purple { background: var(--brand-light); color: var(--brand); }
.stat-icon.green  { background: #E8FFF3; color: var(--success); }
.stat-icon.orange { background: #FFF8E7; color: var(--warning); }
.stat-icon.red    { background: #FFF5F8; color: var(--danger); }

.stat-label { font-size: 12px; color: var(--muted); font-weight: 500; margin-bottom: 4px; }
.stat-value { font-size: 24px; font-weight: 700; color: var(--text); line-height: 1; }

/* ---- Buttons ---- */
.btn {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 9px 18px;
    border-radius: 8px;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: opacity .15s, box-shadow .15s;
}
.btn:hover { opacity: .88; text-decoration: none; }
.btn svg { width: 15px; height: 15px; }

.btn-primary { background: var(--brand); color: #fff; }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 6px 13px; font-size: 12.5px; }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; padding: 11px 14px; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; border-bottom: 1px solid var(--border); background: var(--bg); }
td { padding: 13px 14px; border-bottom: 1px solid var(--border); font-size: 13.5px; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--brand-light); }

/* ---- Badges ---- */
.badge { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 600; }
.badge-draft     { background: #F3F4F6; color: #6B7280; }
.badge-pending   { background: #FFF8E7; color: #D97706; }
.badge-approved  { background: #E8FFF3; color: #059669; }
.badge-scheduled { background: #EEF2FF; color: var(--brand); }
.badge-published { background: #D1FAE5; color: #047857; }
.badge-rejected  { background: #FFF5F8; color: var(--danger); }
.badge-active    { background: #E8FFF3; color: var(--success); }
.badge-on_hold   { background: #FFF8E7; color: var(--warning); }
.badge-todo      { background: #F3F4F6; color: #6B7280; }
.badge-in_progress { background: #EEF2FF; color: var(--brand); }
.badge-done      { background: #D1FAE5; color: #047857; }

/* ---- Forms ---- */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; color: var(--text); }
.form-control {
    width: 100%; padding: 10px 13px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    color: var(--text);
    background: var(--white);
    transition: border-color .15s;
}
.form-control:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79,70,229,.12); }
.form-text { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ---- Alert ---- */
.alert { padding: 13px 16px; border-radius: 8px; font-size: 13.5px; margin-bottom: 18px; }
.alert-danger  { background: #FFF5F8; color: var(--danger); border: 1px solid #FECDD3; }
.alert-success { background: #E8FFF3; color: #047857; border: 1px solid #A7F3D0; }

/* ---- Login page ---- */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); }
.login-box { background: var(--white); border: 1px solid var(--border); border-radius: 14px; padding: 44px 40px; width: 100%; max-width: 400px; box-shadow: var(--shadow); }
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo h1 { font-size: 22px; font-weight: 800; color: var(--brand); }
.login-logo p { font-size: 13px; color: var(--muted); margin-top: 4px; }
