/* ── Insait Notes — Orange-Purple Theme ─────────────────────── */
:root {
    --orange:        #ff6b00;
    --orange-light:  #ff8c00;
    --orange-dark:   #cc5500;
    --purple:        #6a0dad;
    --purple-light:  #9b30d0;
    --purple-dark:   #450a7d;
    --bg-dark:       #1a0a2e;
    --bg-card:       #2a1050;
    --bg-card-hover: #331268;
    --text-light:    #f0e6ff;
    --text-muted:    #c4a8e8;
    --border:        rgba(255,107,0,0.3);
    --shadow:        0 4px 24px rgba(106,13,173,0.4);
    --pri-high:      #e05555;
    --pri-normal:    #d4a800;
    --pri-low:       #3aab6e;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-dark);
    color: var(--text-light);
    min-height: 100vh;
    min-height: 100dvh;
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

/* ── NAV ─────────────────────────────────────────────────────── */
nav {
    background: linear-gradient(90deg, var(--purple-dark) 0%, var(--purple) 50%, var(--orange-dark) 100%);
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 16px rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    min-height: 56px;
}

.back-link {
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    font-size: 0.82rem;
    padding: 0.4rem 0.7rem;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 6px;
    transition: background 0.2s, color 0.2s;
    white-space: nowrap;
}

.back-link:hover { background: rgba(255,255,255,0.12); color: #fff; }

nav .brand {
    font-size: 1.35rem;
    font-weight: 700;
    color: #fff;
    text-decoration: none;
    padding: 1rem 0.5rem;
    letter-spacing: 1px;
    white-space: nowrap;
    flex: 1;
}

nav .brand span { color: var(--orange-light); }

.nav-toggle {
    display: none;
    background: none;
    border: none;
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
}

.nav-panel {
    display: flex;
    align-items: center;
}

.lang-switcher {
    display: flex;
    gap: 0.25rem;
    padding: 0.4rem 0;
    flex-shrink: 0;
}

.lang-btn {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 6px;
    color: var(--text-light);
    padding: 0.25rem 0.45rem;
    font-size: 0.76rem;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.2s;
    white-space: nowrap;
}

.lang-btn:hover { background: rgba(255,107,0,0.3); }

.lang-btn.lang-active {
    background: linear-gradient(90deg, var(--orange), var(--orange-dark));
    border-color: var(--orange);
    color: #fff;
}

/* ── HERO ─────────────────────────────────────────────────────── */
.hero {
    background: linear-gradient(135deg, var(--purple-dark) 0%, var(--bg-dark) 60%, var(--orange-dark) 100%);
    text-align: center;
    padding: 3.5rem 2rem 2.5rem;
}

.hero h1 {
    font-size: clamp(1.8rem, 5vw, 3rem);
    font-weight: 800;
    background: linear-gradient(90deg, var(--orange-light), var(--purple-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
}

.hero-icon {
    display: inline-block;
    width: 1.15em;
    height: 1.15em;
    vertical-align: middle;
    border: 2px solid var(--orange);
    border-radius: 6px;
}

.hero p {
    color: var(--text-muted);
    font-size: 1.1rem;
}

/* ── TOOLBAR ──────────────────────────────────────────────────── */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    max-width: 1100px;
    margin: 1.5rem auto 0;
    padding: 0 1.5rem;
}

.toolbar-left { display: flex; align-items: center; gap: 1rem; }

.notes-count {
    color: var(--text-muted);
    font-size: 0.88rem;
}

.toolbar-right input[type="search"] {
    background: rgba(255,255,255,0.07);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-light);
    padding: 0.55rem 0.9rem;
    font-size: 0.92rem;
    outline: none;
    width: 240px;
    transition: border-color 0.2s;
}

.toolbar-right input[type="search"]:focus { border-color: var(--orange-light); }

.toolbar-right input[type="search"]::placeholder { color: var(--text-muted); }

/* ── FILTERS BAR ──────────────────────────────────────────────── */
.filters-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    max-width: 1100px;
    margin: 0.75rem auto 0;
    padding: 0 1.5rem;
}

.filter-group { display: flex; gap: 0.4rem; flex-wrap: wrap; }

.filter-btn {
    background: rgba(255,255,255,0.07);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text-muted);
    padding: 0.3rem 0.85rem;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.filter-btn:hover { background: rgba(255,107,0,0.15); color: var(--text-light); }

.filter-btn.active {
    background: linear-gradient(90deg, var(--orange), var(--orange-dark));
    border-color: var(--orange);
    color: #fff;
}

.sort-group { display: flex; align-items: center; gap: 0.5rem; }

.sort-label { color: var(--text-muted); font-size: 0.85rem; white-space: nowrap; }

.sort-group select {
    background: rgba(255,255,255,0.07);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-light);
    padding: 0.3rem 0.6rem;
    font-size: 0.85rem;
    outline: none;
    cursor: pointer;
}

