/* --- Variables de color de Google Keep --- */
:root {
    --bg-color: #ffffff;
    --border-color: #e0e0e0;
    --text-main: #202124;
    --text-sec: #5f6368;
    --shadow: 0 1px 2px 0 rgba(60,64,67,0.3), 0 1px 3px 1px rgba(60,64,67,0.15);
    --shadow-hover: 0 1px 3px 0 rgba(60,64,67,0.3), 0 4px 8px 3px rgba(60,64,67,0.15);
    --bg-hover: #f1f3f4;
}

/* --- Estilos Base --- */
* {
    box-sizing: border-box;
}

body {
    font-family: 'Roboto', 'Segoe UI', Tahoma, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    margin: 0;
    padding: 0;
    line-height: 1.5;
}

/* --- Barra Superior (Navbar) --- */
.navbar {
    display: flex;
    align-items: center;
    padding: 8px 16px; /* Ajuste responsive */
    border-bottom: 1px solid var(--border-color);
    height: 64px;
    position: sticky;
    top: 0;
    background: white;
    z-index: 100;
}

.logo {
    display: flex;
    align-items: center;
    min-width: fit-content;
}

.logo img {
    width: 40px;
    height: 40px;
}

.logo h1 {
    font-size: 22px;
    font-weight: 400;
    margin-left: 10px;
    color: var(--text-sec);
}

.search-bar {
    flex-grow: 1;
    max-width: 720px;
    margin-left: 20px;
}

.search-bar input {
    width: 100%;
    padding: 12px 20px;
    border: none;
    background: var(--bg-hover);
    border-radius: 8px;
    font-size: 16px;
    outline: none;
    transition: background 0.2s, box-shadow 0.2s;
}

.search-bar input:focus {
    background: white;
    box-shadow: 0 1px 1px rgba(0,0,0,0.2);
}

/* --- Contenedor Principal --- */
main {
    padding: 0 16px;
    max-width: 1200px;
    margin: 0 auto;
}

/* --- Creador de Notas --- */
.create-note-container {
    display: flex;
    justify-content: center;
    margin: 32px auto;
    width: 100%;
    max-width: 600px;
}

.create-note-box {
    width: 100%;
    box-shadow: var(--shadow);
    border-radius: 8px;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    background: white;
}

.create-note-box input, 
.create-note-box textarea {
    border: none;
    outline: none;
    width: 100%;
    font-family: inherit;
    font-size: 16px;
    resize: none;
    background: transparent;
}

.create-note-box input {
    font-weight: 500;
    margin-bottom: 12px;
    color: var(--text-main);
}

.hidden { 
    display: none !important; 
}

/* --- Botones del Formulario --- */
.form-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 12px;
}

#save-btn {
    background-color: transparent;
    border: none;
    color: var(--text-main);
    padding: 8px 24px;
    border-radius: 4px;
    font-weight: 500;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
}

#save-btn:hover { 
    background-color: var(--bg-hover); 
}

/* --- Cuadrícula de Notas (Responsive) --- */
.notes-grid {
    display: grid;
    /* auto-fill permite que las notas se ajusten solas al ancho disponible */
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 16px;
    padding: 20px 0;
    width: 100%;
}

.note-card {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
    transition: box-shadow 0.2s, transform 0.1s;
    background: white;
    word-wrap: break-word;
    position: relative;
    display: flex;
    flex-direction: column;
}

.note-card:hover {
    box-shadow: var(--shadow-hover);
}

.note-card h3 {
    margin: 0 0 8px 0;
    font-size: 17px;
    font-weight: 500;
}

.note-card p {
    font-size: 14px;
    color: var(--text-main);
    white-space: pre-wrap;
    margin: 0;
    flex-grow: 1;
}

/* --- Footer de la Nota (Borrado) --- */
.note-footer {
    display: flex;
    justify-content: flex-end;
    margin-top: 12px;
    opacity: 0;
    transition: opacity 0.2s;
}

.note-card:hover .note-footer {
    opacity: 1;
}

.delete-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    padding: 6px;
    border-radius: 50%;
    color: var(--text-sec);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.delete-btn:hover {
    background-color: rgba(0,0,0,0.08);
    color: #d93025; /* Un rojo sutil al pasar el mouse */
}

/* --- Ajustes para Móvil (Media Queries) --- */
@media (max-width: 600px) {
    .navbar {
        padding: 8px 12px;
    }

    .logo h1 {
        display: none; /* Escondemos el nombre para ganar espacio */
    }

    .search-bar {
        margin-left: 10px;
    }

    .create-note-container {
        margin: 16px auto;
        padding: 0 8px;
    }

    .notes-grid {
        grid-template-columns: 1fr; /* Una sola columna en teléfonos muy pequeños */
        gap: 12px;
    }
}

@media (min-width: 601px) and (max-width: 900px) {
    .notes-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    }
}

.placeholder-view {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: text;
    color: var(--text-sec);
    padding: 4px 0;
}

.add-btn-trigger {
    background-color: #fbbc04; /* Color amarillo Keep */
    color: white;
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, background-color 0.2s;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.add-btn-trigger:hover {
    background-color: #f5af00;
    transform: scale(1.1);
}

/* Ajuste para que el input de título no se vea mal al expandir */
#new-title {
    margin-top: 5px;
}

#save-btn {
    background-color: transparent;
    color: var(--text-main);
    border: none;
    padding: 8px 24px;
    border-radius: 4px;
    font-weight: 500;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
}

#save-btn:hover {
    background-color: rgba(95, 99, 104, 0.1); /* Gris muy suave */
}

.search-bar input:focus {
    background-color: white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    outline: none;
}

.notes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 16px;
    padding: 16px;
    /* Aseguramos que el flujo sea el estándar de arriba hacia abajo */
    grid-auto-flow: row; 
}

@media (max-width: 600px) {
    .notes-grid {
        /* En móvil, forzamos una sola columna para que el orden sea clarísimo */
        grid-template-columns: 1fr;
    }
}