/* ============================
   RESET
============================ */
* {
    box-sizing: border-box;
    font-family: Arial, sans-serif;
}

/* ============================
   Floating Add Button
============================ */
#floatingAddNoteBtn {
    position: fixed;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: #ff4500;
    color: white;
    font-size: 32px;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.45);
    z-index: 1200;
}

/* ============================
   TOP BAR
============================ */
.notesTopBar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: linear-gradient(90deg,#0f1720,#0b1016);
    border-bottom: 1px solid rgba(255,255,255,0.03);
    color: #fff;
    position: relative;
    z-index: 1000;
}

.notesTopBar .appTitle {
    font-weight: 700;
    font-size: 16px;
}

.notesTopBar .topRight {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ============================
   Export Menu
============================ */
.exportWrap { position: relative; }

.exportMenu {
    display: none;
    position: absolute;
    right: 0;
    top: 40px;
    background: #1b1b1b;
    border-radius: 8px;
    padding: 6px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.6);
    z-index: 1600;
    min-width: 160px;
}
.exportMenu.open,
.exportMenu[aria-open="true"] { display: flex; flex-direction: column; gap:6px; }
.exportMenu button {
    background: transparent;
    color: #eee;
    border: none;
    padding: 8px;
    text-align: left;
    cursor: pointer;
}
.exportMenu button:hover { background: rgba(255,255,255,0.03); }

/* ============================
   NOTES CONTAINER (Base)
============================ */
#noteContainer {
    margin-top: 12px;
    padding: 12px;
    overflow-y: auto;
    min-height: calc(100vh - 180px);
    width: 100%;
    box-sizing: border-box;
}

/* ============================
   LIST VIEW (Full width)
============================ */
#noteContainer.listView {
    display: flex;
    flex-direction: column;
    gap: 15px;
}
#noteContainer.listView .note-card {
    width: 100%;
    height: 120px;
}

/* ============================
   GRID VIEW (True 50% width)
============================ */
#noteContainer.gridView {
    display: grid !important;
    grid-template-columns: repeat(2, calc(50% - 10px));
    gap: 20px;
    width: 100% !important;
    box-sizing: border-box;
}

#noteContainer.gridView .note-card {
    width: 100% !important;
    height: 180px !important; /* 1.5× height */
    max-width: none !important;
    min-width: 0 !important;
    box-sizing: border-box;
}

/* Debug border (optional) */
.note-card.grid-debug { border: 2px solid red !important; }

/* ============================
   NOTE CARD (Universal Style)
============================ */
.note-card {
    background: linear-gradient(145deg, #1f1f1f, #272727);
    color: #ddd;
    border-radius: 12px;
    padding: 14px 16px;
    cursor: pointer;
    box-shadow: 0 6px 14px rgba(0,0,0,0.5);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
    position: relative;
    padding-bottom: 50px; /* reserve space for actions at bottom-right */
}
.note-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 24px rgba(0,0,0,0.6);
}

