/* Core Variables - Synchronized across all J-Tools */
:root {
    --bg: #f4f7f9;
    --card-bg: #ffffff;
    --text-main: #1a1c20;
    --text-muted: #64748b;
    --accent: #4361ee;
    --border: #e2e8f0;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] {
    --bg: #0f172a;
    --card-bg: #1e293b;
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --border: #334155;
    --shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
}

/* Base Reset & Typography */
* { margin: 0; padding: 0; box-sizing: border-box; transition: background 0.3s, color 0.3s, border-color 0.3s, box-shadow 0.3s; }
body { background: var(--bg); color: var(--text-main); font-family: 'Plus Jakarta Sans', sans-serif; line-height: 1.6; }

/* Layout Structure */
.wrapper { max-width: 800px; margin: 0 auto; padding: 40px 20px; }

/* Navigation */
nav { display: flex; justify-content: space-between; align-items: center; margin-bottom: 30px; }
.back-link { text-decoration: none; color: var(--text-main); font-weight: 600; font-size: 0.9rem; transition: color 0.2s; }
.back-link:hover { color: var(--accent); }

#theme-toggle {
    background: var(--card-bg); border: 1px solid var(--border); color: var(--text-main);
    width: 40px; height: 40px; border-radius: 12px; cursor: pointer;
    display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow);
}

/* Header */
header { text-align: center; margin-bottom: 40px; }
header h1 { font-size: 2rem; letter-spacing: -1px; margin-bottom: 5px; color: var(--text-main); }
header p { color: var(--text-muted); font-size: 0.95rem; }

/* Reusable Card Style */
.card {
    background: var(--card-bg); border: 1px solid var(--border);
    padding: 30px; border-radius: 24px; box-shadow: var(--shadow); margin-bottom: 40px;
}

/* --- AUTHENTICATION (Login / Register) --- */
.auth-card { max-width: 450px; margin: 0 auto; text-align: center; }
.auth-card h2 { margin-bottom: 25px; font-size: 1.5rem; letter-spacing: -0.5px; }

.auth-input {
    width: 100%; padding: 14px 15px; margin-bottom: 15px; border-radius: 12px;
    border: 1px solid var(--border); background: var(--bg); color: var(--text-main);
    font-family: inherit; font-size: 1rem; outline: none;
}
.auth-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.1); }

/* Standard Buttons */
.btn { flex: 1; border: none; padding: 14px 20px; border-radius: 12px; font-weight: 700; cursor: pointer; font-size: 1rem; display: inline-flex; align-items: center; justify-content: center; }
.btn:active { transform: scale(0.98); }

.primary-btn { background: var(--accent); color: white; border: 1px solid var(--accent); }
.primary-btn:hover { opacity: 0.9; }

.secondary-btn { background: var(--bg); color: var(--text-main); border: 1px solid var(--border); }
.secondary-btn:hover { border-color: var(--text-muted); }

.logout-btn { background: transparent; border: none; color: #ef4444; font-weight: 700; cursor: pointer; font-size: 0.9rem; padding: 8px 12px; border-radius: 8px; }
.logout-btn:hover { background: rgba(239, 68, 68, 0.1); }

/* --- EDITOR SECTION (create & edit) --- */
#note-title {
    width: 100%; border: none; background: transparent; font-size: 1.6rem; font-weight: 700;
    color: var(--text-main); font-family: inherit; margin-bottom: 15px; outline: none;
}
#note-title::placeholder { color: var(--text-muted); opacity: 0.6; font-weight: 600; }

#note-content {
    width: 100%; border: none; background: transparent; font-size: 1.05rem; color: var(--text-main);
    font-family: inherit; min-height: 250px; resize: vertical; outline: none; line-height: 1.7;
}
#note-content::placeholder { color: var(--text-muted); opacity: 0.6; }

.editor-footer {
    display: flex; justify-content: space-between; align-items: center;
    margin-top: 25px; border-top: 1px solid var(--border); padding-top: 25px; gap: 15px;
}

