@import url('../vendor/fonts/inter/inter.css');
/*
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');
*/

@media (max-width: 767px) {
  /* Mobile Layout - Full Screen Panes */
  #sidebar-left, #sidebar-middle, #editor-area {
    width: 100% !important;
    height: 100% !important;
    max-width: none !important; /* Override desktop max-width constraints */
    min-width: 0 !important;
  }

  #sidebar-logo {
    justify-content: center !important;
    position: relative !important;
  }

  #sidebar-logo .icon-button {
    position: absolute !important;
    right: 0 !important;
    margin-left: 0 !important;
  }

  /* Better spacing for touch targets in Sidebar Left */
  #sidebar-left { padding: 12px !important; }
  
  /* Relaxed items spacing */
  .tag-item-container, 
  .favorites-item-container { 
    margin: 4px 0 !important; 
    padding: 12px 16px !important; 
    border-radius: 12px !important;
    user-select: none !important;
  }

  .tag-list-item,
  .tag-list-item * {
    user-select: none !important;
    -webkit-user-select: none !important;
    -webkit-touch-callout: none !important;
    -webkit-tap-highlight-color: transparent;
  }
  
  .folder-item-container {
    margin: 4px 0 !important; 
    padding-top: 12px !important;
    padding-bottom: 12px !important;
    padding-right: 16px !important;
    border-radius: 12px !important;
    user-select: none !important;
    /* padding-left is handled by inline style for hierarchy */
  }
  
  /* Larger text */
  .folder-item-container .folder-name,
  .tag-item-container .tag-name,
  .favorites-item-container .favorites-name { font-size: 1.05rem !important; }
  
  /* Larger icons */
  .folder-item-container i, 
  .tag-item-container i,
  .favorites-item-container i { font-size: 1.2rem !important; width: 1.75rem !important; }

  /* Headers */
  h3 { 
    margin-bottom: 8px !important; 
    margin-top: 20px !important; 
    font-size: 0.9rem !important; 
    padding-left: 4px;
  }
  
  /* Header containers */
  #sidebar-left .flex.justify-between.items-center {
    min-height: 40px;
    margin-bottom: 8px;
  }
  
  /* Note List Header - Taller & Airier */
  #sidebar-middle > div:first-child {
    padding-top: 16px !important;
    padding-bottom: 16px !important;
    min-height: 64px !important;
    border-bottom: 1px solid #e2e8f0;
    margin-bottom: 4px;
  }

  #notes-list-title {
    flex: 1 1 auto !important;
    min-width: 0 !important;
  }

  #sidebar-middle > div:first-child .icon-button {
    padding: 12px 14px !important;
    min-width: 44px !important;
  }

  #add-note-btn {
    padding: 12px 14px !important;
    min-width: 44px !important;
  }

  /* Larger Plus buttons */
  #sidebar-left .icon-button {
    padding: 10px !important;
    background-color: #f1f5f9; /* Slight bg for better touch target visibility */
  }
  #sidebar-left .icon-button i {
    font-size: 1.1rem !important; 
  }
  
  /* Notes List padding - Avoid bottom sheet overlap */
  #notes-list { 
    padding: 8px !important; 
    padding-bottom: calc(6rem + env(safe-area-inset-bottom, 0px)) !important;
  }
  .note-list-item { padding: 14px !important; margin-bottom: 8px !important; }
  .note-list-item,
  .note-list-item * {
    user-select: none !important;
    -webkit-user-select: none !important;
    -webkit-touch-callout: none !important;
  }
  .note-list-item h4 { font-size: 1rem !important; margin-bottom: 4px; }

  /* Mobile: keep selection logic, but remove selected visual emphasis. */
  .selected-folder > .folder-item-container,
  .selected-tag > .tag-item-container,
  .selected-favorites > .favorites-item-container {
    background-color: transparent !important;
    border-color: transparent !important;
    box-shadow: none !important;
    color: inherit !important;
    font-weight: inherit !important;
  }

  .selected-folder > .folder-item-container .subtle-icon,
  .selected-tag > .tag-item-container .subtle-icon,
  .selected-favorites > .favorites-item-container .subtle-icon {
    color: #94a3b8 !important;
  }

  .selected-note {
    border-color: transparent !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03) !important;
  }

  .selected-note h4 {
    font-weight: 500 !important;
  }

  .folder-note-item .bg-blue-100,
  .folder-note-item .hover\:bg-blue-100:hover {
    background-color: transparent !important;
  }
  
  /* User Bar */
  #sidebar-user-bar {
    padding-top: 6px !important;
    padding-bottom: calc(0px + env(safe-area-inset-bottom, 0px)) !important;
  }
  #sidebar-user-bar .px-2.py-2 { 
    padding: 10px !important; 
    margin-top: 4px;
    background-color: white;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
  }
  .safe-area-bottom {
    padding-bottom: calc(2px + env(safe-area-inset-bottom, 0px)) !important;
  }

  #editor-back-btn {
    padding: 12px 14px !important;
    min-width: 44px !important;
  }
  
  /* Editor - Mobile Layout Fix */
  #editor-area {
    display: flex;
    flex-direction: column;
    height: 100% !important;
    width: 100% !important;
    overflow: hidden !important;
    position: relative;
  }
  
  #editor-content {
    display: flex;
    flex-direction: column;
    height: 100% !important;
    width: 100% !important;
    overflow: hidden !important;
  }
  
  /* Header - Fixed Height, No Shrink */
  #editor-content > .border-b {
    flex: 0 0 auto !important;
    z-index: 50;
    background-color: white;
    border-bottom: 1px solid #e2e8f0;
    width: 100%;
    position: relative;
  }
  
  /* Body - Scrollable container */
  #editor-content > .flex-grow {
    flex: 1 1 0 !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior: contain !important;
    padding: 0 !important;
  }

  /* SunEditor fills container, no internal scroll */
  #note-content-editor {
    width: 100% !important;
    min-height: 100% !important;
  }

  #editor-content .sun-editor {
    width: 100% !important;
    border: none !important;
  }
  
  #editor-content .sun-editor .se-toolbar {
    position: sticky !important;
    top: 0 !important;
    z-index: 10 !important;
    background: white !important;
  }
  
  #editor-content .sun-editor .se-wrapper {
    min-height: 200px !important;
  }
  
  #editor-content .sun-editor .se-wrapper-inner {
    min-height: 200px !important;
    overflow: visible !important;
  }
  
  #editor-content .sun-editor .se-resizing-bar { display: none !important; }
  
  #editor-area .sun-editor .sun-editor-editable { 
    font-size: 16px !important; 
    line-height: 1.6 !important; 
    padding: 1.25rem !important; 
    min-height: 300px !important;
  }
  #editor-area .sun-editor .se-toolbar { padding: 4px !important; overflow-x: auto; white-space: nowrap; }

  /* Modals Mobile Override */
  .modal-content { 
    min-width: 0 !important; 
    width: 90% !important; 
    max-width: 360px !important;
    padding: 1.5rem !important;
  }
  .modal-actions {
    flex-direction: column-reverse; /* Stack buttons on mobile */
    gap: 12px;
  }
  .modal-button {
    width: 100%;
    justify-content: center;
    padding: 12px;
    font-size: 1rem;
  }
  
  /* Hide resizers on mobile */
  .resizer { display: none !important; }

  /* Mobile Bottom Sheet */
  .bottom-sheet-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(0, 0, 0, 0.4);
    z-index: 2000;
    opacity: 0; visibility: hidden;
    transition: opacity 0.2s ease-out, visibility 0.2s;
  }
  .bottom-sheet-overlay.active { opacity: 1; visibility: visible; }

  .bottom-sheet {
    position: fixed; left: 0; right: 0; bottom: 0;
    background-color: white;
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    padding: 8px 0;
    z-index: 2001;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.1);
    max-height: 80vh;
    overflow-y: auto;
  }
  .bottom-sheet-overlay.active .bottom-sheet { transform: translateY(0); }

  .bottom-sheet-handle {
    width: 40px; height: 4px; background-color: #e2e8f0;
    border-radius: 2px; margin: 0 auto 4px auto;
  }

  .bottom-sheet-item {
    display: flex; align-items: center;
    padding: 12px 24px;
    font-size: 1rem; color: #334155;
    cursor: pointer;
  }
  .bottom-sheet-item:active { background-color: #f1f5f9; }
  .bottom-sheet-item i { margin-right: 16px; width: 24px; text-align: center; color: #94a3b8; font-size: 1.1rem; }
  
  /* Move Mode */
  .move-mode-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(0, 0, 0, 0.5); /* 30-50% dimming */
    z-index: 900; /* Below context menu but above content */
    opacity: 0; visibility: hidden;
    transition: opacity 0.2s;
  }
  .move-mode-overlay.active { opacity: 1; visibility: visible; }

  /* Highlight the folder being moved */
  .folder-list-item.move-mode-target {
    z-index: 910;
    position: relative;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.3);
  }
}

