:root {
    --bg: #ffffff;
    --card: #ffffff;
    --text: #1a1a1a;
    --muted: #666666;
    --accent: #000000;
    --border: #e0e0e0;
    --danger: #dc2626;
    --sidebar: #f5f5f5;
    --topbar: #1a1a1a;
    --text-light: #ffffff;
    --input-bg: #fafafa;
    --input-focus: #ffffff;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
}

[data-theme="dark"] {
    --bg: #121212;
    --card: #1e1e1e;
    --text: #e5e5e5;
    --muted: #a0a0a0;
    --accent: #f07707;
    --border: #333333;
    --danger: #ef4444;
    --sidebar: #121213;
    --topbar: #0a0a0a;
    --text-light: #e5e5e5;
    --input-bg: #2a2a2a;
    --input-focus: #333333;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.5);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

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

a:hover {
    text-decoration: underline;
}

/* Sidebar */
.sidebar {
    width: 240px;
    background: var(--sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: fixed;
    top: 56px;
    left: 0;
    bottom: 0;
    overflow-y: auto;
    z-index: 100;
}

.sidebar .brand {
    padding: 1.50rem;
    border-bottom: 1px solid var(--border);
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.sidebar .brand a {
    color: var(--text);
}

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

[data-theme="dark"] .sidebar .brand a {
    color: var(--text-light);
}

.sidebar nav {
    display: flex;
    flex-direction: column;
    flex: 1;
    padding: 0.75rem 0;
}

.sidebar .section-label {
    padding: 0.75rem 1.25rem 0.25rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #666666;
}

[data-theme="dark"] .sidebar .section-label {
    color: #666666;
}

.sidebar nav a {
    padding: 0.80rem 1.50rem;
    color: #444444;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    transition: color 0.15s, background 0.15s;
}

.sidebar nav a:hover {
    background: rgba(0,0,0,0.05);
    color: #000000;
    text-decoration: none;
}

.sidebar nav a.active {
    color: #ffffff;
    background: #000000;
    border-radius: 6px;
    margin: 0 0.5rem;
    padding-left: 1rem;
}

[data-theme="dark"] .sidebar nav a {
    color: #cccccc;
}

[data-theme="dark"] .sidebar nav a:hover {
    background: rgba(255,255,255,0.1);
    color: #ffffff;
}

[data-theme="dark"] .sidebar nav a.active {
    color: #ffffff;
    background: #f07707;
    border-radius: 6px;
}

[data-theme="dark"] .btn {
    background: #f07707;
    color: #1a1a1a;
}

[data-theme="dark"] .btn:hover {
    background: #f07707;
}

[data-theme="dark"] .btn.secondary {
    background: transparent;
    border-color: #666666;
    color: #e5e5e5;
}

[data-theme="dark"] .btn.secondary:hover {
    background: rgba(255, 182, 193, 0.1);
    border-color: #ffb6c1;
}

.sidebar nav a .icon {
    width: 18px;
    text-align: center;
    flex-shrink: 0;
}

/* Sidebar backdrop */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99;
}

.sidebar-backdrop.open {
    display: block;
}

/* Topbar */
.topbar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 0 1.5rem;
    height: 56px;
    border-bottom: 1px solid #333333;
    background: var(--topbar);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 110;
}

.topbar .page-title {
    margin-right: auto;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-light);
}

.icon-btn.hamburger {
    display: none;
}

/* Icon button */
.icon-btn {
    position: relative;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: #cccccc;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: background 0.15s, color 0.15s;
}

.icon-btn:hover {
    background: rgba(255,255,255,0.1);
    color: #ffffff;
}

.icon-btn .badge {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--danger);
    color: #fff;
    font-size: 0.6rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

/* Dropdown panels */
.dropdown {
    position: relative;
}

.dropdown-panel {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.35);
    min-width: 260px;
    z-index: 200;
    overflow: hidden;
}

.dropdown.open .dropdown-panel {
    display: block;
}

/* Wrapper - below topbar, next to sidebar */
.wrapper {
    margin-left: 240px;
    margin-top: 56px;
    min-height: calc(100vh - 56px);
    display: flex;
    flex-direction: column;
}

/* Notification panel */
.notif-panel {
    width: 340px;
    max-height: 420px;
    overflow-y: auto;
}

.notif-panel .notif-header {
    padding: 0.85rem 1rem;
    font-weight: 600;
    font-size: 0.95rem;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--card);
}

.notif-item {
    display: flex;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    transition: background 0.1s;
    cursor: default;
}

.notif-item:hover {
    background: rgba(0,0,0,0.03);
}

[data-theme="dark"] .notif-item:hover {
    background: rgba(255,255,255,0.03);
}

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

.notif-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    flex-shrink: 0;
    margin-top: 6px;
}

.notif-dot.read {
    background: transparent;
}

.notif-content {
    flex: 1;
    min-width: 0;
}

