:root {
    --primary-color: #3b82f6;
    --bg-color: #ffffff;
    --text-color: #1f2937;
    --border-color: #e5e7eb;
    --hover-bg: #f3f4f6;
    --selected-bg: #dbeafe;
    --icon-color: #6b7280;
    --sidebar-bg: #f9fafb;
    --sidebar-text: #374151;
    --modal-bg: rgba(0, 0, 0, 0.5);
    --folder-color: #f59e0b;
    --success-color: #10b981;
    --error-color: #ef4444;
}

[data-theme="dark"] {
    --primary-color: #60a5fa;
    --bg-color: #111827;
    --text-color: #f9fafb;
    --border-color: #374151;
    --hover-bg: #1f2937;
    --selected-bg: #1e3a8a;
    --icon-color: #9ca3af;
    --sidebar-bg: #1f2937;
    --sidebar-text: #f3f4f6;
    --folder-color: #fbbf24;
    --success-color: #34d399;
    --error-color: #f87171;
}

/* ========== ANIMATIONS ========== */

/* Fade In Animation */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Slide In from Right */
@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Slide In from Bottom */
@keyframes slideInBottom {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Scale In */
@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Pulse */
@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }
}

/* Shake */
@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    10%,
    30%,
    50%,
    70%,
    90% {
        transform: translateX(-5px);
    }

    20%,
    40%,
    60%,
    80% {
        transform: translateX(5px);
    }
}

/* Ripple Effect */
@keyframes ripple {
    0% {
        transform: scale(0);
        opacity: 1;
    }

    100% {
        transform: scale(4);
        opacity: 0;
    }
}

/* ========== END ANIMATIONS ========== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

body {
    font-family: 'Cairo', 'Tajawal', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    height: 100vh;
    overflow: hidden;
    direction: rtl;
}

/* Sidebar */
.sidebar {
    width: 250px;
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 20px;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 30px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-item {
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-color);
    transition: background 0.2s;
}

.nav-item:hover {
    background-color: var(--hover-bg);
}

.nav-item.active {
    background-color: var(--selected-bg);
    color: var(--primary-color);
    font-weight: 600;
}

/* Bookmarks */
.sidebar-section {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.section-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--icon-color);
    margin-bottom: 10px;
    padding: 0 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.bookmarks-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.bookmark-item {
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-color);
    font-size: 0.9rem;
    transition: background 0.2s;
}

.bookmark-item:hover {
    background-color: var(--hover-bg);
}

.bookmark-item i {
    font-size: 0.85rem;
    color: var(--icon-color);
}

.bookmark-remove {
    margin-left: auto;
    opacity: 0;
    transition: opacity 0.2s;
    padding: 2px 6px;
    border-radius: 3px;
}

.bookmark-item:hover .bookmark-remove {
    opacity: 1;
}

.bookmark-remove:hover {
    background-color: var(--border-color);
    color: #dc3545;
}

.bookmarks-empty {
    padding: 10px;
    font-size: 0.85rem;
    color: var(--icon-color);
    text-align: center;
    font-style: italic;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 20px;
    overflow: hidden;
}

/* Header */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

.search-bar.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px;
    font-size: 20px;
    font-weight: 600;
    color: var(--text-color);
    border-bottom: 1px solid var(--border-color);
    transition: all 0.2s;
}

.logo:hover {
    background-color: var(--hover-bg);
    transform: translateX(3px);
}

.search-bar {
    display: flex;
    align-items: center;
    background: var(--sidebar-bg);
    padding: 8px 15px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    width: 300px;
}

.search-bar input {
    border: none;
    background: transparent;
    outline: none;
    margin-left: 10px;
    color: var(--text-color);
    width: 100%;
}

.actions {
    display: flex;
    gap: 10px;
}

button {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    background-color: var(--primary-color);
    color: white;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    position: relative;
    overflow: hidden;
}

button::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

