/* root variables for easy customization */
:root {
    --bg-dark: #0b0f1a;
    --sidebar-bg: #161b2a;
    --card-bg: #1e293b;
    --text-main: #f8fafc;
    --text-dim: #94a3b8;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --danger: #ef4444;
    --success: #10b981;
    --border: #334155;
    --sidebar-width: 260px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    display: flex; /* Sidebar + Main Content */
    height: 100vh;
    overflow: hidden;
}

/* --- SIDEBAR --- */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 20px 0;
}

.profile {
    padding: 0 20px 30px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar {
    width: 32px;
    height: 32px;
    background: var(--accent);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
}

.menu-group {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-dim);
    margin: 20px 20px 10px;
    letter-spacing: 1px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    text-decoration: none;
    color: var(--text-dim);
    font-size: 14px;
    transition: all 0.2s ease;
}

.nav-link i {
    width: 18px;
    text-align: center;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

.nav-link.active {
    background: rgba(59, 130, 246, 0.15);
    color: var(--accent);
    border-right: 3px solid var(--accent);
}

/* --- MAIN CONTENT --- */
.content-area {
    flex: 1;
    padding: 40px;
    overflow-y: auto;
}

h1 {
    font-size: 28px;
    margin-bottom: 30px;
    font-weight: 700;
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- CARDS & GRID --- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--card-bg);
    padding: 24px;
    border-radius: 12px;
    border: 1px solid var(--border);
    transition: transform 0.2s;
}

.stat-card:hover {
    transform: translateY(-4px);
    border-color: var(--accent);
}

.stat-card h3 {
    color: var(--text-dim);
    font-size: 14px;
    margin-bottom: 10px;
}

.stat-card span {
    font-size: 24px;
    font-weight: bold;
    display: block;
}

/* --- FOCUS MODE UI --- */
.pomodoro-container {
    max-width: 400px;
    margin: 50px auto;
    text-align: center;
    background: var(--card-bg);
    padding: 40px;
    border-radius: 20px;
    border: 1px solid var(--border);
}

#timer-display {
    font-size: 80px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    margin-bottom: 30px;
    color: var(--text-main);
}

button {
    background: var(--accent);
    color: white;
    border: none;
    padding: 14px 28px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    font-size: 16px;
    transition: background 0.2s;
}

button:hover {
    background: var(--accent-hover);
}

#start-btn.pause {
    background: var(--danger);
}

/* --- RESPONSIVENESS --- */
@media (max-width: 768px) {
    body {
        flex-direction: column;
    }
    .sidebar {
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
}

/* Progress Bar Animation */
.progress-bar {
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}


.stat-card p {
    line-height: 1.5;
}


/* Kanban Board Layout */
.kanban-board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    height: 70vh;
}

.kanban-column {
    background: rgba(15, 23, 42, 0.5);
    border-radius: 12px;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 15px;
}

.column-header {
    font-size: 12px;
    font-weight: 800;
    color: var(--text-dim);
    margin-bottom: 15px;
    letter-spacing: 1px;
    text-align: center;
}

.task-list {
    flex-grow: 1;
    min-height: 100px;
}

.task-item {
    background: var(--card-bg);
    padding: 15px;
    border-radius: 8px;
    border: 1px solid var(--border);
    margin-bottom: 10px;
    cursor: grab;
    transition: box-shadow 0.2s;
}

.task-item:active { cursor: grabbing; }
.task-item.dragging { opacity: 0.5; border: 1px dashed var(--accent); }