.noteCardInner {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.note-preview-text {
    color: #dcdcdc;
    font-size: 14px;
    line-height: 1.3;
    white-space: pre-wrap;
    word-break: break-word;
}

.note-timestamp-small {
    color: #9aa3b2;
    font-size: 12px;
}

/* ============================
   Note Actions (bottom-right)
============================ */
.note-actions {
    position: absolute;
    right: 10px;
    bottom: 10px;
    z-index: 20;
    display: flex;
    gap: 8px;
    align-items: center;
}
.iconBtn {
    background: rgba(0,0,0,0.12);
    border: none;
    color: #f7c66b; /* neither pure white nor black - fits both themes */
    font-size: 18px;
    cursor: pointer;
    border-radius: 6px;
    padding: 6px 8px;
}
.iconBtn:hover { filter: brightness(1.05); }

/* ============================
   Panels (Add/Edit)
============================ */
.notePanel {
    display: none;
    flex-direction: column;
    gap: 12px;
    position: fixed;
    top: 0; left: 0;
    width: 100vw;
    height: 100vh;
    background: #121212;
    padding: 18px;
    animation: fadeIn 0.25s ease;
    z-index: 1100;
}

/* Panel top bar layout */
.panelTopBar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* Back Button */
.backArrow {
    font-size: 26px;
    cursor: pointer;
    color: #e0e0e0;
    background: none;
    border: none;
}

/* Per-panel export & theme buttons */
.panelExportBtn,
.panelThemeToggle {
    background: none;
    border: none;
    color: #e0e0e0;
    font-size: 20px;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 6px;
}
.panelExportBtn:hover,
.panelThemeToggle:hover { background: rgba(255,255,255,0.03); }

/* per-panel export menu */
.panelExportMenu {
    display: none;
    position: absolute;
    top: 56px; /* below panel top bar */
    left: 18px;
    background: #1b1b1b;
    border-radius: 8px;
    padding: 6px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.6);
    z-index: 2000;
    min-width: 130px;
    flex-direction: column;
    gap: 6px;
}
.panelExportMenu.open { display: flex; }
.panelExportMenu button {
    background: transparent;
    color: #fff;
    border: none;
    padding: 8px;
    text-align: left;
    cursor: pointer;
}
.panelExportMenu button:hover { background: rgba(255,255,255,0.03); }

/* ============================
   RICH TEXT TOOLBAR
============================ */
.richToolbar {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #222;
    padding: 4px 6px;
    border-radius: 6px;
}

.richToolbar button,
.richToolbar select {
    padding: 4px 6px;
    border-radius: 4px;
    border: none;
    background: #333;
    color: white;
    cursor: pointer;
    font-size: 14px;
}
.richToolbar select { min-width: 70px; }

.richToolbar button.rtBtn {
    width: 28px;
    height: 28px;
    display:flex;
    justify-content:center;
    align-items:center;
}

/* Active formatting state */
.richToolbar .rtBtn.active {
    background: #1e90ff;
    color: #fff;
    box-shadow: 0 4px 10px rgba(30,144,255,0.18);
}

/* Editor areas */
#addContentArea,
#editContentArea {
    flex: 1;
    padding: 12px;
    background: #1e1e1e;
    border-radius: 10px;
    color: white;
    overflow-y: auto;
    outline: none;
    font-size: 16px;
    -webkit-overflow-scrolling: touch;
}

/* ============================
   Confirmation Modal
============================ */
#confirmModal {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.75);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

#confirmBox {
    width: 90%;
    max-width: 420px;
    padding: 20px;
    background: #1e1e1e;
    border-radius: 12px;
    text-align: center;
    color: white;
}

#confirmBox button {
    margin-top: 15px;
    padding: 10px 18px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
}
#confirmYes { background: #1e90ff; color: white; }
#confirmNo { background: #444; color: white; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
}

/* ============================
   LIGHT THEME (applies to the container via .notes-light)
============================ */
.notes-light .notePanel { background: #fff; color: #111; }
.notes-light #addContentArea,
.notes-light #editContentArea { background: #fafafa; color: #111; }
.notes-light .richToolbar { background: #f3f3f3; }
.notes-light .richToolbar button,
.notes-light .richToolbar select { background: #fff; color: #111; border: 1px solid #ddd; }
.notes-light .note-card { background: #fff; color: #111; box-shadow: 0 6px 18px rgba(0,0,0,0.06); border: 1px solid #eee; }
.notes-light .panelExportMenu,
.notes-light .exportMenu { background: #fff; color: #111; border: 1px solid #eee; box-shadow: 0 8px 20px rgba(0,0,0,0.04); }

/* ensure panel export menus are not fullscreen-anchored (positioned near top left of panel) */
#addPanel .panelExportMenu { left: 18px; }
#editPanel .panelExportMenu { left: 18px; }