#note-tags {
    flex: 1; border: 1px solid var(--border); background: var(--bg); padding: 12px 15px;
    border-radius: 12px; color: var(--text-main); font-size: 0.95rem; outline: none; font-family: inherit;
}
#note-tags:focus { border-color: var(--accent); }

/* --- DASHBOARD & SAVED NOTES GRID --- */
.section-header { 
    display: flex; justify-content: space-between; align-items: center; 
    margin-bottom: 25px; padding: 0 5px; 
}
.user-greeting h2 { font-size: 1.3rem; letter-spacing: -0.5px; margin-bottom: 2px; }
#note-count { font-size: 0.9rem; color: var(--text-muted); font-weight: 600; }

/* Custom Small Button for Dashboard */
.new-note-btn {
    background: var(--accent); color: white; padding: 8px 16px;
    border-radius: 10px; font-size: 0.85rem; font-weight: 700; 
    text-decoration: none; display: inline-flex; align-items: center; 
    justify-content: center; transition: all 0.2s; white-space: nowrap;
}
.new-note-btn:hover { opacity: 0.9; transform: translateY(-1px); }
.new-note-btn:active { transform: scale(0.95); }

.notes-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 24px; }

/* Individual Note Card */
.note-card {
    background: var(--card-bg); border: 1px solid var(--border); border-radius: 20px;
    padding: 24px; box-shadow: var(--shadow); display: flex; flex-direction: column; cursor: pointer;
    position: relative;
}
.note-card:hover { border-color: var(--accent); transform: translateY(-3px); }

.note-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 15px; }
.note-title { font-size: 1.15rem; font-weight: 700; line-height: 1.3; color: var(--text-main); }

.note-body {
    font-size: 0.95rem; color: var(--text-muted); margin-bottom: 20px; flex-grow: 1;
    overflow: hidden; max-height: 90px; position: relative; line-height: 1.6;
}

/* Markdown parsing inside the card preview */
.note-body p { margin-bottom: 8px; }
.note-body strong { color: var(--text-main); }
.note-body code {
    background: var(--bg); padding: 2px 6px; border-radius: 6px;
    font-family: 'JetBrains Mono', monospace; font-size: 0.85rem; border: 1px solid var(--border);
}

.note-footer { display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--border); padding-top: 15px; }
.note-date { font-size: 0.8rem; color: var(--text-muted); font-weight: 500; }

.tag-pill {
    background: var(--bg); border: 1px solid var(--border); font-size: 0.75rem;
    padding: 4px 10px; border-radius: 20px; color: var(--accent); font-weight: 600; text-transform: lowercase;
}

/* --- MOBILE ADJUSTMENTS --- */
@media (max-width: 650px) {
    /* Shrink the outer padding so cards fit better */
    .wrapper { padding: 20px 15px; }
    
    /* Keep header items on the same row, scale down */
    .section-header { 
        flex-direction: row; align-items: center; 
        margin-bottom: 20px; gap: 10px;
    }
    .user-greeting h2 { font-size: 1.1rem; }
    #note-count { font-size: 0.8rem; }
    
    /* Make the button compact on phones */
    .new-note-btn { padding: 8px 14px; font-size: 0.85rem; border-radius: 10px; }

    /* Fix the grid to a single column */
    .notes-grid { grid-template-columns: 1fr; gap: 16px; }
    
    /* Optimize the forms for mobile touch targets */
    .editor-footer { flex-direction: column; align-items: stretch; gap: 15px; }
    .editor-footer > div { display: flex; width: 100%; gap: 10px; }
    .btn { width: 100%; padding: 14px; }
    
    /* Make cards slightly more compact */
    .card { padding: 20px; border-radius: 20px; margin-bottom: 20px; }
    .note-card { padding: 18px; border-radius: 16px; }
    
    #note-title { font-size: 1.3rem; }
}