.tag {
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    font-weight: bold;
    display: inline-block;
    margin-bottom: 8px;
}
.tag-study { background: #8b5cf6; color: white; }
.tag-work { background: #3b82f6; color: white; }


/* Vault Status Tags */
.status-expired { background: var(--danger); color: white; }
.status-warning { background: #f59e0b; color: white; } /* Orange */
.status-valid { background: var(--success); color: white; }

.stat-card .tag {
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 10px;
}

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: none; /* Hidden by default */
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-card {
    background: var(--card-bg);
    padding: 30px;
    border-radius: 12px;
    width: 400px;
    border: 1px solid var(--border);
}

.modal-card h2 { margin-bottom: 20px; font-size: 20px; }

.modal-card label { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 5px; }

.modal-card input, .modal-card select {
    width: 100%;
    padding: 10px;
    margin-bottom: 15px;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    color: white;
    border-radius: 6px;
}

.modal-btns { display: flex; gap: 10px; margin-top: 10px; }
.btn-secondary { background: #334155; flex: 1; }
.btn-primary { background: var(--accent); flex: 1; }


.report-paper {
    background: linear-gradient(145deg, #1e293b, #0f172a);
    padding: 40px;
    border-radius: 15px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    max-width: 800px;
    margin: 0 auto;
}

.report-header {
    border-bottom: 2px solid var(--accent);
    padding-bottom: 20px;
    margin-bottom: 30px;
}

#urgent-docs-list {
    list-style: none;
    padding: 0;
}

#urgent-docs-list li {
    padding: 5px 0;
}


/*********************financial****************************/
.excel-grid {
    width: 100%;
    border-collapse: collapse;
    background: var(--card-bg);
    border: 1px solid var(--border);
    font-size: 14px;
}

.excel-grid th {
    background: #0f172a;
    padding: 12px;
    color: var(--text-dim);
    text-align: left;
    border-bottom: 2px solid var(--border);
}

.excel-grid td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text-main);
}

.excel-grid tr:hover { background: rgba(255, 255, 255, 0.03); }

/* ألوان الحالة مثل الإكسيل */
.status-ok { color: var(--success); font-weight: bold; }
.status-over { color: var(--danger); font-weight: bold; }

.total-row {
    background: #1e293b;
    font-weight: bold;
    color: var(--accent);
}

.inline-form {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.inline-form input, .inline-form select {
    flex: 1;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    color: white;
    padding: 8px;
    border-radius: 6px;
}


/***************************vault*******************************************/
/* Ensure the grid can hold the cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
}

/* Card Styling */
.stat-card {
    background: var(--sidebar-bg);
    border: 1px solid var(--border);
    padding: 20px;
    border-radius: 12px;
}

/* Status Tags */
.tag {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: bold;
}
.status-valid { background: rgba(34, 197, 94, 0.2); color: #22c55e; }
.status-warning { background: rgba(245, 158, 11, 0.2); color: #f59e0b; }
.status-expired { background: rgba(239, 68, 68, 0.2); color: #ef4444; }

/********************************dashboard alarm*********************************/
/* تأثير النبض للإطار الأحمر */
@keyframes pulse-border {
    0% { border-color: #ef4444; box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    70% { border-color: #ef4444; box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
    100% { border-color: #ef4444; box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* حركة جرس الإنذار */
@keyframes ring {
    0% { transform: rotate(0); }
    10% { transform: rotate(15deg); }
    20% { transform: rotate(-15deg); }
    30% { transform: rotate(15deg); }
    40% { transform: rotate(-15deg); }
    50% { transform: rotate(0); }
    100% { transform: rotate(0); }
}

/* ألوان التاجات الذكية */
.tag-field-op { background: #0ea5e9; color: white; } /* أزرق للعمليات */
.tag-academy { background: #8b5cf6; color: white; } /* بنفسجي للأكاديمية */
.tag-fitness { background: #10b981; color: white; } /* أخضر للرياضة */
.tag-general { background: #64748b; color: white; } /* رمادي للمهام العادية */

.task-item {
    border-left: 4px solid transparent;
    transition: all 0.3s;
}

/* تلوين حافة الكارت بناءً على التاج */
.task-item:has(.tag-field-op) { border-left-color: #0ea5e9; }
.task-item:has(.tag-academy) { border-left-color: #8b5cf6; }
.task-item:has(.tag-fitness) { border-left-color: #10b981; }


/*******************************************************************************/
/* --- RESPONSIVE LAYOUT --- */

/* زر الموبايل - مخفي في الشاشات الكبيرة */
.mobile-toggle {
    display: none;
    position: fixed;
    top: 15px;
    left: 15px;
    z-index: 2000;
    background: var(--accent);
    padding: 10px 15px;
    border-radius: 8px;
}

/* شاشات الموبايل والتابلت (أقل من 1024px) */
@media (max-width: 1024px) {
    body {
        flex-direction: column;
    }

    .mobile-toggle {
        display: block; /* يظهر فقط في الموبايل */
    }

    .sidebar {
        position: fixed;
        left: -100%; /* مخفي خارج الشاشة */
        top: 0;
        bottom: 0;
        z-index: 1500;
        transition: left 0.3s ease;
        box-shadow: 10px 0 30px rgba(0,0,0,0.5);
    }

    .sidebar.open {
        left: 0; /* يظهر عند الضغط على الزر */
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.6);
        z-index: 1400;
        backdrop-filter: blur(3px);
    }

    .sidebar-overlay.active {
        display: block;
    }

    .content-area {
        padding: 80px 20px 20px; /* مسافة عشان زر الموبايل */
    }

    /* ضبط الجريدات لتناسب الشاشة الصغيرة */
    .stats-grid {
        grid-template-columns: 1fr !important; /* كارت واحد في الصف */
    }

    .kanban-board {
        grid-template-columns: 1fr; /* أعمدة الكانبان تحت بعض */
        height: auto;
        gap: 30px;
    }

    .kanban-column {
        min-height: 300px;
    }

    /* تصغير العناوين والجداول */
    h1 { font-size: 22px; }
    
    .table-container {
        font-size: 11px;
    }

    /* تعديل الـ Journal و Financial Layout */
    .grid-layout, #financial section, div[style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
    }
}

nav {
    /* تحديد طول القائمة */
    height: 100vh; 
    
    /* تفعيل التمرير العمودي */
    overflow-y: auto; 
    overflow-x: hidden;
    
    /* لضمان بقاء العناصر الداخلية منظمة */
    display: flex;
    flex-direction: column;
    padding: 20px 0;
    
    /* تحسين شكل الـ Scrollbar في المتصفحات (Chrome, Edge, Safari) */
}

/* تخصيص شكل شريط التمرير */
nav::-webkit-scrollbar {
    width: 5px; /* عرض الشريط */
}

nav::-webkit-scrollbar-track {
    background: transparent; /* خلفية المسار */
}

nav::-webkit-scrollbar-thumb {
    background: #334155; /* لون المقبض */
    border-radius: 10px; /* جعل الحواف دائرية */
}

nav::-webkit-scrollbar-thumb:hover {
    background: #38bdf8; /* يتغير اللون عند تمرير الماوس */
}

/* للمتصفحات الأخرى مثل Firefox */
nav {
    scrollbar-width: thin;
    scrollbar-color: #334155 transparent;
}

#ideas-grid div:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.2);
    border-color: #fbbf24 !important;
}

#ideas-grid .sticky-note-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

#ideas-grid .sticky-note-card:hover {
    transform: translateY(-8px) rotate(1deg); /* Slight lift and rotation */
    box-shadow: 0 15px 30px rgba(0,0,0,0.4); /* Stronger shadow on hover */
    cursor: grab;
}

#ideas-grid .sticky-note-card:active {
    cursor: grabbing;
    transform: translateY(-4px) rotate(0deg);
}

.sticky-note {
    transition: transform 0.2s ease, box-shadow 0.2s ease; /* تنعيم الحركة */
    user-select: none; /* يمنع تحديد النص تماماً أثناء السحب */
}

.sticky-note:active {
    transition: none; /* نلغي التنعيم أثناء السحب الفعلي عشان ما يبقاش فيه تأخير (Lag) */
}

#mindmap-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; /* Allows you to click the nodes through the canvas */
    z-index: 5; /* Sit behind the nodes but above the background */
}

#mindmap-board {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10; /* Sit above the canvas */
}


/**************************************************/
/* تخصيص السكرول بار العام للمتصفح أو لأي عنصر */
::-webkit-scrollbar {
    width: 8px;  /* عرض السكرول الرأسي */
    height: 8px; /* ارتفاع السكرول الأفقي */
}

/* الخلفية (المسار) */
::-webkit-scrollbar-track {
    background: #0b0f1a; 
    border-radius: 10px;
}

/* المقبض (الجزء الذي يتحرك) */
::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #6366f1, #4f46e5); /* تدرج لوني إنديغو */
    border-radius: 10px;
    border: 2px solid #0b0f1a; /* يعطي إيحاء بوجود مسافة حول المقبض */
}

/* تأثير عند تمرير الماوس فوق السكرول */
::-webkit-scrollbar-thumb:hover {
    background: #818cf8; 
}

/* تحسين شكل السكرول داخل قسم الـ MindMap تحديداً */
#mindmap {
    scrollbar-width: thin; /* لمتصفح فايرفوكس */
    scrollbar-color: #6366f1 #0b0f1a; /* لمتصفح فايرفوكس */
}

#mindmap-container {
    scroll-behavior: smooth;
    /* لمنع ظهور السكرول بار تماماً إذا كنت تعتمد على السحب بالماوس (Panning) */
    scrollbar-width: none; 
    -ms-overflow-style: none;
}
#mindmap-container::-webkit-scrollbar {
    display: none; /* إخفاء السكرول في منطقة العمل لزيادة التركيز */
}

/************************Study****************************/

/* تصميم الكتاب */
.book-container {
    perspective: 1500px;
    display: none; /* يظهر فقط عند الضغط على الدرس */
    justify-content: center;
    margin: 40px 0;
}

.book {
    width: 350px;
    height: 450px;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.5s;
    cursor: pointer;
}

.book.open {
    transform: rotateY(-20deg);
}

.page {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    background: #fdf6e3; /* لون ورقي */
    color: #2d3436;
    padding: 20px;
    box-shadow: inset 3px 0px 10px rgba(0,0,0,0.1);
    border-radius: 0 5px 5px 0;
    display: flex;
    flex-direction: column;
}

.book-cover {
    background: #1e293b;
    color: #38bdf8;
    z-index: 10;
    transform-origin: left;
    transition: transform 0.5s;
    border: 2px solid #334155;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-weight: bold;
}

.book.open .book-cover {
    transform: rotateY(-160deg);
}

/* أدوات التحرير داخل الكتاب */
.note-editor {
    flex: 1;
    border: none;
    background: transparent;
    resize: none;
    outline: none;
    font-family: 'Courier New', Courier, monospace;
    line-height: 1.5;
    font-size: 15px;
}

.highlight {
    background: #fef08a; /* لون تمييز أصفر */
}

.book-controls {
    margin-top: 10px;
    display: flex;
    justify-content: space-between;
}

/* تحسين شكل صفحة الكتابة */
.note-editor-paper {
    flex: 1;
    border: none;
    background: transparent;
    outline: none;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    font-size: 16px;
    overflow-y: auto;
    padding: 10px;
    border-left: 1px solid #e5e7eb; /* خط الهامش */
    min-height: 300px;
}

/* نمط التظليل (Highlight) */
.hl-yellow { background-color: #fef08a; padding: 2px 4px; border-radius: 3px; }
.hl-green { background-color: #bbf7d0; padding: 2px 4px; border-radius: 3px; }

/* حركة تقليب الصفحة */
.page-flip {
    animation: flipAnim 0.6s ease-in-out;
}

@keyframes flipAnim {
    0% { transform: rotateY(0deg); }
    100% { transform: rotateY(-180deg); opacity: 0; }
}

/* Container for the book */
.book-container {
    display: none; /* JS will change this to flex */
    width: 100%;
    min-height: 600px; /* Crucial: gives the book space to exist */
    justify-content: center;
    align-items: center;
    perspective: 2000px;
    margin-top: 50px;
    padding: 40px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 20px;
}

.book {
    width: 350px;
    height: 500px;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.page {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    border-radius: 0 10px 10px 0;
    transform-origin: left;
    transition: transform 0.8s;
    box-shadow: 10px 10px 30px rgba(0,0,0,0.5);
}

.book-cover {
    background: #1e293b !important;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #334155;
    backface-visibility: hidden;
}

/* Opening effect */
.book.open .book-cover {
    transform: rotateY(-165deg);
}

.content-page {
    background: #fdf6e3;
    z-index: 1;
    padding: 30px;
    color: #1e293b;
    overflow: hidden;
}

.note-editor-paper {
    flex: 1;
    outline: none;
    font-family: 'Georgia', serif;
    font-size: 16px;
    line-height: 1.8;
    background-image: linear-gradient(#d1d5db 1px, transparent 1px);
    background-size: 100% 1.8em;
    padding: 10px;
    color: #334155;
}