button:active::before {
    width: 300px;
    height: 300px;
}

button:hover {
    background-color: #357abd;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.3);
}

button:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(74, 144, 226, 0.2);
}

.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: 0.2s;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-outline {
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-color);
}

.btn:hover {
    opacity: 0.9;
}

select.btn {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 28px;
}

[data-theme="dark"] select.btn {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23e0e0e0' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
}

/* Breadcrumbs */
.breadcrumbs {
    display: flex;
    gap: 5px;
    margin-bottom: 15px;
    font-size: 0.9rem;
    color: var(--icon-color);
    align-items: center;
}

.breadcrumb-item {
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
}

.breadcrumb-item:hover {
    background-color: var(--hover-bg);
    color: var(--text-color);
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* File View */
.file-area {
    flex: 1;
    overflow-y: auto;
}

/* Grid View */
.grid-view {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 15px;
}

.file-item {
    background-color: var(--sidebar-bg);
    border-radius: 8px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    gap: 8px;
    position: relative;
    animation: fadeIn 0.3s ease-out;
    animation-fill-mode: both;
    user-select: none;
}

.file-item:hover {
    background-color: var(--hover-bg);
}

.file-item.selected {
    background-color: var(--selected-bg);
    border-color: var(--primary-color);
}

.file-icon {
    font-size: 3rem;
    margin-bottom: 10px;
    color: var(--icon-color);
}

.file-icon.folder {
    color: var(--folder-color);
}

.file-name {
    font-size: 0.85rem;
    word-break: break-all;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* List View */
.list-view {
    display: flex;
    flex-direction: column;
}

.list-view .file-item {
    flex-direction: row;
    padding: 10px;
    gap: 15px;
    align-items: center;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    border-radius: 0;
    margin-bottom: 0;
}

.list-view .file-icon {
    font-size: 1.5rem;
    margin-bottom: 0;
}

.list-view .file-name {
    flex: 1;
    font-size: 0.9rem;
}

.file-meta {
    font-size: 0.8rem;
    color: var(--icon-color);
    width: 150px;
    text-align: right;
}

/* Context Menu */
.context-menu {
    position: absolute;
    background: var(--sidebar-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: none;
    flex-direction: column;
    min-width: 180px;
    z-index: 1000;
    padding: 5px 0;
    animation: fadeIn 0.1s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.menu-item {
    padding: 8px 16px;
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-color);
}

.menu-item:hover {
    background-color: var(--hover-bg);
    color: var(--primary-color);
}

.menu-item.delete:hover {
    color: #dc3545;
    background-color: #fee2e2;
}

.menu-divider {
    height: 1px;
    background-color: var(--border-color);
    margin: 4px 0;
}

/* Modal Properties */
.prop-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 0.9rem;
}

.prop-label {
    color: var(--icon-color);
    font-weight: 500;
}

.prop-value {
    font-weight: 600;
}

/* Preview Modal */
.preview-modal {
    background: var(--sidebar-bg);
    border-radius: 12px;
    width: 90vw;
    max-width: 1200px;
    height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
}

.preview-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-color);
    padding: 5px 10px;
    border-radius: 4px;
}

.preview-close:hover {
    background: var(--hover-bg);
}

.preview-body {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
    padding: 20px;
    background: var(--bg-color);
}

.preview-body img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
}

.preview-body video {
    max-width: 100%;
    max-height: 100%;
    border-radius: 8px;
}

.preview-body iframe {
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 8px;
}

.preview-nav {
    display: flex;
    justify-content: space-between;
    padding: 15px 20px;
    border-top: 1px solid var(--border-color);
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--modal-bg);
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease-out;
}

