@import url('https://fonts.googleapis.com/css2?family=Lora:ital,wght@0,400;0,500;0,600;1,400&family=Inter:wght@300;400;500&display=swap');

:root {
    /* Colors - Paper & Ink aesthetic */
    --bg-paper: #eCECE9; 
    --bg-surface: #F4F4F1; /* Fondo para las cards */
    --text-ink: #2A2A28; 
    --text-muted: #7A7A76; 
    --border-line: rgba(42, 42, 40, 0.15); 
    
    /* Muted Tag Colors (Earthy/Pastel) */
    --tag-1: #D1D5C8; 
    --tag-2: #E6D4D4; 
    --tag-3: #E1DCD3; 
    --tag-4: #C9D0D5; 
    --tag-5: #D8D4E3; 

    /* Typography */
    --font-serif: 'Lora', serif;
    --font-sans: 'Inter', sans-serif;

    /* Layout Metrics */
    --dock-height: 70px;
    --max-width: 800px;
}

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

body {
    font-family: var(--font-sans);
    background-color: var(--bg-paper);
    color: var(--text-ink);
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    overflow-x: hidden;
    padding-bottom: calc(var(--dock-height) + 100px);
    
    /* Decoración de diario */
    background-image: repeating-linear-gradient(
        transparent, 
        transparent 31px, 
        rgba(0, 0, 0, 0.04) 31px, 
        rgba(0, 0, 0, 0.04) 32px
    );
    background-attachment: local;
    line-height: 32px;
}

/* Layout */
.app-container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 4rem 2rem;
}

.view {
    display: none;
    animation: fadeIn 0.6s ease forwards;
}

.view.active {
    display: block;
}

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

/* Headers */
.view-header {
    margin-bottom: 4rem; 
    text-align: center;
}

h1 {
    font-family: var(--font-serif);
    font-size: 3rem;
    font-weight: 400;
    font-style: italic;
    letter-spacing: -0.02em;
    margin-bottom: 0.5rem;
    color: var(--text-ink);
}

.subtitle {
    font-family: var(--font-sans);
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 300;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

/* Sticky Search & Tags (Notepad) */
.sticky-header {
    position: sticky;
    top: 0;
    background: linear-gradient(to bottom, var(--bg-paper) 85%, transparent);
    padding: 2rem 0 1.5rem 0;
    z-index: 10;
}

.search-bar-container {
    display: flex;
    align-items: center;
    background: var(--bg-surface);
    border: 1px solid var(--text-ink); /* Neobrutalismo: borde fino y claro */
    padding: 0.75rem 1.25rem;
    margin-bottom: 1.5rem;
    transition: all 0.2s ease;
    border-radius: 4px;
}

.search-bar-container:focus-within {
    box-shadow: 2px 2px 0 var(--text-ink); /* Neobrutalismo elegante al interactuar */
    transform: translate(-1px, -1px);
}

.search-bar-container i {
    color: var(--text-ink);
    font-size: 1.2rem;
    margin-right: 1rem;
}

.search-bar-container input {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-ink);
    font-size: 1.1rem;
    outline: none;
    font-family: var(--font-serif);
    font-style: italic;
}

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

/* Tags */
.tags-filter-container {
    display: flex;
    gap: 0.75rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
    scrollbar-width: none;
}

.tags-filter-container::-webkit-scrollbar {
    display: none;
}

.tag {
    padding: 0.3rem 0.8rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s ease;
    border: 1px solid var(--text-ink); /* Borde fino */
    color: var(--text-ink);
}

.tag.blue { background-color: var(--tag-1); }
.tag.pink { background-color: var(--tag-2); }
.tag.green { background-color: var(--tag-3); }
.tag.purple { background-color: var(--tag-4); }
.tag.orange { background-color: var(--tag-5); }

.tag:hover {
    transform: translate(-1px, -1px);
    box-shadow: 2px 2px 0 var(--text-ink);
}

/* Grids & Cards */
.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); /* Mejor escalabilidad móvil */
    gap: 2rem; 
}

.card {
    background: var(--bg-surface); /* Tapa las líneas del fondo, mejorando legibilidad */
    border: 1px solid var(--text-ink); /* Neobrutalismo: Borde delimitador */
    border-radius: 4px; /* Un pelín redondeado para mantener elegancia */
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
}

.card:hover {
    background: #FAFAFA; /* Un pelín más claro al hover */
    transform: translate(-2px, -2px);
    box-shadow: 3px 3px 0 var(--text-ink); /* Sombra neobrutalista fina */
}

.card-title {
    font-family: var(--font-serif);
    font-size: 1.4rem;
    font-weight: 500;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    line-height: 1.3;
}

.card-title i {
    font-size: 1.2rem;
    color: var(--text-ink);
    opacity: 0;
    transform: translateX(-5px) translateY(-5px);
    transition: all 0.2s ease;
    margin-top: 2px;
}

.card:hover .card-title i {
    opacity: 1;
    transform: translateX(0) translateY(0);
}

.card-desc {
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.6;
    flex-grow: 1;
    font-weight: 300;
}

