:root {
    --sidebar-bg: #1e2a3b;
    --sidebar-hover: #2a3a4f;
    --sidebar-active: #3a4a5f;
    --primary-color: #f5683d;
    --text-light: #ffffff;
    --text-muted: #8a94a6;
    --border-color: #2a3a4f;
    --content-bg: #f5f7fa;
    --card-bg: #ffffff;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--content-bg);
    min-height: 100vh;
}

.admin-wrapper {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--sidebar-bg);
    min-height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-logo {
    color: var(--text-light);
    font-size: 24px;
    font-weight: 700;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-logo img {
    height: 35px;
}

.sidebar {
    height: 100vh;
    overflow: hidden;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 15px 0;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.sidebar-nav::-webkit-scrollbar {
    display: none;
}

.nav-section {
    margin-bottom: 10px;
}

.nav-section-title {
    padding: 10px 20px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
}

.nav-item {
    display: block;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: var(--text-muted);
    text-decoration: none;
    transition: all 0.2s ease;
    font-size: 14px;
}

.nav-link:hover {
    background: var(--sidebar-hover);
    color: var(--text-light);
}

.nav-link.active {
    background: var(--sidebar-active);
    color: var(--text-light);
    border-left: 3px solid var(--primary-color);
}

.nav-link i {
    font-size: 18px;
    width: 24px;
    text-align: center;
}

.nav-submenu {
    display: none;
    background: rgba(0, 0, 0, 0.1);
}

.nav-item.open .nav-submenu {
    display: block;
}

.nav-submenu .nav-link {
    padding-left: 56px;
    font-size: 13px;
}

.nav-toggle {
    margin-left: auto;
    transition: transform 0.2s ease;
}

.nav-item.open .nav-toggle {
    transform: rotate(90deg);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 260px;
    min-height: 100vh;
}

.top-bar {
    background: var(--card-bg);
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    position: sticky;
    top: 0;
    z-index: 50;
}

.top-bar-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--sidebar-bg);
}

