/* RTL Layout */
* {
    direction: rtl;
    text-align: right;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Arial, sans-serif;
    background-color: #f5f5f5;
}

/* Page Layout */
.page {
    display: flex;
    height: 100vh;
    background: #0a0a0a;
    position: relative;
    z-index: 1;
}

.mobile-topbar {
    display: none;
}

.sidebar-overlay {
    display: none;
}

/* Sidebar - Left/* Sidebar - Matrix Style */
.sidebar {
    width: 260px;
    background: linear-gradient(180deg, #1a0000 0%, #000000 100%);
    color: #E31937;
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 20px rgba(227, 25, 55, 0.5);
    position: relative;
    z-index: 100;
    border-left: 2px solid #E31937;
}

.sidebar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(227, 25, 55, 0.03) 2px,
        rgba(227, 25, 55, 0.03) 4px
    );
    pointer-events: none;
}

.sidebar-header {
    padding: 20px;
    background-color: #1a252f;
    border-bottom: 1px solid #34495e;
}

.sidebar-header h3 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 600;
}

.sidebar-nav {
    flex: 1;
    padding: 10px 0;
}

.nav-section {
    margin-bottom: 20px;
}

.nav-section-title {
    padding: 10px 20px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #95a5a6;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.menu {
    flex: 1;
    overflow-y: auto;
    padding: 15px 0;
}

.menu-item {
    display: flex;
    align-items: center;
    padding: 14px 20px;
    color: #E31937;
    text-decoration: none;
    transition: all 0.3s ease;
    border-right: 3px solid transparent;
    font-size: 15px;
    font-family: 'Courier New', monospace;
    position: relative;
}