.sort-group select option { background: var(--bg-card); }

/* ── MAIN / GRID ──────────────────────────────────────────────── */
main {
    flex: 1;
    width: 100%;
    max-width: 1100px;
    margin: 1.25rem auto 0;
    padding: 0 1.5rem 4rem;
}

.notes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.25rem;
}

/* ── NOTE CARD ────────────────────────────────────────────────── */
.note-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 1.25rem 1.35rem;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    cursor: pointer;
    transition: transform 0.18s, box-shadow 0.18s, border-color 0.18s;
    position: relative;
    outline: none;
}

.note-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 4px;
    height: 100%;
    border-radius: 14px 0 0 14px;
}

.note-card.pri-high::before   { background: var(--pri-high); }
.note-card.pri-normal::before { background: var(--pri-normal); }
.note-card.pri-low::before    { background: var(--pri-low); }

.note-card:hover, .note-card:focus {
    transform: translateY(-4px);
    box-shadow: 0 8px 32px rgba(106,13,173,0.55);
    border-color: rgba(255,107,0,0.55);
}

.note-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
}

.note-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--orange-light);
    word-break: break-word;
}

.note-preview {
    color: var(--text-muted);
    font-size: 0.88rem;
    line-height: 1.55;
    flex: 1;
    word-break: break-word;
}

.ellipsis { color: var(--text-muted); opacity: 0.6; }

.note-footer {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.25rem;
}

.note-date {
    color: var(--text-muted);
    font-size: 0.77rem;
    margin-left: auto;
}

.note-chars {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.note-cat {
    background: rgba(106,13,173,0.35);
    border: 1px solid rgba(155,48,208,0.4);
    color: var(--purple-light);
    border-radius: 12px;
    padding: 0.12rem 0.55rem;
    font-size: 0.75rem;
    font-weight: 600;
}

.note-pri-badge {
    font-size: 0.72rem;
    font-weight: 700;
    border-radius: 10px;
    padding: 0.15rem 0.5rem;
    white-space: nowrap;
    flex-shrink: 0;
}

.note-pri-badge.pri-high   { background: rgba(224,85,85,0.2);  color: var(--pri-high); }
.note-pri-badge.pri-normal { background: rgba(212,168,0,0.2);  color: var(--pri-normal); }
.note-pri-badge.pri-low    { background: rgba(58,171,110,0.2); color: var(--pri-low); }

/* ── EMPTY STATE ──────────────────────────────────────────────── */
.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    color: var(--text-muted);
    padding: 4rem 1rem;
    font-size: 1.05rem;
}

/* ── CLEAR WRAP ───────────────────────────────────────────────── */
.clear-wrap {
    text-align: right;
    margin-top: 1.5rem;
}

/* ── BUTTONS ──────────────────────────────────────────────────── */
.btn {
    display: inline-block;
    padding: 0.6rem 1.4rem;
    border-radius: 8px;
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: filter 0.2s, transform 0.1s;
}

.btn:hover  { filter: brightness(1.15); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary {
    background: linear-gradient(90deg, var(--orange), var(--orange-dark));
    color: #fff;
}

.btn-ghost {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.15);
    color: var(--text-light);
}

