/* ============================================================
   NP2 — NewsPhase2  |  Core Styles v2
   Dropdown menu from logo, full-width content area
   ============================================================ */

:root {
    --bg-body:          #f0f0f0;
    --bg-header:        #c8c8c8;
    --bg-content:       #ffffff;
    --bg-dropdown:      #ffffff;
    --bg-hover:         #f2f3f5;
    --bg-active:        #e8eaed;
    --bg-modal:         rgba(0,0,0,0.45);

    --text-primary:     #1a1a1a;
    --text-secondary:   #555;
    --text-muted:       #888;
    --text-on-dark:     #fff;

    --accent:           #c0392b;
    --accent-soft:      #e74c3c;
    --border:           #bbb;
    --border-light:     #e0e0e0;

    --header-height:    52px;

    --font-body:        'DM Sans', sans-serif;
    --font-mono:        'Space Mono', monospace;

    --radius:           6px;
    --radius-lg:        10px;
    --transition:       0.2s ease;
    --shadow-dropdown:  0 8px 30px rgba(0,0,0,0.18), 0 2px 8px rgba(0,0,0,0.08);
    --shadow-modal:     0 20px 60px rgba(0,0,0,0.2);
}

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

html, body {
    height: 100%;
    font-family: var(--font-body);
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-body);
    -webkit-font-smoothing: antialiased;
}

/* ============================================================
   HEADER — Gray bar across the top
   ============================================================ */
#app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    height: var(--header-height);
    background: var(--bg-header);
    border-bottom: 1px solid var(--border);
    padding: 0 16px;
    gap: 12px;
    z-index: 100;
}

/* ---- Logo / Brand ---- */
.header-brand {
    flex-shrink: 0;
    position: relative;
}

.logo {
    display: flex;
    align-items: center;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
    position: relative;
    z-index: 201;
}

.logo-img {
    height: 38px;
    width: 38px;
    object-fit: contain;
    border-radius: 50%;
    transition: transform var(--transition), box-shadow var(--transition);
}

.logo:hover .logo-img {
    transform: scale(1.08);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.logo.menu-open .logo-img {
    box-shadow: 0 2px 12px rgba(0,0,0,0.2);
    transform: scale(1.05);
}

/* ---- Header Tabs (pinned groups) ---- */
.header-tabs {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0 8px;
    overflow-x: auto;
    min-width: 0;
}

.header-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border: none;
    border-radius: var(--radius);
    background: rgba(255,255,255,0.35);
    color: var(--text-secondary);
    font-family: var(--font-body);
    font-size: 12.5px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: background var(--transition), color var(--transition);
}

.header-tab:hover {
    background: rgba(255,255,255,0.6);
    color: var(--text-primary);
}

.header-tab.active {
    background: #fff;
    color: var(--text-primary);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.header-tab-icon { display: flex; align-items: center; }
.header-tab-icon svg { width: 14px; height: 14px; }

/* ---- Header Actions (+ button, user badge) ---- */
.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    position: relative;
    z-index: 10;
}

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: var(--radius);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    position: relative;
    z-index: 11;
    transition: background var(--transition), color var(--transition);
}

.btn-icon:hover {
    background: rgba(255,255,255,0.5);
    color: var(--text-primary);
}

.user-badge {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.user-initials {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-on-dark);
    letter-spacing: 0.5px;
}

/* ============================================================
   DROPDOWN MENU — drops from logo
   ============================================================ */
.dropdown-backdrop {
    position: fixed;
    inset: 0;
    z-index: 150;
    background: transparent;
}

.dropdown-menu {
    position: fixed;
    top: calc(var(--header-height) + 4px);
    left: 16px;
    width: 280px;
    max-height: calc(100vh - var(--header-height) - 32px);
    overflow-y: auto;
    background: var(--bg-dropdown);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-dropdown);
    border: 1px solid var(--border-light);
    z-index: 200;
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity 0.15s ease, transform 0.15s ease;
    pointer-events: none;
}

.dropdown-menu.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.dropdown-inner {
    padding: 8px;
}

/* ---- Dropdown Group ---- */
.dropdown-group {
    margin-bottom: 2px;
}

.dropdown-group-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 9px 12px;
    border: none;
    border-radius: var(--radius);
    background: transparent;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition);
    text-align: left;
}

.dropdown-group-toggle:hover {
    background: var(--bg-hover);
}

.dropdown-group-icon {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    color: var(--text-secondary);
}

