:root {
    --bg-main: #f8fafc;
    --bg-white: #ffffff;
    --border-color: #e2e8f0;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --primary-light: #eff6ff;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --sidebar-width: 260px;
    --sidebar-width-collapsed: 70px;
    --topbar-height: 64px;
    --radius: 12px;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a {
    text-decoration: none;
    color: inherit;
    transition: all 0.2s;
}

ul {
    list-style: none;
}

/* Layout */
.admin-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.admin-sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-white);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 50;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.sidebar-collapsed .admin-sidebar {
    width: var(--sidebar-width-collapsed);
}

.sidebar-header {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    padding: 0 24px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--primary);
}

.sidebar-logo img {
    height: 32px;
    width: auto;
}

.sidebar-collapsed .sidebar-logo span {
    display: none;
}

.sidebar-nav {
    flex: 1;
    padding: 24px 12px;
    overflow-y: auto;
}

.sidebar-nav ul li {
    margin-bottom: 4px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.9rem;
}

.sidebar-nav a svg {
    flex-shrink: 0;
}

.sidebar-nav a:hover {
    background-color: var(--bg-main);
    color: var(--text-main);
}

.sidebar-nav a.active {
    background-color: var(--primary-light);
    color: var(--primary);
}

.sidebar-collapsed .sidebar-nav a span {
    display: none;
}

.sidebar-collapsed .sidebar-nav a {
    justify-content: center;
    padding: 12px;
}

.sidebar-footer {
    padding: 16px 12px;
    border-top: 1px solid var(--border-color);
}

.sidebar-footer a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.sidebar-footer a:hover {
    color: var(--danger);
}

.sidebar-collapsed .sidebar-footer a span {
    display: none;
}

/* Main Content */
.admin-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

