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

:root {
    --primary-color: #4a5568;
    --secondary-color: #718096;
    --danger-color: #e53e3e;
    --bg-color: #f7fafc;
    --surface-color: #ffffff;
    --border-color: #e2e8f0;
    --text-color: #2d3748;
    --text-secondary: #718096;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
}

.screen {
    display: none;
}

.screen.active {
    display: block;
}

/* Login & Register Screens */
.login-container {
    max-width: 400px;
    margin: 100px auto;
    padding: 40px;
    background: var(--surface-color);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
}

.logo {
    text-align: center;
    margin-bottom: 30px;
    color: var(--primary-color);
}

.logo svg {
    margin-bottom: 10px;
}

.logo h1 {
    font-size: 24px;
    font-weight: 600;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-color);
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
    width: 100%;
}

.btn-primary:hover {
    background-color: #2d3748;
}

.btn-secondary {
    background-color: var(--bg-color);
    color: var(--text-color);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background-color: var(--border-color);
}

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

.btn-danger:hover {
    background-color: #c53030;
}

.btn-block {
    width: 100%;
    margin-top: 10px;
}

.form-footer {
    text-align: center;
    margin-top: 20px;
}

.form-footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-size: 14px;
}

.form-footer a:hover {
    text-decoration: underline;
}

.error-message {
    margin-top: 15px;
    padding: 12px;
    background-color: #fed7d7;
    color: #c53030;
    border-radius: 6px;
    font-size: 14px;
    display: none;
}

.error-message.show {
    display: block;
}

/* Main App */
.app-header {
    background: var(--surface-color);
    border-bottom: 1px solid var(--border-color);
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow);
}

.header-left h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-color);
}

.header-right {
    display: flex;
    gap: 12px;
    align-items: center;
}

.user-badge {
    padding: 6px 12px;
    background-color: var(--bg-color);
    border-radius: 6px;
    font-size: 14px;
    color: var(--text-secondary);
}

.app-container {
    display: flex;
    height: calc(100vh - 65px);
}

.sidebar {
    width: 320px;
    background: var(--surface-color);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.search-box {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.date-input {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
}

.entries-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.entry-item {
    padding: 12px;
    margin-bottom: 8px;
    background: var(--bg-color);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
}

.entry-item:hover {
    background: var(--border-color);
}

.entry-item.active {
    border-color: var(--primary-color);
    background: #edf2f7;
}

.entry-item-date {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-color);
    margin-bottom: 4px;
}

.entry-item-preview {
    font-size: 13px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.loading {
    text-align: center;
    padding: 20px;
    color: var(--text-secondary);
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--surface-color);
}

.empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}

.empty-state svg {
    margin-bottom: 20px;
    opacity: 0.5;
}

.empty-state p {
    font-size: 16px;
}

.entry-editor {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 24px;
}

.editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.editor-header-top {
    display: flex;
    gap: 10px;
    align-items: center;
    flex: 1;
}

.entry-date-input {
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 16px;
    font-weight: 600;
}

.editor-actions {
    display: flex;
    gap: 10px;
}

.entry-textarea {
    flex: 1;
    padding: 16px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 15px;
    font-family: inherit;
    line-height: 1.8;
    resize: none;
    outline: none;
}

.entry-textarea:focus {
    border-color: var(--primary-color);
}

.editor-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
    font-size: 13px;
    color: var(--text-secondary);
}

#save-status {
    color: #48bb78;
}

/* Text justify */
.entry-textarea {
    text-align: justify;
}

/* Botón de bloqueo */
.btn-lock {
    background: var(--secondary-color);
    color: white;
}

.btn-lock:hover {
    background: var(--primary-color);
}

.btn-lock.locked {
    background: #f59e0b;
}

.btn-lock.locked:hover {
    background: #d97706;
}

.btn-lock:disabled,
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.entry-textarea:disabled,
.entry-date-input:disabled {
    background: #f5f5f5;
    cursor: not-allowed;
    opacity: 0.7;
}

/* Badges en lista de entradas */
.entry-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.25rem;
}

.entry-item-badges {
    display: flex;
    gap: 0.25rem;
    align-items: center;
}

.entry-item-icon,
.entry-item-lock {
    font-size: 0.9rem;
}

/* Botón nueva entrada móvil - oculto por defecto */
.btn-new-mobile {
    display: none;
}

/* Selector de iconos */
.icon-selector {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 12px;
    background: var(--bg-color);
    border-radius: 6px;
    margin-bottom: 16px;
    border: 1px solid var(--border-color);
}

.icon-selector-label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.icon-btn {
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: white;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}

.icon-btn:hover {
    background: var(--bg-color);
    border-color: var(--primary-color);
}

.icon-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* ===========================
   RESPONSIVE - MÓVIL ULTRA MINIMALISTA
   =========================== */