.page-title {
    font-size: 20px;
    font-weight: 600;
    color: #1e2a3b;
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.user-name {
    font-size: 14px;
    font-weight: 500;
}

.logout-btn {
    background: none;
    border: 1px solid #ddd;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: #666;
    text-decoration: none;
    transition: all 0.2s ease;
}

.logout-btn:hover {
    background: #f5f5f5;
    border-color: #ccc;
}

/* Content Area */
.content-area {
    padding: 30px;
}

.card {
    background: var(--card-bg);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    margin-bottom: 20px;
}

.card-header {
    padding: 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-title {
    font-size: 18px;
    font-weight: 600;
    color: #1e2a3b;
}

.card-body {
    padding: 20px;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    transition: all 0.2s ease;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: #e55a32;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-success {
    background: #28a745;
    color: white;
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

/* Tables */
.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #1e2a3b;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table tr:hover {
    background: #f8f9fa;
}

.table-actions {
    display: flex;
    gap: 8px;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #1e2a3b;
}

.form-control {
    width: 100%;
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.2s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
}

.form-control-file {
    padding: 8px 0;
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

select.form-control {
    cursor: pointer;
}

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--card-bg);
    border-radius: 8px;
    padding: 25px;
    display: flex;
    align-items: center;
    gap: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: white;
}

.stat-icon.blue { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }
.stat-icon.green { background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%); }
.stat-icon.orange { background: linear-gradient(135deg, #f5683d 0%, #ff8c3d 100%); }
.stat-icon.purple { background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%); }

.stat-info h3 {
    font-size: 28px;
    font-weight: 700;
    color: #1e2a3b;
}

.stat-info p {
    color: var(--text-muted);
    font-size: 14px;
    margin-top: 5px;
}

/* Alerts */
.alert {
    padding: 15px 20px;
    border-radius: 4px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-danger {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert-warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeeba;
}

/* Badges */
.badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.badge-success { background: #d4edda; color: #155724; }
.badge-danger { background: #f8d7da; color: #721c24; }
.badge-warning { background: #fff3cd; color: #856404; }
.badge-info { background: #d1ecf1; color: #0c5460; }

/* Search Box */
.search-box {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.search-box input {
    flex: 1;
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

/* Login Page */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e2a3b 0%, #2a3a4f 100%);
}

.login-box {
    background: white;
    padding: 40px;
    border-radius: 10px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
}

.login-logo {
    text-align: center;
    margin-bottom: 30px;
}

.login-logo h1 {
    font-size: 28px;
    color: #1e2a3b;
}

.login-logo span {
    color: var(--primary-color);
}

.login-title {
    text-align: center;
    margin-bottom: 30px;
    color: #666;
}

/* Responsive */
@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .sidebar-toggle {
        display: block;
    }
}

@media (max-width: 576px) {
    .content-area {
        padding: 15px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .table-responsive {
        overflow-x: auto;
    }
}

/* Full-width admin forms */
.content-area > .card,
.content-area .admin-form-card,
.content-area .card[style*="max-width"] {
    max-width: none !important;
    width: 100%;
}

.page-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.page-heading {
    font-size: 24px;
    font-weight: 700;
    color: #1e2a3b;
    margin: 0 0 6px;
}

.page-subheading {
    color: var(--text-muted);
    margin: 0;
    font-size: 14px;
}

.page-toolbar-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.dashboard-section {
    margin-bottom: 24px;
}

.table-full {
    width: 100%;
}

.text-end {
    text-align: right;
}

.justify-end {
    justify-content: flex-end;
}

.empty-state {
    text-align: center;
    padding: 40px;
    color: #888;
}

.cms-form .form-row {
    display: grid;
    gap: 20px;
    margin-bottom: 4px;
}

.cms-form .form-row-2 {
    grid-template-columns: repeat(2, 1fr);
}

.cms-form .form-row-3 {
    grid-template-columns: repeat(3, 1fr);
}

.cms-form .cms-editor {
    min-height: 140px;
}

.cms-form .required {
    color: #dc3545;
}

.cms-form .form-hint {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    color: #888;
}

.input-group-url {
    display: flex;
    align-items: stretch;
}

.input-prefix {
    display: flex;
    align-items: center;
    padding: 0 12px;
    background: #f0f2f5;
    border: 1px solid #ddd;
    border-right: 0;
    border-radius: 4px 0 0 4px;
    color: #666;
    font-size: 14px;
    white-space: nowrap;
}

.input-group-url .form-control {
    border-radius: 0 4px 4px 0;
}

.cms-preview-image {
    max-width: 200px;
    margin-top: 10px;
    border-radius: 6px;
    display: block;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

.form-group-inline {
    display: flex;
    align-items: flex-end;
    padding-bottom: 8px;
}

.permission-group {
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid #eee;
}

.permission-group:last-child {
    border-bottom: 0;
    margin-bottom: 0;
}

.permission-group-title {
    font-size: 14px;
    font-weight: 600;
    color: #1e2a3b;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.permission-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 10px;
}

.permission-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    cursor: pointer;
    padding: 8px 10px;
    border-radius: 4px;
    background: #f8f9fa;
}

.permission-item:hover {
    background: #eef1f5;
}

.cms-table a {
    color: #2575fc;
    word-break: break-all;
}

@media (max-width: 992px) {
    .cms-form .form-row-2,
    .cms-form .form-row-3,
    .admin-form .form-row-2,
    .admin-form .form-row-3 {
        grid-template-columns: 1fr;
    }

    .admin-form-grid {
        grid-template-columns: 1fr;
    }
}

/* ========== Admin form pages (add/edit) ========== */
.main-content:has(.admin-form-page) .top-bar .page-title {
    display: none;
}

.admin-form-page {
    width: 100%;
}

.form-page-header {
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid #e8ecf1;
}

.form-back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    text-decoration: none;
    margin-bottom: 10px;
    transition: color 0.2s ease;
}

.form-back-link:hover {
    color: var(--primary-color);
}

.form-page-title {
    font-size: 26px;
    font-weight: 700;
    color: #1e2a3b;
    margin: 0 0 6px;
}

.form-page-subtitle {
    margin: 0;
    font-size: 14px;
    color: var(--text-muted);
}

.admin-form-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 24px;
    align-items: start;
}

.admin-form-main,
.admin-form-sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-panel {
    background: var(--card-bg);
    border-radius: 10px;
    box-shadow: 0 2px 12px rgba(30, 42, 59, 0.06);
    border: 1px solid #e8ecf1;
    overflow: hidden;
}

.form-panel__head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 22px;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f4f9 100%);
    border-bottom: 1px solid #e8ecf1;
}

.form-panel__head i {
    font-size: 18px;
    color: var(--primary-color);
}

.form-panel__head h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: #1e2a3b;
}

.form-panel__body {
    padding: 22px;
}

.admin-form .form-row {
    display: grid;
    gap: 18px;
    margin-bottom: 0;
}

.admin-form .form-row-2 {
    grid-template-columns: repeat(2, 1fr);
}

.admin-form .form-row-3 {
    grid-template-columns: repeat(3, 1fr);
}

.admin-form .form-group {
    margin-bottom: 18px;
}

.admin-form .form-group:last-child {
    margin-bottom: 0;
}

.admin-form .form-label {
    font-size: 13px;
    font-weight: 600;
    color: #3a4a5f;
    margin-bottom: 8px;
}

.admin-form .form-control {
    border-radius: 6px;
    border-color: #d8dee8;
    padding: 11px 14px;
}

.admin-form .form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(245, 104, 61, 0.12);
}

.form-actions-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 28px;
    padding: 20px 24px;
    background: var(--card-bg);
    border-radius: 10px;
    border: 1px solid #e8ecf1;
    box-shadow: 0 2px 12px rgba(30, 42, 59, 0.06);
}