.sidebar-collapsed .admin-main {
    margin-left: var(--sidebar-width-collapsed);
}

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

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topbar-title {
    font-size: 1.1rem;
    font-weight: 600;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.site-switcher .form-control {
    min-width: 220px;
    height: 36px;
    padding: 6px 10px;
    font-size: 0.85rem;
}

.site-switcher form {
    margin: 0;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-name {
    font-size: 0.9rem;
    font-weight: 500;
}

.user-avatar {
    width: 36px;
    height: 36px;
    background-color: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
}

.admin-content {
    padding: 32px;
    flex: 1;
}

.quick-actions {
    width: 500px !important;
}

/* Components */
.card {
    background-color: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
}

.individual-card {
    width: 350px !important;
}

.card h5 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 16px;
}

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

.col-span-full {
    grid-column: 1 / -1;
}

.mt-4 {
    margin-top: 24px;
}

.mb-4 {
    margin-bottom: 24px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
}

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

.btn-outline-primary {
    border-color: var(--primary);
    color: var(--primary);
    background: transparent;
}

.btn-outline-primary:hover {
    background-color: var(--primary-light);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    border-radius: 8px;
}

.btn-icon:hover {
    background-color: var(--bg-main);
    color: var(--text-main);
}

/* Alerts */
.alert {
    padding: 16px;
    border-radius: 10px;
    margin-bottom: 24px;
    font-size: 0.9rem;
}

.alert-success {
    background-color: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.alert-danger {
    background-color: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

/* Tables */
.table-container {
    background-color: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th {
    background-color: var(--bg-main);
    padding: 12px 20px;
    text-align: left;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
}

.table td {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
}

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

.table tr:hover {
    background-color: #f9fafb;
}

/* Utilities */
.w-100 {
    width: 100% !important;
}

.py-2 {
    padding-top: 8px !important;
    padding-bottom: 8px !important;
}

.py-3 {
    padding-top: 12px !important;
    padding-bottom: 12px !important;
}

.py-4 {
    padding-top: 16px !important;
    padding-bottom: 16px !important;
}

.mb-0 {
    margin-bottom: 0 !important;
}

.mb-1 {
    margin-bottom: 4px !important;
}

.mb-2 {
    margin-bottom: 8px !important;
}

.mb-3 {
    margin-bottom: 16px !important;
}

.mb-4 {
    margin-bottom: 24px !important;
}

.mt-2 {
    margin-top: 8px !important;
}

.mt-3 {
    margin-top: 16px !important;
}

.mt-4 {
    margin-top: 24px !important;
}

.d-flex {
    display: flex !important;
}

.d-grid {
    display: grid !important;
}

.d-block {
    display: block !important;
}

.d-inline-block {
    display: inline-block !important;
}

.collapse {
    display: none;
}

.collapse.show {
    display: block;
}

tr.collapse.show {
    display: table-row;
}

.gap-2 {
    gap: 8px !important;
}

.gap-3 {
    gap: 16px !important;
}

.justify-content-between {
    justify-content: space-between !important;
}

.justify-content-center {
    justify-content: center !important;
}

.align-items-center {
    align-items: center !important;
}

.align-items-start {
    align-items: flex-start !important;
}

.flex-1 {
    flex: 1 !important;
}

.text-center {
    text-align: center !important;
}

.text-muted {
    color: var(--text-muted) !important;
}

.text-danger {
    color: var(--danger) !important;
}

.small {
    font-size: 0.875rem !important;
}

.font-weight-bold {
    font-weight: 600 !important;
}

.shadow-sm {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08) !important;
}

.sticky-top {
    position: sticky !important;
}

.bg-light {
    background-color: var(--bg-light) !important;
}

/* Row/Column Grid */
.row {
    display: grid;
    gap: 16px;
}

.col-1,
.col-2,
.col-3,
.col-4,
.col-5,
.col-6,
.col-7,
.col-8,
.col-9,
.col-10,
.col-11,
.col-12,
.col-md-1,
.col-md-2,
.col-md-3,
.col-md-4,
.col-md-5,
.col-md-6,
.col-md-7,
.col-md-8,
.col-md-9,
.col-md-10,
.col-md-11,
.col-md-12 {
    grid-column: span 12;
}

@media (min-width: 768px) {
    .row {
        grid-template-columns: repeat(12, 1fr);
    }

    .col-md-1 {
        grid-column: span 1;
    }

    .col-md-2 {
        grid-column: span 2;
    }

    .col-md-3 {
        grid-column: span 3;
    }

    .col-md-4 {
        grid-column: span 4;
    }

    .col-md-5 {
        grid-column: span 5;
    }

    .col-md-6 {
        grid-column: span 6;
    }

    .col-md-7 {
        grid-column: span 7;
    }

    .col-md-8 {
        grid-column: span 8;
    }

    .col-md-9 {
        grid-column: span 9;
    }

    .col-md-10 {
        grid-column: span 10;
    }

    .col-md-11 {
        grid-column: span 11;
    }

    .col-md-12 {
        grid-column: span 12;
    }

    .d-md-none {
        display: none !important;
    }

    .d-md-block {
        display: block !important;
    }

    .d-md-flex {
        display: flex !important;
    }
}

.d-none {
    display: none !important;
}

.d-block {
    display: block !important;
}

.d-flex {
    display: flex !important;
}

/* Forms */
.form-section {
    margin-bottom: 32px;
}

.form-section-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 20px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
    color: var(--primary);
}

.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text-main);
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.9rem;
    background-color: var(--bg-white);
    transition: all 0.2s;
    color: var(--text-main);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-text {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 4px;
    display: block;
    max-width: 520px;
}

.form-label {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 6px;
    display: inline-block;
}

/* TinyMCE Editor Styling */
.tox-tinymce {
    border: 1px solid var(--border-color) !important;
    border-radius: 8px !important;
    overflow: hidden;
}

.tox .tox-toolbar,
.tox .tox-toolbar__overflow,
.tox .tox-toolbar__primary {
    background: var(--bg-light) !important;
    border-bottom: 1px solid var(--border-color) !important;
}

.tox .tox-tbtn {
    color: var(--text-main) !important;
}

.tox .tox-tbtn:hover {
    background: var(--bg-white) !important;
}

.tox .tox-tbtn--enabled,
.tox .tox-tbtn--enabled:hover {
    background: var(--primary-light) !important;
    color: var(--primary) !important;
}

.tox .tox-edit-area__iframe {
    background: var(--bg-white) !important;
}

.tox-statusbar {
    border-top: 1px solid var(--border-color) !important;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

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

.modal-dialog {
    background: var(--bg-white);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 90vw;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-dialog.modal-xl {
    max-width: 1200px;
}

.modal-dialog.modal-lg {
    max-width: 900px;
}

.modal-content {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.modal-header {
    padding: 24px 32px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-main);
    margin: 0;
}

.modal-body {
    padding: 32px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 20px 32px;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    flex-shrink: 0;
}

.btn-close {
    background: transparent;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-muted);
}

.btn-close:hover {
    background: var(--bg-light);
    color: var(--text-main);
}

.btn-close::before {
    content: "×";
    font-size: 28px;
    line-height: 1;
}

/* Form Check (Checkbox) */
.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-check-input {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.form-check-input:checked {
    background: var(--primary);
    border-color: var(--primary);
}

.form-check-label {
    cursor: pointer;
    user-select: none;
    font-size: 0.9rem;
}

/* Image Preview Container */
.image-preview-container {
    position: relative;
    display: inline-block;
}

.image-preview-container img {
    display: block;
}

/* Responsive */
@media (max-width: 1024px) {
    .admin-sidebar {
        transform: translateX(-100%);
    }

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

    .admin-main {
        margin-left: 0;
    }

    .sidebar-toggle {
        display: flex;
    }

    .modal-dialog {
        max-width: 95vw;
        max-height: 95vh;
    }

    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 20px;
    }
}

/* Auth pages */
.auth-layout {
    min-height: 100vh;
    background: var(--bg-main);
}

.auth-main {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 16px;
}

.auth-card {
    width: 100%;
    max-width: 520px;
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 28px;
}

.auth-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 18px;
}

.auth-logo {
    width: 44px;
    height: 44px;
    object-fit: contain;
}

.auth-header h1 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.auth-header p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.auth-form .form-group {
    margin-bottom: 16px;
}

.auth-footer {
    margin-top: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 0.9rem;
}

.auth-link {
    color: var(--primary);
    font-weight: 600;
}

.auth-link:hover {
    color: var(--primary-hover);
}

.password-field {
    position: relative;
}

.password-field .form-control {
    padding-right: 44px;
}

.password-toggle {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
}

.internal-link-results {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.internal-link-item {
    width: 100%;
    text-align: left;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 12px;
    cursor: pointer;
    font-size: 0.9rem;
}

.internal-link-item:hover {
    background: var(--primary-light);
    border-color: var(--primary);
}