/* =========================================================
   NoteSafe - Global Styles & Themes
   ========================================================= */

/* Tema Oscuro (Por defecto) */
:root {
   --bg: #020617;
    /* slate-950 */
    --bg-gradient: rgba(99, 102, 241, 0.08);
    /* indigo tint */
    --surface: #0f172a;
    /* slate-900 */
    --surface-light: #1e293b;
    /* slate-800 */
    --surface-glass: rgba(15, 23, 42, 0.88);

    --primary: #6366f1;
    /* indigo-500 */
    --primary-hover: #4f46e5;
    /* indigo-600 */
    --btn-text: #ffffff;

    --text: #f8fafc;
    /* slate-50 */
    --muted: #94a3b8;
    /* slate-400 */

    --danger: #f87171;
    --danger-bg: rgba(248, 113, 113, 0.1);
    --success: #4ade80;
    --success-bg: rgba(74, 222, 128, 0.1);

    --border: #1e293b;
    /* slate-800 */

    --radius: 16px;
    --shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
}

/* Tema Claro (Alternativo) */
[data-theme="light"] {
     --bg: #f8fafc;
    --bg-gradient: rgba(99, 102, 241, 0.05);
    --surface: #ffffff;
    --surface-light: #f1f5f9;
    --surface-glass: rgba(255, 255, 255, 0.95);

    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --btn-text: #ffffff;

    --text: #0f172a;
    --muted: #64748b;

    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.1);
    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.1);

    --border: #e2e8f0;

    --shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
}

/* =========================================================
   Reset & Base
   ========================================================= */

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

html {
    min-height: 100%;
}

body {
    min-height: 100vh;
    background: radial-gradient(circle at top right, var(--bg-gradient), transparent 35%), var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.5;
    transition: background-color 0.3s ease, color 0.3s ease;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: var(--primary-hover);
}

/* =========================================================
   Componentes: Formularios y Botones
   ========================================================= */

button,
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 10px;
    padding: 0.75rem 1.1rem;
    background: var(--primary);
    color: var(--btn-text);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
}

button:hover,
.button:hover {
    background: var(--primary-hover);
    color: #fff;
    transform: translateY(-1px);
}

.button-secondary {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--muted);
}

.button-secondary:hover {
    background: var(--surface);
    border-color: var(--surface-light);
    color: var(--text);
}

label {
    display: block;
    margin-bottom: 0.45rem;
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 600;
}

input,
textarea {
    width: 100%;
    padding: 0.8rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg);
    color: var(--text);
    font: inherit;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--bg-gradient);
}

textarea {
    min-height: 180px;
    resize: vertical;
}

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

.form-actions {
    margin-top: 1.5rem;
}

.form-actions button {
    width: 100%;
}

/* =========================================================
   Componentes: Mensajes (Alertas)
   ========================================================= */

.message {
    margin-bottom: 1.25rem;
    padding: 0.85rem 1rem;
    border-radius: 10px;
    font-size: 0.95rem;
}

.message-error {
    background: var(--danger-bg);
    border: 1px solid rgba(248, 113, 113, 0.3);
    color: var(--danger);
}

.message-success {
    background: var(--success-bg);
    border: 1px solid rgba(74, 222, 128, 0.3);
    color: var(--success);
}

/* =========================================================
   Vistas: Autenticación (Login / Register) - RESPONSIVE
   ========================================================= */

.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1rem;
}

.auth-card {
    width: 100%;
    max-width: 430px;
    padding: 2.25rem;
    background: var(--surface-glass);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    backdrop-filter: blur(12px);
}

.logo {
    margin-bottom: 0.4rem;
    color: var(--text);
    font-size: 1.8rem;
    font-weight: 800;
    letter-spacing: -0.04em;
}

.logo span {
    color: var(--primary);
}

.auth-subtitle {
    margin-bottom: 2rem;
    color: var(--muted);
}

.auth-footer {
    margin-top: 1.5rem;
    color: var(--muted);
    font-size: 0.9rem;
    text-align: center;
}

