/* ─── Reset & Base ─────────────────────────────────────────────────────────── */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Color Palette */
    --bg-primary: #fdf0ed;
    --bg-secondary: #f5e6e0;
    --bg-header: #d4c4bc;
    --text-primary: #3e2c23;
    --text-secondary: #6d5147;
    --text-muted: #9c847a;
    --accent: #c9a89c;
    --accent-hover: #b8917f;
    --accent-dark: #8b6f63;
    --card-shadow: rgba(62, 44, 35, 0.08);
    --card-shadow-hover: rgba(62, 44, 35, 0.18);
    --overlay-bg: rgba(30, 20, 15, 0.6);
    --white: #fffaf8;
    --border-light: rgba(62, 44, 35, 0.1);
    --danger: #d45d5d;
    --danger-hover: #c04444;
    --pin-color: #e8a87c;

    /* Sticky note colors */
    --note-rose: #fce4ec;
    --note-peach: #fff3e0;
    --note-mint: #e8f5e9;
    --note-sky: #e3f2fd;
    --note-lavender: #f3e5f5;
    --note-butter: #fffde7;
    --note-latte: #efebe9;
    --note-silver: #eceff1;

    /* Typography */
    --font-body: 'DM Sans', sans-serif;
    --font-display: 'Playfair Display', serif;

    /* Spacing */
    --gap: 1.5rem;
    --radius: 4px;
    --radius-lg: 8px;
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}


/* ─── Header ───────────────────────────────────────────────────────────────── */
.site-header {
    background: var(--bg-header);
    padding: 0.8rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 12px var(--card-shadow);
}

.site-logo {
    font-family: var(--font-display);
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
    text-decoration: none;
    letter-spacing: 0.02em;
}

.site-logo span {
    font-weight: 400;
    color: var(--text-secondary);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.search-box {
    position: relative;
}

.search-box input {
    font-family: var(--font-body);
    font-size: 0.85rem;
    padding: 0.5rem 0.9rem 0.5rem 2.2rem;
    border: 1.5px solid var(--border-light);
    border-radius: 30px;
    background: var(--white);
    color: var(--text-primary);
    width: 220px;
    transition: var(--transition);
    outline: none;
}

.search-box input:focus {
    border-color: var(--accent);
    width: 280px;
    box-shadow: 0 0 0 3px rgba(201, 168, 156, 0.15);
}

.search-box input::placeholder {
    color: var(--text-muted);
}

.search-box svg {
    position: absolute;
    left: 0.7rem;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    pointer-events: none;
}

.btn {
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0.5rem 1.2rem;
    border: none;
    border-radius: 30px;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    line-height: 1.4;
}

.btn-primary {
    background: var(--accent-dark);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--text-primary);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px var(--card-shadow-hover);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1.5px solid var(--border-light);
}

.btn-ghost:hover {
    background: var(--white);
    border-color: var(--accent);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-danger:hover {
    background: var(--danger-hover);
}

.btn-sm {
    font-size: 0.78rem;
    padding: 0.35rem 0.9rem;
}


/* ─── Main Content ─────────────────────────────────────────────────────────── */
.main-content {
    max-width: 1280px;
    margin: 0 auto;
    padding: 2rem 2rem 4rem;
}

.wall-title {
    font-family: var(--font-display);
    font-size: 1.6rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.3rem;
}

.wall-subtitle {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 2rem;
}

.entry-count {
    font-weight: 600;
    color: var(--accent-dark);
}


/* ─── Sticky Notes Grid ───────────────────────────────────────────────────── */
.notes-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: var(--gap);
}

.sticky-note {
    position: relative;
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 210px;
    box-shadow: 2px 3px 8px var(--card-shadow),
                0 1px 2px rgba(62, 44, 35, 0.04);
}

.sticky-note::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, 
        rgba(62, 44, 35, 0.06), 
        rgba(62, 44, 35, 0.12), 
        rgba(62, 44, 35, 0.06));
    z-index: 1;
}

.sticky-note:hover {
    transform: translateY(-4px) rotate(-0.5deg);
    box-shadow: 4px 8px 24px var(--card-shadow-hover),
                0 2px 6px rgba(62, 44, 35, 0.08);
}

.sticky-note:active {
    transform: translateY(-2px) rotate(0deg);
}

.note-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 0.9rem 1rem 0.5rem;
    background: rgba(0, 0, 0, 0.04);
    gap: 0.5rem;
}