/* Note Cards */
.note-tags {
    margin-top: 1.5rem;
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Floating Dock */
.floating-dock {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-surface);
    border: 1px solid var(--text-ink); /* Borde neobrutalista */
    border-radius: 8px; 
    padding: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 4px 4px 0 var(--text-ink); /* Le da personalidad y lo separa del fondo */
    z-index: 100;
    transition: all 0.2s ease;
}

.dock-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-ink);
    width: 48px;
    height: 48px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.dock-btn i {
    font-size: 1.3rem;
}

.dock-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    border: 1px solid var(--text-ink);
}

.dock-btn.primary {
    background: var(--text-ink);
    color: var(--bg-surface);
    border: 1px solid var(--text-ink);
}

.dock-btn.primary:hover {
    background: var(--bg-surface);
    color: var(--text-ink);
}

.dock-btn .btn-label {
    display: none;
}

/* Overlays & Modals (Neo-brutalismo) */
.overlay {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(236, 236, 233, 0.85); /* bg-paper con opacidad */
    backdrop-filter: blur(5px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s ease;
}

.overlay.active {
    opacity: 1;
    pointer-events: all;
}

.modal {
    background: var(--bg-surface);
    border: 1px solid var(--text-ink);
    padding: 2.5rem;
    width: 90%;
    max-width: 500px;
    box-shadow: 6px 6px 0 var(--text-ink);
    transform: translateY(20px);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.overlay.active .modal {
    transform: translateY(0);
}

.pin-modal h2 {
    font-family: var(--font-serif);
    margin-bottom: 1rem;
}
.pin-modal p {
    color: var(--text-muted);
    margin-bottom: 2rem;
    font-size: 0.95rem;
}
.pin-modal input {
    width: 100%;
    padding: 1rem;
    font-size: 1.5rem;
    letter-spacing: 0.5em;
    text-align: center;
    border: 1px solid var(--text-ink);
    background: transparent;
    margin-bottom: 1.5rem;
    outline: none;
    font-family: monospace;
}
.pin-modal input:focus {
    box-shadow: 2px 2px 0 var(--text-ink);
    transform: translate(-1px, -1px);
}
.btn-primary {
    width: 100%;
    padding: 1rem;
    background: var(--text-ink);
    color: var(--bg-surface);
    border: 1px solid var(--text-ink);
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
}
.btn-primary:hover {
    background: var(--bg-surface);
    color: var(--text-ink);
}

/* Note Modal */
.note-modal {
    max-width: 700px;
    height: 80vh;
    display: flex;
    flex-direction: column;
    padding: 2rem;
}

.note-modal-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--border-line);
    padding-bottom: 1rem;
}

.icon-btn {
    background: transparent;
    border: 1px solid transparent;
    font-size: 1.5rem;
    color: var(--text-ink);
    cursor: pointer;
    width: 40px; height: 40px;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s ease;
}
.icon-btn:hover {
    border-color: var(--text-ink);
    background: rgba(0,0,0,0.05);
}

.note-modal-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow-y: auto;
}

.note-detail-input {
    width: 100%;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-ink);
    outline: none;
}

.note-detail-input.title {
    font-family: var(--font-serif);
    font-size: 2rem;
    font-weight: 500;
}

.note-detail-input.content {
    flex: 1;
    font-family: var(--font-sans);
    font-size: 1rem;
    line-height: 1.8;
    resize: none;
}

.note-detail-input:not([readonly]) {
    border-color: var(--border-line-strong);
    padding: 0.5rem;
    background: rgba(0,0,0,0.02);
}

.note-detail-tags {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 1rem;
}

/* Delete Mode */
.grid-container.delete-mode .note-card {
    border-color: #ef4444;
    animation: shake 0.5s infinite alternate ease-in-out;
}
@keyframes shake {
    from { transform: rotate(-0.5deg); }
    to { transform: rotate(0.5deg); }
}

.btn-delete-card {
    position: absolute;
    top: -10px; right: -10px;
    background: #ef4444;
    color: white;
    border: 1px solid var(--text-ink);
    width: 24px; height: 24px;
    border-radius: 50%;
    display: none;
    align-items: center; justify-content: center;
    cursor: pointer;
    z-index: 10;
}
.grid-container.delete-mode .btn-delete-card {
    display: flex;
}
.btn-delete-card:hover {
    transform: scale(1.1);
}

/* 100% Responsive */
@media (max-width: 768px) {
    .app-container {
        padding: 2rem 1.5rem;
    }
    
    h1 {
        font-size: 2.5rem;
    }

    .grid-container {
        grid-template-columns: 1fr; /* Una sola columna en móviles */
        gap: 1.5rem;
    }

    .card {
        padding: 1.25rem;
    }

    .view-header {
        margin-bottom: 2rem;
    }
}

@media (max-width: 480px) {
    .app-container {
        padding: 1.5rem 1rem;
    }

    h1 {
        font-size: 2rem;
    }

    .floating-dock {
        width: calc(100% - 2rem); /* Ocupa casi todo el ancho en móviles pequeños */
        justify-content: space-around;
        bottom: 1.5rem;
    }

    .dock-btn {
        width: 44px;
        height: 44px;
    }
    
    .modal {
        padding: 1.5rem;
    }
}