.btn-danger-sm {
    background: rgba(220,50,50,0.2);
    border: 1px solid rgba(220,50,50,0.4);
    color: #ff7070;
    padding: 0.4rem 0.9rem;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    display: inline-block;
}

.btn-danger-sm:hover { background: rgba(220,50,50,0.35); }

/* ── MODALS ───────────────────────────────────────────────────── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(10,0,30,0.75);
    backdrop-filter: blur(3px);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-overlay.active { display: flex; }

.modal-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 8px 48px rgba(0,0,0,0.6);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
    animation: modalIn 0.2s ease;
}

.modal-box--view { max-width: 660px; }

@keyframes modalIn {
    from { opacity: 0; transform: translateY(-16px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0)     scale(1); }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h2 {
    font-size: 1.3rem;
    color: var(--orange-light);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.6rem;
    cursor: pointer;
    line-height: 1;
    padding: 0.1rem 0.3rem;
    border-radius: 6px;
    transition: color 0.2s, background 0.2s;
}

.modal-close:hover { color: #fff; background: rgba(255,255,255,0.1); }

.modal-footer {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}

/* ── FORM ─────────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 0.35rem; }

.form-group label {
    color: var(--orange-light);
    font-weight: 600;
    font-size: 0.88rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    background: rgba(255,255,255,0.07);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-light);
    padding: 0.6rem 0.85rem;
    font-size: 0.93rem;
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: var(--orange-light); }

.form-group textarea { resize: vertical; min-height: 120px; }

.form-group select option { background: var(--bg-card); }

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* ── VIEW CONTENT ─────────────────────────────────────────────── */
.view-meta {
    color: var(--text-muted);
    font-size: 0.88rem;
    line-height: 1.8;
}

.view-content {
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.1rem 1.2rem;
    color: var(--text-light);
    font-size: 0.95rem;
    line-height: 1.75;
    word-break: break-word;
    white-space: pre-wrap;
}

/* ── ALERTS ───────────────────────────────────────────────────── */
.alert {
    padding: 0.65rem 0.9rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
}

.alert-danger {
    background: rgba(220,50,50,0.15);
    border: 1px solid #dc3232;
    color: #ff7070;
}

/* ── FOOTER ───────────────────────────────────────────────────── */
footer {
    text-align: center;
    padding: 1.5rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    border-top: 1px solid var(--border);
    background: var(--purple-dark);
}

footer a { color: var(--orange-light); text-decoration: none; }

/* ── MOBILE ───────────────────────────────────────────────────── */
@media (max-width: 680px) {
    nav {
        padding: 0 max(1rem, env(safe-area-inset-right)) 0 max(1rem, env(safe-area-inset-left));
    }

    .nav-toggle { display: block; }

    .nav-panel {
        display: none;
        width: 100%;
        padding: 0.5rem 0 0.75rem;
    }

    .nav-panel.open { display: flex; }

    .lang-switcher { justify-content: center; flex-wrap: wrap; }

    .toolbar, .filters-bar { flex-direction: column; align-items: stretch; }

    .toolbar-right input[type="search"] { width: 100%; }

    .form-row { grid-template-columns: 1fr; }

    .form-group input,
    .form-group select,
    .form-group textarea,
    .toolbar-right input[type="search"] {
        font-size: 1rem;
    }

    main,
    .toolbar,
    .filters-bar {
        padding-left: max(1.5rem, env(safe-area-inset-left));
        padding-right: max(1.5rem, env(safe-area-inset-right));
    }

    .modal-box {
        padding: 1.25rem;
        max-height: 90dvh;
        padding-bottom: max(1.25rem, env(safe-area-inset-bottom));
    }

    footer { padding-bottom: max(1.5rem, env(safe-area-inset-bottom)); }
}

@media (max-width: 480px) {
    .notes-grid { grid-template-columns: 1fr; }

    .toolbar-left { width: 100%; }
    .toolbar-left .btn { flex: 1; }

    .modal-footer .btn { flex: 1 1 auto; }
}