.menu-item::before {
    content: '>';
    margin-left: 10px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.menu-item:hover {
    background: rgba(227, 25, 55, 0.2);
    border-right-color: #E31937;
    padding-right: 25px;
    text-shadow: 0 0 10px rgba(227, 25, 55, 0.8);
}

.menu-item:hover::before {
    opacity: 1;
}

.menu-item.active {
    background: rgba(227, 25, 55, 0.3);
    border-right-color: #E31937;
    font-weight: 600;
    box-shadow: inset 0 0 10px rgba(227, 25, 55, 0.5);
}

.menu-item.active::before {
    opacity: 1;
}

.nav-link-child {
    padding-right: 35px;
    font-size: 0.95rem;
}

.nav-link {
    display: block;
    padding: 10px 20px;
    color: #ecf0f1;
    text-decoration: none;
    transition: background-color 0.2s;
}

.nav-link:hover {
    background-color: #34495e;
    color: white;
}

.nav-link.active {
    background-color: #34495e;
    color: white;
    font-weight: 600;
}

.sidebar-footer {
    padding: 15px 20px;
    border-top: 1px solid #34495e;
    background-color: #1a252f;
}

.user-info {
    font-size: 0.9rem;
}

.user-info button {
    margin-top: 8px;
    padding: 0;
    color: #3498db;
    text-decoration: none;
}

.user-info button:hover {
    text-decoration: underline;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 280px;
    overflow-y: auto;
}

.content-wrapper {
    padding: 30px;
    max-width: 1200px;
}

/* Cards & Panels */
.card {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

.card-header {
    padding: 15px 20px;
    border-bottom: 1px solid #e0e0e0;
    font-weight: 600;
    font-size: 1.1rem;
}

.card-body {
    padding: 20px;
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
}

th {
    background-color: #f8f9fa;
    padding: 12px;
    text-align: right;
    font-weight: 600;
    border-bottom: 2px solid #dee2e6;
}

td {
    padding: 12px;
    border-bottom: 1px solid #dee2e6;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
textarea,
select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 1rem;
}

textarea {
    min-height: 150px;
    font-family: inherit;
}

.markdown-editor {
    min-height: 400px;
    font-family: 'Courier New', monospace;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.2s;
}

.btn-primary {
    background-color: #3498db;
    color: white;
}

.btn-primary:hover {
    background-color: #2980b9;
}

.btn-success {
    background-color: #27ae60;
    color: white;
}

.btn-success:hover {
    background-color: #229954;
}

.btn-danger {
    background-color: #e74c3c;
    color: white;
}

.btn-danger:hover {
    background-color: #c0392b;
}

.btn-secondary {
    background-color: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background-color: #7f8c8d;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 0.875rem;
}

.btn-link {
    background: none;
    color: #3498db;
    padding: 0;
}

.btn-link:hover {
    text-decoration: underline;
}

/* Alerts */
.alert {
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 4px;
}

.alert-success {
    background-color: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}

.alert-danger {
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

.alert-info {
    background-color: #d1ecf1;
    border: 1px solid #bee5eb;
    color: #0c5460;
}

/* Login Page */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-card {
    background: white;
    padding: 40px;
    border-radius: 10px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    width: 100%;
    max-width: 400px;
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header h2 {
    margin: 0;
    color: #2c3e50;
}

/* Search */
.search-box {
    margin-bottom: 30px;
}

.search-input {
    padding: 12px;
    font-size: 1.1rem;
}

.search-results {
    list-style: none;
    padding: 0;
    margin: 0;
}

.search-result-item {
    padding: 15px;
    border-bottom: 1px solid #e0e0e0;
}

.search-result-item a {
    color: #2c3e50;
    text-decoration: none;
    font-weight: 600;
}

.search-result-item a:hover {
    color: #3498db;
}

.search-result-snippet {
    margin-top: 5px;
    color: #7f8c8d;
    font-size: 0.9rem;
}

/* Content Display */
.page-content {
    line-height: 1.8;
}

.page-content.ql-editor {
    padding: 0;
    overflow: visible;
}

.page-content h1,
.page-content h2,
.page-content h3 {
    margin-top: 30px;
    margin-bottom: 15px;
    color: #2c3e50;
}

.page-content img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    margin: 20px 0;
}

.page-content ul,
.page-content ol {
    margin: 15px 0;
    padding-right: 20px;
}

.page-content pre {
    background-color: #f8f9fa;
    padding: 15px;
    border-radius: 4px;
    overflow-x: auto;
}

.page-content code {
    background-color: #f8f9fa;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
}

/* Quill Editor Styling */
.ql-container {
    font-family: 'Segoe UI', Tahoma, Arial, sans-serif;
    font-size: 1rem;
}

.ql-editor {
    min-height: 400px;
    direction: rtl;
    text-align: right;
}

.ql-editor p,
.ql-editor ol,
.ql-editor ul {
    direction: rtl;
    text-align: right;
    unicode-bidi: plaintext;
}

.ql-editor p {
    unicode-bidi: plaintext;
}

.ql-editor img {
    cursor: pointer;
    max-width: 100%;
    height: auto;
}

.ql-editor img:hover {
    outline: 1px dashed #0066cc;
}

/* Responsive */
@media (max-width: 768px) {
    .page {
        height: auto;
        min-height: 100vh;
    }

    .mobile-topbar {
        display: flex;
        align-items: center;
        gap: 12px;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: 56px;
        padding: 0 12px;
        background-color: #1a252f;
        color: white;
        z-index: 1100;
        border-bottom: 1px solid #34495e;
    }

    .mobile-menu-button {
        background: none;
        border: none;
        color: white;
        font-size: 1.5rem;
        line-height: 1;
        padding: 8px 10px;
    }

    .mobile-title {
        font-size: 1rem;
        font-weight: 600;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .sidebar {
        width: 85vw;
        max-width: 320px;
        transform: translateX(-110%);
        transition: transform 0.2s ease;
        z-index: 1200;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .mobile-close-button {
        background: none;
        border: none;
        color: white;
        font-size: 1.6rem;
        line-height: 1;
        padding: 0 6px;
        margin-right: auto;
    }

    .sidebar-overlay {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.45);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.2s ease;
        z-index: 1150;
    }

    .sidebar-overlay.open {
        opacity: 1;
        pointer-events: auto;
    }

    .main-content {
        margin-left: 0;
        padding-top: 56px;
    }

    .content-wrapper {
        padding: 16px;
        max-width: 100%;
    }

    table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}