@media (max-width: 768px) {
    /* Reset general para evitar desbordamiento */
    * {
        box-sizing: border-box;
    }

    body {
        overflow-x: hidden;
        margin: 0;
        padding: 0;
    }

    /* Header ultra compacto */
    .app-header {
        padding: 0.4rem 0.5rem;
        min-height: auto;
    }

    .header-left h2 {
        font-size: 0.9rem;
        margin: 0;
    }

    .user-badge {
        display: none;
    }

    .header-right {
        gap: 0.3rem;
    }

    /* Ocultar botones de importar y exportar en móvil */
    #import-btn,
    #export-btn {
        display: none;
    }

    .btn {
        padding: 0.3rem 0.5rem;
        font-size: 0.7rem;
        white-space: nowrap;
    }

    /* Container principal - mantener horizontal */
    .app-container {
        flex-direction: row;
        height: calc(100vh - 45px);
        overflow: hidden;
        width: 100vw;
    }

    /* Sidebar más ancho en móvil */
    .sidebar {
        width: 90px;
        min-width: 90px;
        max-width: 90px;
        border-right: 1px solid var(--border-color);
        border-left: none;
        overflow-y: auto;
        overflow-x: hidden;
        order: 1;
        display: flex;
        flex-direction: column;
    }

    /* Botón nueva entrada móvil */
    .btn-new-mobile {
        display: block;
        width: 100%;
        padding: 0.8rem;
        background: var(--primary-color);
        color: white;
        border: none;
        font-size: 1.8rem;
        font-weight: bold;
        cursor: pointer;
        border-bottom: 1px solid var(--border-color);
        flex-shrink: 0;
        transition: background 0.2s;
    }

    .btn-new-mobile:hover {
        background: var(--secondary-color);
    }

    .search-box {
        padding: 0.3rem;
        display: none; /* Ocultar búsqueda por fecha en móvil */
    }

    .date-input {
        display: none;
    }

    #new-entry-btn {
        display: none; /* Ocultar botón desktop en móvil */
    }

    .entries-list {
        padding: 0.2rem;
        flex: 1;
        overflow-y: auto;
    }

    .entry-item {
        padding: 0.3rem;
        margin-bottom: 0.3rem;
        border-radius: 4px;
        writing-mode: horizontal-tb;
    }

    .entry-item-header {
        flex-direction: column;
        align-items: center;
        gap: 0.2rem;
    }

    .entry-item-date {
        font-size: 0.6rem;
        text-align: center;
        line-height: 1.2;
        word-break: break-word;
        width: 100%;
    }

    .entry-item-badges {
        flex-direction: row;
        gap: 0.1rem;
        font-size: 0.8rem;
    }

    .entry-item-icon,
    .entry-item-lock {
        font-size: 0.8rem;
    }

    .entry-item-preview {
        display: none;
    }

    /* Editor ocupa el resto del espacio */
    .main-content {
        flex: 1;
        width: auto;
        overflow: hidden;
        display: flex;
        flex-direction: column;
        height: auto;
        order: 2;
    }

    .entry-editor {
        padding: 0.5rem;
        width: 100%;
        height: 100%;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    /* Header del editor compacto - reorganizado */
    .editor-header {
        display: flex;
        flex-direction: column;
        gap: 0.4rem;
        margin-bottom: 0.5rem;
        flex-shrink: 0;
    }

    .editor-header-top {
        display: flex;
        gap: 0.3rem;
        align-items: center;
    }

    .entry-date-input {
        width: 100%;
        padding: 0.5rem;
        font-size: 0.85rem;
    }

    .editor-actions {
        display: flex;
        gap: 0.3rem;
    }

    .btn-lock {
        padding: 0.4rem 0.6rem;
        font-size: 0.85rem;
    }

    .btn-primary,
    .btn-danger {
        padding: 0.4rem 0.6rem;
        font-size: 0.85rem;
    }

    /* Selector de iconos compacto en móvil */
    .icon-selector {
        padding: 0.5rem;
        gap: 0.4rem;
        margin-bottom: 0.5rem;
        flex-wrap: wrap;
    }

    .icon-selector-label {
        font-size: 0.75rem;
    }

    .icon-btn {
        padding: 0.4rem 0.6rem;
        font-size: 0.85rem;
    }

    /* Textarea ocupa TODO el espacio - texto más pequeño */
    .entry-textarea {
        flex: 1;
        font-size: 0.9rem;
        line-height: 1.5;
        padding: 0.6rem;
        width: 100%;
        height: 100%;
        resize: none;
        min-height: 0;
    }

    /* Footer compacto */
    .editor-footer {
        padding: 0.4rem 0;
        margin-top: 0.4rem;
        font-size: 0.7rem;
        flex-shrink: 0;
    }

    /* Empty state */
    .empty-state {
        padding: 1rem;
    }

    .empty-state svg {
        width: 60px;
        height: 60px;
        margin-bottom: 0.5rem;
    }

    .empty-state p {
        font-size: 0.85rem;
    }

    /* Login screens */
    .login-container {
        margin: 2rem auto;
        padding: 1.5rem;
        max-width: 90%;
    }

    .logo h1 {
        font-size: 1.2rem;
    }

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

    .form-group input {
        padding: 0.7rem;
        font-size: 0.9rem;
    }
}

/* Móvil muy pequeño */
@media (max-width: 480px) {
    .app-header {
        padding: 0.3rem 0.4rem;
    }

    .header-left h2 {
        font-size: 0.8rem;
    }

    .btn {
        padding: 0.25rem 0.4rem;
        font-size: 0.65rem;
    }

    .entry-textarea {
        font-size: 0.95rem;
        line-height: 1.5;
        padding: 0.5rem;
    }

    .icon-btn {
        font-size: 0.65rem;
        padding: 0.25rem 0.4rem;
    }
}

/* Landscape móvil */
@media (max-width: 768px) and (orientation: landscape) {
    .app-header {
        padding: 0.2rem 0.4rem;
    }

    .sidebar.show {
        max-height: 30vh;
    }

    .icon-selector {
        padding: 0.3rem;
        margin-bottom: 0.3rem;
    }

    .editor-header {
        margin-bottom: 0.3rem;
    }

    .editor-footer {
        padding: 0.2rem 0;
        margin-top: 0.2rem;
    }
}