.modal-content {
    background-color: var(--bg-color);
    padding: 25px;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    animation: scaleIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-header {
    font-size: 1.2rem;
    margin-bottom: 15px;
    font-weight: 600;
}

.modal-body input {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-color);
    color: var(--text-color);
    margin-bottom: 20px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Upload Progress */
.upload-progress {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--sidebar-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 15px 20px;
    min-width: 300px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 2000;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.progress-bar-container {
    height: 6px;
    background: var(--border-color);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--primary-color);
    transition: width 0.3s ease;
    border-radius: 3px;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: var(--sidebar-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 20px;
    border-radius: 8px;
    margin-bottom: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 250px;
    animation: slideInRight 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast.success {
    border-left: 4px solid #10b981;
}

.toast.error {
    border-left: 4px solid #ef4444;
}

.toast.info {
    border-left: 4px solid var(--primary-color);
}

/* Color Palette */
.color-palette {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
    gap: 12px;
    padding: 10px;
}

.color-option {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.color-option:hover {
    transform: scale(1.1);
    border-color: var(--primary-color);
}

.color-option.reset {
    background: var(--border-color);
    color: var(--text-color);
    font-size: 1.2rem;
}

/* Text Editor Modal */
.modal-large {
    width: 90vw;
    max-width: 1200px;
    height: 85vh;
    padding: 0;
    display: flex;
    flex-direction: column;
}

.modal-large .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    margin: 0;
}

.editor-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1rem;
    font-weight: 600;
}

.editor-header-right {
    display: flex;
    gap: 10px;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.85rem;
}

.editor-body {
    flex: 1;
    padding: 0;
    overflow: hidden;
    margin: 0;
}

.editor-container {
    height: 100%;
    position: relative;
}

#fileEditor {
    width: 100%;
    height: 100%;
    border: none;
    outline: none;
    padding: 20px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.6;
    background: var(--bg-color);
    color: var(--text-color);
    resize: none;
    tab-size: 4;
}

#editorPreview {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 20px;
    overflow: auto;
    background: #1e1e1e;
    border-radius: 0;
}

#editorPreview code {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.6;
}

.markdown-preview {
    width: 100%;
    height: 100%;
    padding: 20px 40px;
    overflow: auto;
    background: var(--bg-color);
    color: var(--text-color);
}

.markdown-preview h1,
.markdown-preview h2,
.markdown-preview h3,
.markdown-preview h4,
.markdown-preview h5,
.markdown-preview h6 {
    margin-top: 24px;
    margin-bottom: 16px;
    font-weight: 600;
    line-height: 1.25;
}

.markdown-preview h1 {
    font-size: 2em;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.3em;
}

.markdown-preview h2 {
    font-size: 1.5em;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.3em;
}

.markdown-preview p {
    margin-bottom: 16px;
    line-height: 1.6;
}

.markdown-preview code {
    background: var(--hover-bg);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.9em;
}

.markdown-preview pre {
    background: var(--hover-bg);
    padding: 16px;
    border-radius: 6px;
    overflow-x: auto;
    margin-bottom: 16px;
}

.markdown-preview pre code {
    background: transparent;
    padding: 0;
}

.markdown-preview ul,
.markdown-preview ol {
    margin-bottom: 16px;
    padding-left: 2em;
}

.markdown-preview li {
    margin-bottom: 4px;
}

.markdown-preview a {
    color: var(--primary-color);
    text-decoration: none;
}

.markdown-preview a:hover {
    text-decoration: underline;
}

.markdown-preview img {
    max-width: 100%;
    border-radius: 6px;
    margin: 16px 0;
}

.markdown-preview blockquote {
    border-left: 4px solid var(--border-color);
    padding-left: 16px;
    margin: 16px 0;
    color: var(--icon-color);
}

.editor-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    border-top: 1px solid var(--border-color);
    background: var(--sidebar-bg);
    margin: 0;
}

.editor-info {
    display: flex;
    gap: 20px;
    font-size: 0.85rem;
    color: var(--icon-color);
}

.editor-hint {
    font-size: 0.85rem;
    color: var(--icon-color);
    display: flex;
    align-items: center;
    gap: 6px;
}