.dropdown-group-label { flex: 1; }

.dropdown-chevron {
    transition: transform var(--transition);
    color: var(--text-muted);
    flex-shrink: 0;
}

.dropdown-group.expanded .dropdown-chevron {
    transform: rotate(180deg);
}

/* ---- Dropdown Items ---- */
.dropdown-group-items {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease;
}

.dropdown-group.expanded .dropdown-group-items {
    max-height: 400px;
}

.dropdown-link {
    display: block;
    padding: 7px 12px 7px 38px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13px;
    font-weight: 400;
    border-radius: var(--radius);
    transition: background var(--transition), color var(--transition);
}

.dropdown-link:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.dropdown-link.active {
    background: var(--bg-active);
    color: var(--text-primary);
    font-weight: 500;
}

/* Divider between groups */
.dropdown-divider {
    height: 1px;
    background: var(--border-light);
    margin: 6px 12px;
}

/* ============================================================
   MAIN CONTENT — full width below header
   ============================================================ */
#main-content {
    margin-top: var(--header-height);
    min-height: calc(100vh - var(--header-height));
    background: var(--bg-content);
    padding: 32px;
}

.content-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: calc(100vh - var(--header-height) - 64px);
    text-align: center;
}

.content-welcome h1 {
    font-family: var(--font-mono);
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -1px;
    margin-bottom: 8px;
}

.content-welcome p {
    color: var(--text-muted);
    font-size: 15px;
}

.content-page {
    max-width: 1200px;
    margin: 0 auto;
}

.content-breadcrumb {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 8px;
    font-weight: 500;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

.content-page h1 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 16px;
}

.content-placeholder {
    color: var(--text-muted);
    padding: 60px 40px;
    border: 2px dashed var(--border-light);
    border-radius: var(--radius-lg);
    text-align: center;
    font-size: 14px;
}

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-modal);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 999;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.modal-overlay.visible {
    display: flex;
    opacity: 1;
}

.modal {
    background: #fff;
    border-radius: var(--radius-lg);
    width: 380px;
    max-width: 90vw;
    box-shadow: var(--shadow-modal);
    transform: translateY(10px);
    transition: transform 0.2s ease;
}

.modal-overlay.visible .modal {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-light);
}

.modal-header h3 {
    font-size: 15px;
    font-weight: 600;
}

.modal-body { padding: 16px 20px; }

.modal-group-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 8px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background var(--transition);
    font-size: 13.5px;
    font-weight: 500;
}

.modal-group-row:hover { background: var(--bg-hover); }

.modal-group-row input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
}

.modal-group-icon {
    display: flex;
    align-items: center;
    color: var(--text-secondary);
}

.modal-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border-light);
    display: flex;
    justify-content: flex-end;
}

.btn-primary {
    padding: 8px 24px;
    border: none;
    border-radius: var(--radius);
    background: var(--accent);
    color: #fff;
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition);
}

.btn-primary:hover { background: var(--accent-soft); }

/* ============================================================
   TOAST
   ============================================================ */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #1a1a1a;
    color: #fff;
    padding: 12px 20px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    font-weight: 500;
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    z-index: 1000;
    box-shadow: 0 8px 30px rgba(0,0,0,0.25);
}

.toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ============================================================
   SCROLLBAR (dropdown)
   ============================================================ */
.dropdown-menu::-webkit-scrollbar { width: 4px; }
.dropdown-menu::-webkit-scrollbar-track { background: transparent; }
.dropdown-menu::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ============================================================
   MODULE HEADER (title + action button row)
   ============================================================ */
.module-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.module-header h1 { margin: 0; }

.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-icon-inline { display: flex; align-items: center; }
.btn-icon-inline svg { width: 16px; height: 16px; }

.btn-secondary {
    padding: 8px 24px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition);
}

.btn-secondary:hover { background: var(--bg-hover); }

.btn-danger {
    padding: 8px 24px;
    border: none;
    border-radius: var(--radius);
    background: #e74c3c;
    color: #fff;
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition);
}

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

.btn-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border: none;
    border-radius: var(--radius);
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
}

.btn-back:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.btn-back svg { width: 16px; height: 16px; }

/* ============================================================
   TOOLBAR (Search + Filters)
   ============================================================ */
.toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #fff;
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 8px 12px;
    flex: 1;
    min-width: 200px;
    max-width: 360px;
    transition: border-color var(--transition);
}