/* =========================================================
   Vistas: Dashboard
   ========================================================= */

.app-page {
    min-height: 100vh;
}

.app-header {
    width: 100%;
    border-bottom: 1px solid var(--border);
    background: rgba(15, 23, 42, 0.82);
    backdrop-filter: blur(12px);
}

.header-inner {
    width: 100%;
    max-width: 1120px;
    min-height: 72px;
    margin: 0 auto;
    padding: 0 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.header-user {
    display: flex;
    align-items: center;
    gap: 1rem;
    color: var(--muted);
    font-size: 0.9rem;
}

.logout-link {
    padding: 0.5rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--muted);
    transition: all 0.2s ease;
}

.logout-link:hover {
    color: var(--text);
    background: var(--surface);
    border-color: var(--surface-light);
}

.dashboard {
    width: 100%;
    max-width: 1120px;
    margin: 0 auto;
    padding: 3.5rem 1rem;
}

.dashboard-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 2rem;
    margin-bottom: 2.5rem;
}

.dashboard-title {
    margin-bottom: 0.35rem;
    font-size: clamp(1.8rem, 4vw, 2.5rem);
    line-height: 1.1;
    letter-spacing: -0.04em;
}

.dashboard-subtitle {
    color: var(--muted);
}

/* Notas */
.notes-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.notes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}

.note-card {
    display: flex;
    flex-direction: column;
    min-height: 230px;
    padding: 1.25rem;
    background: var(--surface-glass);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.note-card:hover {
    transform: translateY(-3px);
    background: var(--surface);
    border-color: var(--surface-light);
}

.note-title {
    margin-bottom: 0.65rem;
    font-size: 1.05rem;
    font-weight: 700;
    overflow-wrap: anywhere;
}

.note-content {
    flex: 1;
    color: var(--muted);
    font-size: 0.92rem;
    overflow-wrap: anywhere;
}

.note-date {
    margin-top: 1rem;
    color: var(--muted);
    font-size: 0.78rem;
}

.note-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.note-delete {
    padding: 0.45rem 0.7rem;
    background: transparent;
    border: 1px solid rgba(248, 113, 113, 0.3);
    color: var(--danger);
    font-size: 0.8rem;
}

.note-delete:hover {
    background: var(--danger-bg);
    border-color: var(--danger);
}


/* =========================================================
   Vues : Éditeur de notes (Create / Edit)
   ========================================================= */

.back-link {
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 600;
}

.back-link:hover {
    color: var(--text);
}

.note-editor-page {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    padding: 3.5rem 1rem;
}

.note-editor-header {
    margin-bottom: 2rem;
}

.eyebrow {
    margin-bottom: 0.4rem;
    color: var(--primary);
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.note-editor-title {
    margin-bottom: 0.4rem;
    font-size: clamp(1.8rem, 4vw, 2.5rem);
    line-height: 1.1;
    letter-spacing: -0.04em;
}

.note-editor-subtitle {
    color: var(--muted);
}

.note-form {
    padding: 1.5rem;
    background: var(--surface-glass);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.note-form textarea {
    min-height: 280px;
}

.note-form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
}


/* =========================================================
   Media Queries (Móviles y Tablets)
   ========================================================= */

@media (max-width: 600px) {

    /* Optimización del Login */
    .auth-page {
        padding: 1rem;
    }

    .auth-card {
        padding: 1.5rem;
        /* Menos padding en móviles para ganar espacio */
    }

    /* Optimización del Dashboard */
    .dashboard {
        padding: 2rem 1rem;
    }

    .dashboard-heading {
        align-items: flex-start;
        flex-direction: column;
        gap: 1rem;
    }

    .header-user span {
        display: none;
        /* Oculta texto secundario en móviles */
    }

    .note-card {
        min-height: 200px;
    }

    .note-editor-page {
        padding: 2rem 1rem;
    }

    .note-form {
        padding: 1.1rem;
    }

    .note-form-actions {
        flex-direction: column-reverse;
    }

    .note-form-actions button,
    .note-form-actions .button {
        width: 100%;
    }
}