/* ==========================================================================
   STASH NOIR — Dark Mode Editorial Redesign
   ========================================================================== */

:root {
    --bg:        #0F0F0F;
    --sidebar-bg: #161616;
    --surface:   #1E1E1E;
    --surface-hover: #262626;
    --border:    #2D2D2D;
    --text:      #FFFFFF;
    --text-2:    #A0A0A0;
    --text-3:    #606060;
    --accent:    #C8553D;
    --radius:    16px;
    --font-display: 'DM Serif Display', serif;
    --font-body:    'DM Sans', sans-serif;
    --font-mono:    'JetBrains Mono', monospace;
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

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

body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ==========================================================================
   SIDEBAR FIX
   ========================================================================== */

.sidebar {
    width: 280px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 32px 20px;
}

.sidebar-top {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 32px;
}

.brand-mark {
    width: 40px; height: 40px; background: var(--accent); color: #fff;
    font-family: var(--font-display); font-size: 22px;
    display: flex; align-items: center; justify-content: center; border-radius: 12px;
    flex-shrink: 0;
}

.brand-text { font-family: var(--font-display); font-size: 26px; color: var(--text); }

.nav-item {
    padding: 12px 16px; border-radius: 12px; cursor: pointer; color: var(--text-2);
    font-size: 14px; transition: 0.2s; display: flex; align-items: center; gap: 10px;
}

.nav-item:hover, .nav-item.active { background: var(--surface); color: var(--text); }
.nav-item.active { border-left: 3px solid var(--accent); border-radius: 4px 12px 12px 4px; }

.nav-count { margin-left: auto; font-family: var(--font-mono); font-size: 11px; opacity: 0.5; }

/* ==========================================================================
   APP MAIN & UNIFORM GRID
   ========================================================================== */

#app { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
    height: 80px; padding: 0 40px; display: flex; align-items: center;
    justify-content: space-between; border-bottom: 1px solid var(--border);
}

.search-bar {
    background: var(--surface); border: 1px solid var(--border); padding: 12px 20px;
    border-radius: 30px; color: #fff; width: 300px; outline: none; transition: 0.3s;
}
.search-bar:focus { border-color: var(--accent); width: 340px; }

.feed { flex: 1; overflow-y: auto; padding: 40px; scroll-behavior: smooth; }

.feed.grid-view {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    grid-auto-rows: 400px;
    gap: 32px;
}

/* ==========================================================================
   CARD DESIGN
   ========================================================================== */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    position: relative;
    cursor: pointer;
    transition: all 0.4s var(--ease-out);
    display: flex;
    flex-direction: column;
}

.card::before {
    content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
    background: var(--text-3); transition: 0.3s;
}

.card.type-note::before { background: #4A90E2; }
.card.type-link::before { background: #50E3C2; }
.card.type-image::before { background: var(--accent); }

.card:hover {
    transform: translateY(-8px);
    border-color: var(--accent);
    box-shadow: 0 12px 40px rgba(0,0,0,0.4);
}

.card-inner { padding: 24px; display: flex; flex-direction: column; height: 100%; }

.card-header {
    display: flex; justify-content: space-between; margin-bottom: 16px;
    font-family: var(--font-mono); font-size: 10px; text-transform: uppercase; letter-spacing: 1px;
}

.card-type { color: var(--accent); font-weight: 600; }
.card-date { color: var(--text-3); }

.card-url {
    font-family: var(--font-mono); font-size: 11px; color: var(--accent);
    background: rgba(200, 85, 61, 0.1); padding: 4px 8px; border-radius: 6px;
    margin-bottom: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.card-img-container { height: 160px; margin: 0 -24px 16px -24px; overflow: hidden; }
.card-image-preview { width: 100%; height: 100%; object-fit: cover; }

.card-title {
    font-family: var(--font-display); font-size: 22px; line-height: 1.2;
    margin-bottom: 12px; color: var(--text);
}

.card-snippet {
    font-size: 14px; color: var(--text-2); line-height: 1.6;
    overflow: hidden; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical;
}

/* ==========================================================================
   MODAL FIXES
   ========================================================================== */

#modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.8); backdrop-filter: blur(10px);
    z-index: 2000; display: flex; align-items: center; justify-content: center;
    opacity: 0; pointer-events: none; transition: 0.3s;
}
#modal-overlay.open { opacity: 1; pointer-events: auto; }

.modal-content {
    background: #121212; border: 1px solid var(--border); padding: 50px;
    width: 90%; max-width: 800px; border-radius: 24px; position: relative;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}

.modal-close {
    position: absolute; top: 24px; right: 24px; width: 36px; height: 36px;
    background: var(--surface); border: 1px solid var(--border); color: var(--text-2);
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: 0.2s; font-size: 18px;
}
.modal-close:hover { background: var(--accent); color: white; border-color: var(--accent); }

.edit-input-meta {
    background: var(--surface); border: 1px solid var(--border); color: var(--text-2);
    padding: 6px 12px; border-radius: 8px; font-size: 12px; outline: none;
}

.modal-image-full { width: 100%; border-radius: 12px; margin-bottom: 24px; }

.btn-save { background: var(--accent); color: white; border: none; padding: 12px 32px; border-radius: 12px; font-weight: 600; cursor: pointer; transition: 0.2s; }
.btn-save:hover { transform: translateY(-2px); box-shadow: 0 4px 15px rgba(200, 85, 61, 0.3); }

.btn-delete { background: transparent; color: #ff4444; border: 1px solid #ff4444; padding: 12px 24px; border-radius: 12px; cursor: pointer; transition: 0.2s; }
.btn-delete:hover { background: rgba(255, 68, 68, 0.1); }

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }

.hidden { display: none !important; }
/* ==========================================================================
   RICH LINK CARDS
   ========================================================================== */

.rich-link-data {
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.link-domain-badge {
    display: inline-block;
    width: fit-content;
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 1px;
    background: rgba(255,255,255,0.05);
    padding: 4px 10px;
    border-radius: 4px;
    border: 1px solid var(--border);
}

.card-url {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--accent);
    background: rgba(200, 85, 61, 0.08);
    padding: 10px 14px;
    border-radius: 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    border: 1px dashed rgba(200, 85, 61, 0.3);
}

.card-footer-action {
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid rgba(255,255,255,0.03);
}

.btn-visit {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-2);
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: 0.2s;
}

.card:hover .btn-visit {
    color: var(--accent);
}

/* Ensure the snippet doesn't crowd the link data */
.type-link .card-snippet {
    -webkit-line-clamp: 2; /* Shorter snippet for links to balance space */
    opacity: 0.7;
}

/* Visual decoration for empty feeling cards */
.type-link::after {
    content: '🔗';
    position: absolute;
    right: -10px;
    bottom: -10px;
    font-size: 80px;
    opacity: 0.03;
    transform: rotate(-15deg);
    pointer-events: none;
}