/* Base & Typography */
html { height: 100%; width: 100%; overflow: hidden; overscroll-behavior: none; }
body { 
  font-family: 'Inter', sans-serif; 
  overflow: hidden; 
  color: #334155; 
  background-color: #f8fafc; 
  height: 100%; 
  width: 100%; 
  overscroll-behavior: none;
  position: fixed; /* Fixed to prevent global rubber-banding/scroll chaining */
}

/* Soft Scrollbars */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* Resizers */
.resizer { width: 4px; cursor: col-resize; background-color: transparent; position: absolute; right: 0; top: 0; bottom: 0; z-index: 10; transition: background-color 0.2s; }
.resizer:hover, .resizer.active { background-color: #cbd5e1; }

/* Layout Backgrounds */
#sidebar-left { position: relative; min-width: 150px; max-width: 400px; transition: width 0.05s; background-color: #f8fafc; }
#sidebar-middle { position: relative; min-width: 180px; max-width: 500px; transition: width 0.05s; background-color: #f1f5f9; } /* Slightly darker for card contrast */

body.resizing { cursor: col-resize; user-select: none; }

/* Sidebar Navigation - Pill Style */
.folder-item-container, 
.tag-item-container, 
.favorites-item-container { 
  margin: 1px 8px;
  padding: 6px 12px;
  border-radius: 8px;
  transition: all 0.15s ease-out;
  border: 1px solid transparent;
}

.folder-item-container,
.folder-item-container * {
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.selected-folder > .folder-item-container,
.selected-tag > .tag-item-container,
.selected-favorites > .favorites-item-container { 
  background-color: #ffffff; 
  color: #0f172a; 
  font-weight: 600; 
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 1px 1px rgba(0, 0, 0, 0.02);
  border-color: #e2e8f0;
}

.selected-folder > .folder-item-container .subtle-icon,
.selected-tag > .tag-item-container .subtle-icon,
.selected-favorites > .favorites-item-container .subtle-icon { color: #3b82f6 !important; }

.selected-folder > .folder-item-container .toggle-collapse { color: #64748b; }

.folder-item-container:hover:not(.selected-folder > .folder-item-container),
.tag-item-container:hover:not(.selected-tag > .tag-item-container),
.favorites-item-container:hover:not(.selected-favorites > .favorites-item-container) {
  background-color: #f1f5f9;
}

/* Middle Sidebar - Card Style Notes */
#notes-list { padding: 12px 6px; }

.note-list-item { 
  background-color: #ffffff; 
  border-radius: 12px; 
  margin-bottom: 8px;
  border: 1px solid transparent; 
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.note-list-item:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
  z-index: 5;
}

.selected-note { 
  background-color: #ffffff; 
  border-color: #3b82f6 !important; /* Ring effect */
  box-shadow: 0 0 0 1px #3b82f6, 0 4px 6px -1px rgba(59, 130, 246, 0.1);
}

/* Remove old left border indicator */
.selected-note::before { display: none; }

.selected-note h4 { color: #0f172a; font-weight: 600; }

/* Tree Structure Lines - Removed for cleaner look */
#folder-list { padding-left: 0; }
.folder-tree ul { padding-left: 0; margin-left: 0; }

/* Floating UI (Menus, Dropdowns) */
.context-menu { 
  position: absolute; z-index: 1000; 
  background-color: rgba(255, 255, 255, 0.9); 
  backdrop-filter: blur(12px);
  border: 1px solid rgba(226, 232, 240, 0.8); 
  border-radius: 12px; 
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05); 
  padding: 6px; 
  min-width: 180px; 
}
.context-menu-item { display: flex; align-items: center; padding: 6px 12px; font-size: 0.8125rem; color: #334155; cursor: pointer; border-radius: 6px; transition: background-color 0.1s; }
.context-menu-item i { margin-right: 0.75rem; width: 1em; text-align: center; color: #94a3b8; }
.context-menu-item:hover { background-color: #3b82f6; color: white; }
.context-menu-item:hover i { color: white; }

.context-menu,
.context-menu *,
.bottom-sheet,
.bottom-sheet *,
.move-mode-overlay,
.move-mode-overlay * {
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.tag-selection-dropdown { 
  position: absolute; z-index: 1000; 
  background-color: white; 
  border: 1px solid #e2e8f0; 
  border-radius: 12px; 
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04); 
  margin-top: 0.5rem; max-height: 250px; overflow-y: auto; min-width: 200px; right: 0; padding: 6px; 
  top: 100%; /* Position below the button */
}
.tag-selection-item { display: flex; align-items: center; gap: 0.5rem; padding: 6px 12px; font-size: 0.8125rem; color: #334155; cursor: pointer; border-radius: 6px; }
.tag-selection-item input[type="checkbox"] { margin-right: 0; cursor: pointer; accent-color: #3b82f6; border-radius: 4px; }
.tag-selection-item:hover { background-color: #f1f5f9; }

/* Drag & Drop Visuals */
.dragging { opacity: 0.6; transform: scale(0.98); }
.drop-target > .folder-item-container,
.drop-target > .tag-item-container { background-color: #eff6ff !important; border-color: #bfdbfe; color: #1e40af; }

.folder-list-item.folder-drop-before::before,
.folder-list-item.folder-drop-after::after {
  content: ''; position: absolute; left: 8px; right: 8px; height: 2px;
  background-color: #3b82f6; border-radius: 9999px; box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2); z-index: 5;
}
.folder-list-item.folder-drop-before::before { top: -1px; }
.folder-list-item.folder-drop-after::after { bottom: -1px; }

/* Global UI Elements */
input:focus, textarea:focus { outline: none; border-color: #3b82f6; box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1); }
.subtle-icon { color: #94a3b8; transition: color 0.2s; }
*:hover > .subtle-icon:not(.always-visible-icon):not(.selected-folder > .folder-item-container .subtle-icon):not(.selected-tag > .tag-item-container .subtle-icon):not(.selected-favorites > .favorites-item-container .subtle-icon) { color: #64748b; }

.icon-button { padding: 6px; border-radius: 8px; transition: all 0.2s; color: #64748b; background-color: transparent; border: none; cursor: pointer; line-height: 1; display: inline-flex; align-items: center; justify-content: center; }
.icon-button:hover { background-color: #e2e8f0; color: #0f172a; }
.icon-button:active { transform: scale(0.95); }

.primary-icon-button { background-color: #0f172a; color: white; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1); }
.primary-icon-button:hover { background-color: #334155; color: white; box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1); }

#sidebar-left .folder-name, #sidebar-left .tag-name, #sidebar-left .favorites-name,
#sidebar-middle h4 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.note-tag-pill { display: inline-flex; align-items: center; background-color: #f1f5f9; color: #475569; font-size: 0.75rem; font-weight: 500; padding: 0.25rem 0.75rem; border-radius: 9999px; margin-right: 0.5rem; margin-bottom: 0.5rem; transition: background-color 0.2s; border: 1px solid transparent; }
.note-tag-pill:hover { background-color: white; border-color: #e2e8f0; color: #1e293b; box-shadow: 0 1px 2px rgba(0,0,0,0.05); }
.note-tag-pill button { margin-left: 0.5rem; color: #94a3b8; background: none; border: none; padding: 0; cursor: pointer; font-size: 1rem; line-height: 0.5; }
.note-tag-pill button:hover { color: #ef4444; }

.notes-list-empty-message { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; text-align: center; color: #94a3b8; padding: 2rem; }
.notes-list-empty-message i { font-size: 2rem; margin-bottom: 1rem; color: #e2e8f0; }

.folder-item-container i, .favorites-item-container i { align-self: center; }
#editor-area img { max-width: 100%; height: auto; border-radius: 0.5rem; }

/* SunEditor Customization */
.sun-editor { width: 100% !important; border: none !important; background: transparent !important; }
.sun-editor .se-toolbar { outline: none !important; border: none !important; background: transparent !important; padding: 0 4px !important; }
.sun-editor .se-wrapper { border: none !important; }
#editor-area .sun-editor .sun-editor-editable { overflow-x: auto; font-family: 'Inter', sans-serif; color: #334155; padding: 1.5rem !important; line-height: 1.7; font-size: 1.05rem; }

/* Modern Modals */
.modal-overlay { 
  position: fixed; top: 0; left: 0; right: 0; bottom: 0; 
  background-color: rgba(15, 23, 42, 0.3); 
  backdrop-filter: blur(4px); 
  display: flex; align-items: center; justify-content: center; 
  z-index: 1050; opacity: 0; visibility: hidden; 
  transition: opacity 0.2s ease-in-out, visibility 0.2s ease-in-out; 
}
.modal-overlay.active { opacity: 1; visibility: visible; }

.modal-content { 
  background-color: white; padding: 2rem; 
  border-radius: 1rem; 
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(0,0,0,0.02); 
  min-width: 0; max-width: 450px; width: 90%;
  transform: scale(0.95) translateY(10px); 
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1); 
}
.modal-overlay.active .modal-content { transform: scale(1) translateY(0); }

.modal-title { font-size: 1.25rem; font-weight: 600; color: #0f172a; margin-bottom: 1.5rem; letter-spacing: -0.025em; }

.modal-input { 
  width: 100%; padding: 0.75rem 1rem; 
  border: 1px solid #cbd5e1; border-radius: 0.75rem; 
  font-size: 0.9375rem; margin-bottom: 1.5rem; 
  transition: all 0.2s; color: #0f172a; background-color: #f8fafc;
}
.modal-input:focus { border-color: #3b82f6; background-color: white; box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1); outline: none; }

.modal-actions { display: flex; justify-content: flex-end; gap: 0.75rem; }

.modal-button { padding: 0.625rem 1.25rem; border-radius: 0.75rem; font-size: 0.875rem; font-weight: 500; cursor: pointer; transition: all 0.2s; border: 1px solid transparent; }

.modal-button-primary { background-color: #0f172a; color: white; border-color: #0f172a; }
.modal-button-primary:hover { background-color: #1e293b; transform: translateY(-1px); box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1); }

.modal-button-danger { background-color: #ef4444; color: white; border-color: #ef4444; }
.modal-button-danger:hover { background-color: #dc2626; transform: translateY(-1px); box-shadow: 0 4px 6px -1px rgba(239, 68, 68, 0.25); }

.modal-button-secondary { background-color: white; color: #64748b; border-color: #e2e8f0; }
.modal-button-secondary:hover { background-color: #f8fafc; border-color: #cbd5e1; color: #334155; }

.toggle-collapse.fa-xs { line-height: normal; }

    /* Mobile Safe Area Fix - extra padding for browser bottom bars */
.safe-area-bottom {
  padding-bottom: calc(env(safe-area-inset-bottom, 0px)) !important;
}

[x-cloak] { display: none !important; }