.notif-content .notif-title {
    font-size: 0.85rem;
    margin-bottom: 2px;
    color: var(--text);
}

.notif-content .notif-time {
    font-size: 0.75rem;
    color: var(--muted);
}

/* User dropdown */
.user-panel {
    padding: 1rem;
    border: 1px solid var(--border);
}

.user-panel .user-info {
    margin-bottom: 0.75rem;
}

.user-panel .user-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text);
}

.user-panel .user-email {
    font-size: 0.8rem;
    color: var(--muted);
}

.user-panel .logout-btn {
    display: block;
    width: 100%;
    text-align: center;
    padding: 0.5rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text);
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.15s;
}

.user-panel .logout-btn:hover {
    background: rgba(0,0,0,0.05);
}

/* Main content */
main {
    flex: 1;
    max-width: 1100px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    width: 100%;
    overflow-y: auto;
}

/* Cards & Tables */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
}

.muted {
    color: var(--muted);
    font-size: 0.9rem;
}

.grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
}

.stat {
    padding: 1rem;
    background: var(--bg);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.stat span {
    display: block;
    font-size: 1.75rem;
    font-weight: 600;
}

/* Form elements */
label {
    display: block;
    margin-bottom: 0.4rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="datetime-local"],
select,
textarea {
    width: 100%;
    padding: 0.65rem 0.75rem;
    border-radius: var(--radius-sm);
    border: 1px solid #d1d5db;
    background: var(--input-bg);
    color: var(--text);
    margin-bottom: 0;
    font-size: 0.9rem;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--input-focus);
    box-shadow: 0 0 0 3px rgba(0,0,0,0.08), var(--shadow-md);
}

input::placeholder,
textarea::placeholder {
    color: #9ca3af;
}

select {
    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 0.5rem center;
    background-repeat: no-repeat;
    background-size: 1.5em 1.5em;
    padding-right: 2.5rem;
    cursor: pointer;
}

textarea {
    min-height: 100px;
    font-family: inherit;
    font-size: 0.9rem;
    line-height: 1.5;
    resize: vertical;
}

.form-grid {
    display: grid;
    gap: 0 1rem;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 1rem;
    align-items: center;
}

button,
.btn {
    cursor: pointer;
    padding: 0.65rem 1.25rem;
    border-radius: var(--radius-sm);
    border: none;
    background: var(--accent);
    color: #fff;
    font-weight: 600;
    font-size: 0.875rem;
    display: inline-block;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
}

button:hover,
.btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
    text-decoration: none;
}

button:active,
.btn:active {
    transform: translateY(0);
}

button.secondary,
.btn.secondary {
    background: transparent;
    border: 1px solid #d1d5db;
    color: var(--text);
    box-shadow: none;
}

button.secondary:hover,
.btn.secondary:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
    box-shadow: var(--shadow-sm);
}

button.danger,
.btn.danger {
    background: var(--danger);
    box-shadow: var(--shadow-sm);
}

button.danger:hover,
.btn.danger:hover {
    background: #b91c1c;
    box-shadow: var(--shadow-md);
}

.error {
    color: var(--danger);
    font-size: 0.875rem;
    margin-bottom: 0.75rem;
}

.flash {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    background: rgba(0,0,0,0.05);
    border: 1px solid var(--accent);
    margin-bottom: 1.25rem;
}

[data-theme="dark"] .flash {
    background: rgba(255,255,255,0.05);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

th,
td {
    text-align: left;
    padding: 0.6rem 0.5rem;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

th {
    color: var(--muted);
    font-weight: 600;
}

.table-wrap {
    overflow-x: auto;
}

.pill {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    background: var(--bg);
    border: 1px solid var(--border);
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
    margin-bottom: 1rem;
}

h1 {
    margin-top: 0;
    font-size: 1.5rem;
}

h2 {
    font-size: 1.15rem;
    margin-top: 0;
}

.check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.check input {
    width: auto;
    margin: 0;
}

/* Pagination - Bootstrap compatible */
.pagination {
    display: flex !important;
    justify-content: center;
    gap: 4px;
    margin-top: 1.5rem;
    margin-bottom: 0;
    padding: 0;
    list-style: none;
    flex-wrap: wrap;
}

.pagination .page-item {
    display: inline-block;
    margin: 0 2px;
}

.pagination .page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    text-decoration: none;
    font-size: 0.875rem;
    background: transparent;
    cursor: pointer;
    transition: all 0.15s ease;
}

.pagination .page-link:hover {
    background: rgba(0,0,0,0.05);
    color: var(--text);
    text-decoration: none;
}

[data-theme="dark"] .pagination .page-link:hover {
    background: rgba(255,255,255,0.1);
}

.pagination .page-item.active .page-link {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.pagination .page-item.disabled .page-link {
    opacity: 0.4;
    pointer-events: none;
    color: var(--muted);
    background: transparent;
}

/* Hide responsive elements in pagination */
.pagination .d-flex,
.pagination .justify-content-between,
.pagination .flex-fill,
.pagination .d-sm-none,
.pagination .d-sm-flex,
.pagination .d-none,
.pagination .text-muted,
.pagination .small {
    display: none !important;
}

.pagination-wrapper {
    display: block;
    text-align: center;
}

.pagination-with-perpage {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.per-page-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
}

.per-page-select {
    width: auto;
    padding: 0.25rem 0.5rem;
    font-size: 0.85rem;
    margin: 0;
    min-width: 60px;
}

.pagination-info {
    margin-left: 0.5rem;
}

@media (min-width: 576px) {
    .pagination-with-perpage {
        flex-direction: row;
        justify-content: space-between;
    }

    .per-page-selector {
        order: -1;
    }
}

/* Mobile */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.25s ease;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .wrapper {
        margin-left: 0;
    }

    .icon-btn.hamburger {
        display: flex;
    }

    .topbar {
        padding: 0 1rem;
    }

    #sidebarClose {
        display: flex !important;
    }
}