.btn-lg {
    padding: 12px 28px;
    font-size: 15px;
}

.toggle-field {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    color: #1e2a3b;
    cursor: pointer;
}

.toggle-field input {
    width: 18px;
    height: 18px;
    accent-color: var(--primary-color);
}

.image-preview-box {
    margin-bottom: 14px;
    padding: 12px;
    background: #f8f9fb;
    border-radius: 8px;
    border: 1px dashed #d8dee8;
    text-align: center;
}

.image-preview-box img {
    max-width: 100%;
    max-height: 180px;
    border-radius: 6px;
    object-fit: contain;
}

.editor-field {
    position: relative;
}

.editor-field .cke {
    width: 100% !important;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #d8dee8 !important;
    box-shadow: none !important;
}

.editor-field .cke_top {
    background: #f8f9fb !important;
    border-bottom: 1px solid #d8dee8 !important;
}

.editor-field .cke_bottom {
    background: #f8f9fb !important;
    border-top: 1px solid #d8dee8 !important;
}

.editor-field .cke_contents {
    min-height: 220px;
}

.editor-field .cke_editable {
    min-height: 220px !important;
    max-height: 500px;
    padding: 14px 16px !important;
}

/* Pricing plan feature rows */
.pricing-features-editor__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.pricing-features-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.pricing-feature-row {
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: #f8fafc;
    border: 1px solid #e4e8ef;
    border-radius: 8px;
}

.pricing-feature-row__drag {
    color: #9ca3af;
    font-size: 18px;
}

.pricing-feature-row__included {
    margin: 0;
    white-space: nowrap;
}

.pricing-feature-row__remove {
    padding: 6px 10px;
}

/* Legacy single-card entity forms */
.admin-form-page .admin-form-card {
    border: 1px solid #e8ecf1;
    border-radius: 10px;
    box-shadow: 0 2px 12px rgba(30, 42, 59, 0.06);
}

.admin-form-page .admin-form-card .card-header {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f4f9 100%);
}

.admin-form-page .admin-form-card .card-body {
    padding: 28px;
}

.admin-form-page .admin-form-card .form-group {
    margin-bottom: 20px;
}

.admin-form-page .admin-form-card .form-actions-inline {
    display: flex;
    gap: 12px;
    margin-top: 28px;
    padding-top: 22px;
    border-top: 1px solid #e8ecf1;
}

.admin-form .code-field {
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 13px;
    background: #f8f9fb;
    min-height: 160px;
}

.field-error {
    color: #dc3545;
    font-size: 13px;
    display: block;
    margin-top: 4px;
}

/* ========== Site Visitors ========== */
.visitors-page .visitors-stats {
    margin-bottom: 24px;
}

.visitors-table-card .card-header {
    flex-wrap: wrap;
    gap: 10px;
}

.visitors-count {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
}

.visitors-table th {
    white-space: nowrap;
}

.visitors-table tbody tr:hover {
    background: #f8fafc;
}

.visitor-ip strong {
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 13px;
    color: #1e2a3b;
}

.visitor-agent {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.agent-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    background: #eef2ff;
    color: #4230d3;
}

.agent-chip--muted {
    background: #f0f2f5;
    color: #5a6a7e;
}

.visitor-location {
    font-size: 14px;
    color: #5a6a7e;
}

.visitor-date {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #1e2a3b;
}

.visitor-time {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.views-badge {
    min-width: 32px;
    font-size: 13px;
    padding: 5px 10px;
}

.pagination-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid #e8ecf1;
}

.pagination-info {
    font-size: 14px;
    color: #5a6a7e;
}

.pagination-bar .btn.disabled {
    opacity: 0.45;
    pointer-events: none;
}

/* Visitor detail */
.visitors-detail-page .visitor-info-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.info-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.info-row--full {
    padding-top: 8px;
    border-top: 1px dashed #e8ecf1;
}

.info-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    font-weight: 600;
}

.info-value {
    font-size: 14px;
    color: #1e2a3b;
}

.ua-code {
    display: block;
    font-size: 11px;
    line-height: 1.5;
    padding: 10px;
    background: #f8f9fb;
    border-radius: 6px;
    border: 1px solid #e8ecf1;
    word-break: break-all;
    color: #5a6a7e;
}

.visit-url {
    color: #2575fc;
    font-size: 13px;
    word-break: break-all;
}

.visit-url:hover {
    text-decoration: underline;
}

.visit-referrer {
    display: block;
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
    color: #5a6a7e;
}

.text-muted {
    color: #999;
    font-size: 13px;
}

@media (max-width: 992px) {
    .visitors-detail-page .admin-form-grid {
        grid-template-columns: 1fr !important;
    }

    .visitor-agent {
        flex-direction: column;
        align-items: flex-start;
    }
}