.note-title {
    font-family: var(--font-display);
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.3;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.note-date {
    font-size: 0.7rem;
    color: var(--text-muted);
    white-space: nowrap;
    font-weight: 500;
    letter-spacing: 0.02em;
}

.note-body {
    padding: 0.7rem 1rem 1rem;
    flex: 1;
    overflow: hidden;
    position: relative;
}

.note-preview {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.55;
    display: -webkit-box;
    -webkit-line-clamp: 5;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.note-body::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 30px;
    background: linear-gradient(transparent, var(--note-rose));
    pointer-events: none;
}

/* Override fade gradient for each note color */
.sticky-note[data-color="#fce4ec"] .note-body::after { background: linear-gradient(transparent, #fce4ec); }
.sticky-note[data-color="#fff3e0"] .note-body::after { background: linear-gradient(transparent, #fff3e0); }
.sticky-note[data-color="#e8f5e9"] .note-body::after { background: linear-gradient(transparent, #e8f5e9); }
.sticky-note[data-color="#e3f2fd"] .note-body::after { background: linear-gradient(transparent, #e3f2fd); }
.sticky-note[data-color="#f3e5f5"] .note-body::after { background: linear-gradient(transparent, #f3e5f5); }
.sticky-note[data-color="#fffde7"] .note-body::after { background: linear-gradient(transparent, #fffde7); }
.sticky-note[data-color="#efebe9"] .note-body::after { background: linear-gradient(transparent, #efebe9); }
.sticky-note[data-color="#eceff1"] .note-body::after { background: linear-gradient(transparent, #eceff1); }

.note-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.4rem 1rem 0.7rem;
}

.note-mood {
    font-size: 1.1rem;
    line-height: 1;
}

.note-pin {
    font-size: 0.7rem;
    color: var(--pin-color);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}


/* ─── Pagination ───────────────────────────────────────────────────────────── */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 2.5rem;
}

.page-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1.5px solid var(--border-light);
    border-radius: 50%;
    background: var(--white);
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    font-family: var(--font-body);
}

.page-btn:hover {
    border-color: var(--accent);
    background: var(--accent);
    color: var(--white);
}

.page-btn.active {
    background: var(--accent-dark);
    border-color: var(--accent-dark);
    color: var(--white);
}

.page-btn.disabled {
    opacity: 0.35;
    pointer-events: none;
}

.page-info {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin: 0 0.8rem;
}


/* ─── Modal Overlay ────────────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--overlay-bg);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    max-width: 640px;
    width: 100%;
    max-height: 85vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(30, 20, 15, 0.3);
    transform: scale(0.92) translateY(20px);
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.active .modal-card {
    transform: scale(1) translateY(0);
}

.modal-top-bar {
    height: 6px;
    width: 100%;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.modal-header {
    padding: 1.5rem 2rem 1rem;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.modal-title {
    font-family: var(--font-display);
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.3;
}

.modal-close {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 50%;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 1.2rem;
    transition: var(--transition);
    flex-shrink: 0;
}

.modal-close:hover {
    background: rgba(0, 0, 0, 0.1);
    color: var(--text-primary);
}

.modal-meta {
    padding: 0 2rem;
    display: flex;
    gap: 1.5rem;
    font-size: 0.82rem;
    color: var(--text-muted);
}

.modal-meta-item {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.modal-body {
    padding: 1.5rem 2rem 2rem;
    overflow-y: auto;
    flex: 1;
}

.modal-content {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.8;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.modal-actions {
    padding: 1rem 2rem 1.5rem;
    display: flex;
    gap: 0.6rem;
    border-top: 1px solid var(--border-light);
}


/* ─── Editor Page ──────────────────────────────────────────────────────────── */
.editor-container {
    max-width: 700px;
    margin: 2rem auto;
    padding: 0 2rem;
}

.editor-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    box-shadow: 0 4px 20px var(--card-shadow);
}

.editor-title {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 2rem;
    color: var(--text-primary);
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.form-input {
    width: 100%;
    font-family: var(--font-body);
    font-size: 0.95rem;
    padding: 0.75rem 1rem;
    border: 1.5px solid var(--border-light);
    border-radius: var(--radius);
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: var(--transition);
    outline: none;
}

.form-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(201, 168, 156, 0.12);
}

textarea.form-input {
    resize: vertical;
    min-height: 240px;
    line-height: 1.7;
}

.form-error {
    background: #fef2f2;
    color: var(--danger);
    padding: 0.7rem 1rem;
    border-radius: var(--radius);
    font-size: 0.85rem;
    margin-bottom: 1.5rem;
    border-left: 3px solid var(--danger);
}

/* Color picker */
.color-options {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.color-option {
    position: relative;
}

.color-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.color-swatch {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    border: 2.5px solid transparent;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.color-option input[type="radio"]:checked + .color-swatch {
    border-color: var(--accent-dark);
    box-shadow: 0 0 0 3px rgba(139, 111, 99, 0.2);
}

.color-swatch:hover {
    transform: scale(1.12);
}

.color-swatch .check {
    display: none;
    font-size: 0.7rem;
}

.color-option input[type="radio"]:checked + .color-swatch .check {
    display: block;
}

/* Mood picker */
.mood-options {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.mood-option {
    position: relative;
}

.mood-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.mood-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem 0.7rem;
    border-radius: var(--radius);
    cursor: pointer;
    border: 1.5px solid transparent;
    transition: var(--transition);
    font-size: 0.72rem;
    color: var(--text-muted);
}

.mood-label:hover {
    background: rgba(0, 0, 0, 0.03);
}

.mood-option input[type="radio"]:checked + .mood-label {
    border-color: var(--accent);
    background: rgba(201, 168, 156, 0.08);
    color: var(--text-primary);
}

.mood-emoji {
    font-size: 1.5rem;
}

.form-actions {
    display: flex;
    gap: 0.8rem;
    margin-top: 2rem;
}


/* ─── Empty State ──────────────────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    grid-column: 1 / -1;
}

.empty-icon {
    font-size: 3.5rem;
    margin-bottom: 1rem;
    opacity: 0.6;
}

.empty-title {
    font-family: var(--font-display);
    font-size: 1.3rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.empty-text {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}


/* ─── Animations ───────────────────────────────────────────────────────────── */
@keyframes noteIn {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.sticky-note {
    animation: noteIn 0.4s ease backwards;
}

.sticky-note:nth-child(1)  { animation-delay: 0.03s; }
.sticky-note:nth-child(2)  { animation-delay: 0.06s; }
.sticky-note:nth-child(3)  { animation-delay: 0.09s; }
.sticky-note:nth-child(4)  { animation-delay: 0.12s; }
.sticky-note:nth-child(5)  { animation-delay: 0.15s; }
.sticky-note:nth-child(6)  { animation-delay: 0.18s; }
.sticky-note:nth-child(7)  { animation-delay: 0.21s; }
.sticky-note:nth-child(8)  { animation-delay: 0.24s; }
.sticky-note:nth-child(9)  { animation-delay: 0.27s; }
.sticky-note:nth-child(10) { animation-delay: 0.30s; }


/* ─── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 1100px) {
    .notes-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 860px) {
    .notes-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    .site-header {
        padding: 0.8rem 1.2rem;
    }
    .main-content {
        padding: 1.5rem 1.2rem 3rem;
    }
}

@media (max-width: 600px) {
    .notes-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
    .search-box input {
        width: 150px;
    }
    .search-box input:focus {
        width: 180px;
    }
    .modal-card {
        max-height: 90vh;
    }
    .modal-header {
        padding: 1.2rem 1.5rem 0.8rem;
    }
    .modal-body {
        padding: 1rem 1.5rem 1.5rem;
    }
    .editor-card {
        padding: 1.5rem;
    }
}

@media (max-width: 420px) {
    .notes-grid {
        grid-template-columns: 1fr;
    }
    .site-logo {
        font-size: 1.1rem;
    }
    .btn span.btn-label {
        display: none;
    }
}


/* ─── Login Page ───────────────────────────────────────────────────────────── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
}

.login-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 3rem 2.5rem;
    max-width: 400px;
    width: 100%;
    box-shadow: 0 8px 40px var(--card-shadow),
                0 2px 8px rgba(62, 44, 35, 0.06);
    text-align: center;
    animation: noteIn 0.5s ease;
}

.login-icon {
    font-size: 2.8rem;
    margin-bottom: 1rem;
}

.login-title {
    font-family: var(--font-display);
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.2rem;
}

.login-subtitle {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 2rem;
}

.login-form {
    text-align: left;
}

.login-form .form-group {
    margin-bottom: 1.5rem;
}

.login-btn {
    width: 100%;
    justify-content: center;
    padding: 0.7rem 1.2rem;
    font-size: 0.9rem;
}

.login-back {
    display: inline-block;
    margin-top: 1.5rem;
    font-size: 0.82rem;
    color: var(--text-muted);
    text-decoration: none;
    transition: var(--transition);
}

.login-back:hover {
    color: var(--accent-dark);
}


/* ─── Admin Styles ─────────────────────────────────────────────────────────── */
.admin-body {
    background: linear-gradient(180deg, #f0e8e4 0%, var(--bg-primary) 120px);
}

.admin-header {
    background: linear-gradient(90deg, #3e2c23, #5a3f32);
}

.admin-header .site-logo {
    color: var(--white);
}

.admin-header .site-logo span {
    color: rgba(255, 255, 255, 0.6);
}

.admin-badge {
    font-family: var(--font-body);
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    background: var(--pin-color);
    color: var(--text-primary);
    padding: 0.15rem 0.5rem;
    border-radius: 20px;
    vertical-align: middle;
    margin-left: 0.4rem;
}

.admin-header .search-box input {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.15);
    color: var(--white);
}

.admin-header .search-box input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.admin-header .search-box input:focus {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.35);
}

.admin-header .search-box svg {
    color: rgba(255, 255, 255, 0.5);
}

.admin-header .btn-ghost {
    color: rgba(255, 255, 255, 0.8);
    border-color: rgba(255, 255, 255, 0.2);
}

.admin-header .btn-ghost:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.35);
    color: #fff;
}