/* Filters */
.filters {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: flex-end;
}

.filters > div {
    flex: 1;
    min-width: 150px;
    max-width: 220px;
}

.filters label {
    display: block;
    margin-bottom: 0.35rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.filters input {
    width: 100%;
    margin: 0;
}

.filters select {
    width: 100%;
    margin: 0;
    min-width: 0;
}

.filters .btn {
    white-space: nowrap;
    flex-shrink: 0;
    height: 36px;
    align-self: flex-end;
}

.filter-actions {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
}

@media (max-width: 640px) {
    .filters > div {
        max-width: 100%;
    }
}

/* Icon links */
.icon-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    text-decoration: none;
    font-size: 1rem;
    margin-right: 0.25rem;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}

.icon-link:hover {
    background: rgba(0,0,0,0.05);
}

[data-theme="dark"] .icon-link:hover {
    background: rgba(255,255,255,0.05);
}

.icon-link.danger {
    color: var(--danger);
}

.icon-link.danger:hover {
    background: rgba(220, 38, 38, 0.1);
}

/* Pagination wrapper */
.pagination-wrapper {
    display: block;
    text-align: center;
}

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-overlay.open {
    display: flex;
}

.modal {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    max-width: 400px;
    width: 90%;
    text-align: center;
}

.modal h3 {
    margin-top: 0;
    margin-bottom: 0.5rem;
}

.modal p {
    color: var(--muted);
    margin-bottom: 1.5rem;
}

.modal-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}

/* Quill Editor Styles */
.ql-toolbar {
    border: 1px solid #d1d5db;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    background: #fafafa;
}

.ql-container {
    border: 1px solid #d1d5db;
    border-top: none;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    font-family: inherit;
    font-size: 0.9rem;
}

.ql-editor {
    min-height: 200px;
    line-height: 1.6;
}

.ql-editor.ql-blank::before {
    color: #9ca3af;
    font-style: normal;
}

.ql-snow .ql-stroke {
    stroke: #6b7280;
}

.ql-snow .ql-fill {
    fill: #6b7280;
}

.ql-snow .ql-picker {
    color: #6b7280;
}

.ql-snow .ql-picker-options {
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
}

.ql-snow.ql-toolbar button:hover,
.ql-snow .ql-toolbar button:hover,
.ql-snow.ql-toolbar button.ql-active,
.ql-snow .ql-toolbar button.ql-active {
    background: #e5e7eb;
    border-radius: 4px;
}

.ql-snow.ql-toolbar button:hover .ql-stroke,
.ql-snow .ql-toolbar button:hover .ql-stroke,
.ql-snow.ql-toolbar button.ql-active .ql-stroke,
.ql-snow .ql-toolbar button.ql-active .ql-stroke {
    stroke: var(--accent);
}

.ql-snow.ql-toolbar button:hover .ql-fill,
.ql-snow .ql-toolbar button:hover .ql-fill,
.ql-snow.ql-toolbar button.ql-active .ql-fill,
.ql-snow .ql-toolbar button.ql-active .ql-fill {
    fill: var(--accent);
}

/* Dark mode Quill */
[data-theme="dark"] .ql-toolbar {
    background: var(--card);
    border-color: var(--border);
}

[data-theme="dark"] .ql-container {
    background: var(--card);
    border-color: var(--border);
}

[data-theme="dark"] .ql-editor {
    color: var(--text);
}

[data-theme="dark"] .ql-snow .ql-stroke {
    stroke: var(--muted);
}

[data-theme="dark"] .ql-snow .ql-fill {
    fill: var(--muted);
}

[data-theme="dark"] .ql-snow .ql-picker {
    color: var(--muted);
}

[data-theme="dark"] .ql-snow .ql-picker-options {
    background: var(--card);
    border-color: var(--border);
}

[data-theme="dark"] .ql-snow.ql-toolbar button:hover,
[data-theme="dark"] .ql-snow .ql-toolbar button:hover {
    background: var(--bg);
}