.search-box:focus-within { border-color: var(--accent); }

.search-icon { display: flex; color: var(--text-muted); }
.search-icon svg { width: 16px; height: 16px; }

.search-box input {
    border: none;
    outline: none;
    font-family: var(--font-body);
    font-size: 13px;
    width: 100%;
    background: transparent;
}

.toolbar-filters {
    display: flex;
    gap: 8px;
}

.select-small {
    padding: 8px 12px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    font-family: var(--font-body);
    font-size: 13px;
    background: #fff;
    color: var(--text-primary);
    cursor: pointer;
}

/* ============================================================
   DATA TABLE
   ============================================================ */
.table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    background: #fff;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

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

.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: middle;
}

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

.data-table tr:hover td { background: #fafbfc; }

.th-actions { width: 100px; text-align: right; }
.td-actions { text-align: right; white-space: nowrap; }

.td-name {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
}

.avatar-sm {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--bg-active);
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.btn-sm {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: none;
    border-radius: var(--radius);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
}

.btn-sm:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.btn-sm.btn-delete:hover { color: #e74c3c; }

.btn-sm svg { width: 15px; height: 15px; }

/* ============================================================
   BADGES
   ============================================================ */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.2px;
}

.badge-role {
    background: #eef2ff;
    color: #4338ca;
}

.badge-success {
    background: #ecfdf5;
    color: #059669;
}

.badge-warning {
    background: #fffbeb;
    color: #d97706;
}

.badge-muted {
    background: #f3f4f6;
    color: #9ca3af;
}

/* ============================================================
   FORM CARD
   ============================================================ */
.form-card {
    background: #fff;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 0;
    overflow: hidden;
}

.form-section {
    padding: 24px 28px;
    border-bottom: 1px solid #f0f0f0;
}

.form-section:last-of-type { border-bottom: none; }

.form-section h3 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.form-section h3 svg { width: 18px; height: 18px; color: var(--text-secondary); }

.form-section-hint {
    font-size: 12.5px;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

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

.form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.form-group label {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-secondary);
}

.form-group input,
.form-group select {
    padding: 9px 12px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    font-family: var(--font-body);
    font-size: 13.5px;
    color: var(--text-primary);
    transition: border-color var(--transition);
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent);
}

.form-hint {
    font-size: 11.5px;
    color: var(--text-muted);
}

.form-row-inline {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.toggle-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
}

.toggle-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
}

.form-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 28px;
    background: #fafafa;
    border-top: 1px solid #f0f0f0;
}

.form-actions .btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.form-actions .btn-primary svg { width: 16px; height: 16px; }

/* ============================================================
   ROLES — Card Grid
   ============================================================ */
.roles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}

.role-card {
    background: #fff;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 20px;
    transition: box-shadow var(--transition);
}

.role-card:hover {
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}

.role-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 16px;
}

.role-card-header h3 {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 4px;
}

.role-card-desc {
    font-size: 12.5px;
    color: var(--text-muted);
}

.role-card-perms {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.role-perm-group {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12.5px;
    color: var(--text-secondary);
}

.role-perm-icon { display: flex; color: var(--text-muted); }
.role-perm-icon svg { width: 14px; height: 14px; }

.role-perm-label { flex: 1; }

.role-perm-count {
    font-weight: 600;
    font-size: 11.5px;
    color: var(--text-muted);
    background: #f3f4f6;
    padding: 2px 8px;
    border-radius: 10px;
}

.role-perm-count.count-full {
    background: #ecfdf5;
    color: #059669;
}

/* ============================================================
   PERMISSION GRID (Role Editor)
   ============================================================ */
.perm-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.perm-module {
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    overflow: hidden;
}

.perm-module-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: #fafafa;
    border-bottom: 1px solid var(--border-light);
}

.perm-module-icon { display: flex; color: var(--text-secondary); }
.perm-module-label { flex: 1; font-weight: 600; font-size: 13px; }

.toggle-all {
    font-size: 12px;
    color: var(--text-muted);
}

.perm-module-items {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0;
}

.perm-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 14px;
    cursor: pointer;
    font-size: 13px;
    transition: background var(--transition);
    border-bottom: 1px solid #f5f5f5;
}

.perm-item:hover { background: #fafbfc; }

.perm-item input[type="checkbox"] {
    width: 15px;
    height: 15px;
    accent-color: var(--accent);
    cursor: pointer;
}