@media screen and (max-width: 768px) {
    /* Ajustes de la Barra Superior */
    .top-bar {
        padding: 5px 10px;
        height: auto;
        flex-wrap: nowrap;
        align-items: center;
    }

    .menu-toggle {
        display: flex;
        padding: 5px;
    }

    .menu-toggle:hover {
        background-color: #e0e0e0;
        color: #007bff;
        transition: background-color 0.2s ease, color 0.2s ease;
    }

    .nombre-local {
        flex: 0;
        font-size: 16px;
        margin-right: 150px;
        white-space: nowrap;
    }
    
    .barra-busqueda {
        flex: 1;
        padding: 0;
    }

    .search-bar {
        max-width: 80%;
        width: 100%;
        padding: 5px;
        font-size: 14px;
    }

    .iconos-contacto {
        flex: 0;
        gap: 0px;
        align-items: center;
    }

    .icono-ws {
        font-size: 0;
    }

    .icono-ws i {
        font-size: 18px;
        color: black;
    }

    .editor-toggle {
        display: flex !important;
        padding: 5px;
    }

    .editor-toggle:hover {
        background-color: #e0e0e0;
        color: #007bff;
        transition: background-color 0.2s ease, color 0.2s ease;
    }

    .editor-toggle i {
        font-size: 18px;
    }

    .editor-toggle i:hover {
        color: #007bff;
        transition: color 0.2s ease;
    }

    .theme-icon {
        font-size: 18px;
    }

    .theme-icon:hover {
        color: #007bff;
        transform: scale(1.1);
        transition: color 0.2s ease, transform 0.2s ease;
    }
    
    .icono-ubicacion i {
        font-size: 0px;
    }
    
    .icono-ubicacion {
        font-size: 0px;
    }

    /* Menú de Navegación */
    .nav-container {
        display: none;
        position: fixed;
        left: 0;
        width: 100%;
        background-color: var(--nav-bg);
        z-index: 29;
        box-shadow: 0 2px 4px var(--cv-shadow);
    }

    .nav-container.active {
        display: block;
        width: 33%;
    }

    .nav-bar {
        height: auto;
        padding: 10px 0;
    }

    .nav-bar ul {
        flex-direction: column;
        gap: 0px;
        margin-top: 16%;
    }

    .nav-bar li {
        width: 100%;
        text-align: left;
    }

    .nav-bar a {
        padding: 10px;
        font-size: 16px;
        border-radius: 0;
        display: block; /* Aseguramos que el enlace ocupe todo el espacio */
        transition: background-color 0.2s ease, color 0.2s ease; /* Transición suave para hover */
        justify-content: left;
    }

    /* Hover para modo claro */
    .nav-bar a:hover {
        background-color: #e8e8e8; /* Fondo gris claro */
        color: #007bff; /* Texto azul */
    }

    /* Contenedor Principal */
    .main-container {
        height: calc(100vh - 52px);
        margin: 0;
        padding: 0;
        box-sizing: border-box;
        display: flex;
        flex-direction: column;
    }

    /* Sidebar (Editor de CV) - Barra horizontal optimizada */
    .sidebar {
        position: fixed;
        top: -250px;
        left: 0;
        width: 100%;
        height: 250px;
        z-index: 30;
        background-color: var(--sidebar-bg);
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
        transition: top 0.3s ease;
        overflow-y: auto;
        padding: 8px;
        box-sizing: border-box;
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    .sidebar.open {
        top: 40px;
        width: 80%;
        position: fixed;
        display: flex;
        left: 10%;
    }

    .close-sidebar {
        display: flex;
        position: absolute;
        top: 8px;
        right: 8px;
        font-size: 16px;
        cursor: pointer;
        color: #333;
    }

    .close-sidebar:hover {
        color: #ff4444;
        transition: color 0.2s ease;
    }

    /* Estilo del título del editor */
    /* .sidebar::before {
        content: "Editor de CV";
        display: block;
        font-size: 14px;
        font-weight: 600;
        color: #333;
        margin-bottom: 4px;
        border-bottom: 1px solid #ddd;
        padding-bottom: 4px;
    } */

    /* H3 */
    .sidebar-header h3 {
        margin: 0;
        font-size: 18px;
        color: var(--primary-color);
        transition: color 0.3s ease;
        margin: auto;
    }

    /* Botones de alternancia (Fondo/Texto) */
    .sidebar .toggle-section {
        padding: 6px 10px;
        font-size: 12px;
        border-radius: 4px;
        background-color: #e0e0e0;
        color: #333;
        border: none;
        cursor: pointer;
        flex: 1;
        transition: background-color 0.2s ease, color 0.2s ease;
    }

    .sidebar .toggle-section:hover {
        background-color: #d0d0d0;
    }

    .sidebar .toggle-section.active {
        background-color: var(--accent-color);
        color: var(--button-text);
    }

    /* Contenedor para los botones de Fondo/Texto */
    .sidebar .toggle-buttons {
        display: flex;
        gap: 8px;
        margin-bottom: 8px;
    }

    /* Sección Fondo (Color Picker) */
    .sidebar .color-picker {
        padding: 8px;
        background-color: #f5f5f5;
        border-radius: 4px;
        display: none;
    }

    .sidebar .color-picker[style*="display: block"] {
        display: block;
    }

    .sidebar .color-picker label {
        font-size: 12px;
        color: #333;
        display: block;
        margin-bottom: 4px;
    }

    .sidebar .color-picker input[type="color"],
    .sidebar .color-picker input[type="range"] {
        height: 40px;
        width: 100%;
        margin-bottom: 4px;
    }

    .sidebar #opacity-value {
        font-size: 12px;
        color: #555;
    }

    /* Sección Texto */
    .sidebar .format-toolbar {
        padding: 8px;
        background-color: #f5f5f5;
        border-radius: 4px;
        display: none;
        flex-direction: column;
        gap: 8px;
    }

    .sidebar .format-toolbar[style*="display: block"] {
        display: flex;
    }

    /* Controles de formato (negrita, cursiva, etc.) */
    .sidebar .format-controls {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
        align-items: center;
    }

    .sidebar .format-btn {
        padding: 6px;
        font-size: 12px;
        border-radius: 4px;
        background-color: #e0e0e0;
        color: #333;
        border: none;
        cursor: pointer;
        min-width: 30px;
        text-align: center;
        transition: background-color 0.2s ease, color 0.2s ease;
    }

    .sidebar .format-btn:hover {
        background-color: #d0d0d0;
    }

    .sidebar .format-btn.active {
        background-color: var(--accent-color);
        color: var(--button-text);
    }

    .sidebar #increase-font-size,
    .sidebar #decrease-font-size {
        padding: 6px;
        font-size: 12px;
        border-radius: 4px;
        background-color: #e0e0e0;
        color: #333;
        border: none;
        cursor: pointer;
        min-width: 30px;
        transition: background-color 0.2s ease, color 0.2s ease;
    }

    .sidebar #increase-font-size:hover,
    .sidebar #decrease-font-size:hover {
        background-color: #d0d0d0;
    }

    .sidebar #font-size-display {
        font-size: 12px;
        color: #555;
        margin: 0 6px;
    }

    .sidebar .format-font,
    .sidebar .format-color {
        height: 24px;
        font-size: 12px;
        border-radius: 4px;
        border: 1px solid #ddd;
        padding: 2px;
    }

    /* Acordeón para botones de añadir elementos */
    .sidebar .add-elements {
        display: flex;
        flex-direction: column;
        gap: 4px;
    }

    .sidebar .add-section {
        border: 1px solid #ddd;
        border-radius: 4px;
    }

    .sidebar .add-section-header {
        padding: 6px 10px;
        font-size: 12px;
        font-weight: 600;
        color: #333;
        background-color: #e8e8e8;
        cursor: pointer;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .sidebar .add-section-header:hover {
        background-color: #d8d8d8;
        transition: background-color 0.2s ease;
    }

    .sidebar .add-section-header::after {
        content: "▼";
        font-size: 10px;
    }

    .sidebar .add-section-header.active::after {
        content: "▲";
    }

    .sidebar .add-section-content {
        display: none;
        padding: 6px 10px;
        background-color: #fafafa;
    }

    .sidebar .add-section-content.active {
        display: block;
    }

    .sidebar .add-section-content button {
        padding: 4px 8px;
        font-size: 11px;
        border-radius: 4px;
        background-color: #007bff;
        color: #fff;
        border: none;
        cursor: pointer;
        margin: 2px;
        display: inline-block;
        transition: background-color 0.2s ease;
    }

    .sidebar .add-section-content button:hover {
        background-color: #0056b3;
    }

    /* Contenedor del Contenido */
    .content-wrapper {
        margin-left: 0;
        width: 100%;
        height: 100%;
        overflow: auto;
        box-sizing: border-box;
        display: flex;
        justify-content: center;
        align-items: flex-start;
        transition: margin-top 0.3s ease;
        margin-top: 52px;
    }

    .sidebar.active ~ .content-wrapper {
        margin-top: 202px;
    }

    .cv-wrapper {
        padding: 0;
        margin: -5% -5%;
        box-sizing: border-box;
        display: flex;
        justify-content: row;
        align-items: flex-start;
    }

    .cv-container {
        width: 210mm;
        height: 297mm;
        margin: 10px;
        padding: 0;
        transition: transform 0.1s ease-out;
        box-sizing: border-box;
        box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
        transform-origin: top left;
        transform: scale(calc(100vw / 210mm));
    }

    .page {
        width: 210mm;
        height: 297mm;
        padding: 10mm 15mm;
        box-shadow: none;
        margin: 0;
        box-sizing: border-box;
        overflow: hidden;
    }

    .page .header h1 {
        font-size: 28pt;
        margin: 0 0 20px 0;
        padding: 10px;
    }

    .page .header h2 {
        font-size: 18pt;
        margin-top: 40px;
    }

    .photo-container {
        width: 40mm;
        height: 50mm;
    }

    .photo-placeholder {
        font-size: 12px;
    }

    .personal-info-grid {
        flex-direction: row;
    }

    .info-column {
        width: 50%;
    }

    .info-item .editable {
        width: 100%;
        white-space: normal;
        overflow: visible;
        text-overflow: clip;
        font-size: 16px;
    }

    .section-header h2 {
        font-size: 18px;
    }

    #education-table th,
    #education-table td,
    #experience-table th,
    #experience-table td {
        padding: 5px 10px;
        font-size: 14px;
    }

    #education-table th:nth-child(1),
    #education-table td:nth-child(1) {
        width: 20%;
    }

    #education-table th:nth-child(2),
    #education-table td:nth-child(2) {
        width: 25%;
    }

    #education-table th:nth-child(3),
    #education-table td:nth-child(3) {
        width: 55%;
    }

    #experience-table th:nth-child(1),
    #experience-table td:nth-child(1) {
        width: 40%;
    }

    #experience-table th:nth-child(2),
    #experience-table td:nth-child(2) {
        width: 30%;
    }

    #experience-table th:nth-child(3),
    #experience-table td:nth-child(3) {
        width: 30%;
    }

    .skills-list li {
        font-size: 16px;
        padding-left: 20px;
    }

    .reference-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .reference-item {
        padding: 10px;
    }

    .editable-wrapper .editable {
        font-size: 16px;
    }

    .page-controls {
        width: 100%;
        left: 0;
        top: auto;
        bottom: 0;
        transform: none;
        background: rgba(255, 255, 255, 0.9);
        padding: 8px;
        box-sizing: border-box;
        z-index: 100;
        box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.1);
    }

    .page-controls #prev-page,
    .page-controls #next-page {
        margin: 0 10px;
        padding: 8px 15px;
        font-size: 12px;
    }

    .page-controls #prev-page:hover,
    .page-controls #next-page:hover {
        background-color: #007bff;
        color: #ffffff;
        transition: background-color 0.2s ease, color 0.2s ease;
    }

    /* Reset completo */
    body, html {
        margin: 0;
        padding: 0;
        overflow-x: hidden;
        -webkit-text-size-adjust: none;
    }

    /* Contenedor principal estilo Canvas */
    .cv-container {
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        transform: none !important;
        margin: 50px 0 0px !important;
        transition: transform 0.1s ease-out !important;
        padding: 0px !important;
        box-shadow: none !important;
        font-family: 'Roboto', sans-serif !important;
    }

    /* Header estilo profesional */
    .header {
        display: flex !important;
        flex-direction: column, row !important;
        align-items: center !important;
        text-align: center !important;
        margin-bottom: 20px !important;
    }

    .title-container h1 {
        font-size: 1.8rem !important;
        font-weight: 700 !important;
        margin: 0 0 5px 0 !important;
        color: #333 !important;
    }

    .title-container h2 {
        font-size: 1.2rem !important;
        font-weight: 400 !important;
        margin: 0 !important;
        color: #666 !important;
    }

    .photo-container {
        width: 100px !important;
        height: 120px !important;
        margin: 0 auto 15px !important;
        border: 2px solid #eee !important;
        border-radius: 2px !important;
    }

    /* Secciones estilo Canvas */
    .section-wrapper {
        margin-bottom: 25px !important;
        break-inside: avoid;
    }

    .section-header h2 {
        font-size: 1.1rem !important;
        font-weight: 600 !important;
        margin: 0 0 10px 0 !important;
        padding-bottom: 5px !important;
        border-bottom: 2px solid #eee !important;
        color: #444 !important;
    }

    /* Experiencia laboral */
    #experience-table {
        width: 100% !important;
        border-collapse: collapse !important;
    }

    #experience-table tr {
        margin-bottom: 15px !important;
        display: block !important;
    }

    #experience-table td {
        padding: 5px 0 !important;
        vertical-align: top !important;
        font-size: 0.9rem !important;
    }

    /* Formación académica */
    #education-table {
        width: 100% !important;
    }

    #education-table td {
        padding: 4px 0 !important;
        font-size: 0.9rem !important;
    }

    /* Listas de habilidades */
    .skills-list {
        columns: 2 !important;
        column-gap: 20px !important;
        padding-left: 20px !important;
    }

    .skills-list li {
        font-size: 0.85rem !important;
        margin-bottom: 5px !important;
        break-inside: avoid;
    }

    /* Controles de navegación */
    .page-controls {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        width: 100% !important;
        padding: 12px !important;
        background: white !important;
        z-index: 100 !important;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
        display: flex !important;
        justify-content: space-between !important;
    }

    /* Top bar ajustada */
    .top-bar {
        position: fixed !important;
        top: 0 !important;
        z-index: 1000 !important;
        width: 100% !important;
        background: white !important;
        box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    }

    /* Espacio para la top bar */
    .content-wrapper {
        margin-top: 5% !important;
    }

    /* Elementos editables */
    .editable {
        min-height: 1.2em !important;
        line-height: 1.4 !important;
        padding: 2px 4px !important;
        margin: 2px 0 !important;
    }

    /* Modo Oscuro */
    [data-theme="dark"] .cv-container {
        background: #1a1a1a !important;
        color: #e0e0e0 !important;
    }

    [data-theme="dark"] .page {
        background: #1a1a1a !important;
        color: #e0e0e0 !important;
    }

    [data-theme="dark"] .cv-container .editable,
    [data-theme="dark"] .cv-container .editable-wrapper .editable,
    [data-theme="dark"] .cv-container .info-item .editable {
        color: #e0e0e0 !important;
    }

    [data-theme="dark"] .cv-container .header .title-container h1 {
        color: #ffffff !important;
    }

    [data-theme="dark"] .cv-container .header .title-container h2 {
        color: #cccccc !important;
    }

    [data-theme="dark"] .cv-container .section-header h2 {
        color: #ffffff !important;
        border-bottom: 2px solid #666 !important;
    }

    [data-theme="dark"] .cv-container #education-table th,
    [data-theme="dark"] .cv-container #education-table td,
    [data-theme="dark"] .cv-container #experience-table th,
    [data-theme="dark"] .cv-container #experience-table td {
        color: #e0e0e0 !important;
    }

    [data-theme="dark"] .cv-container .photo-container {
        border: 2px solid #666 !important;
    }

    [data-theme="dark"] .cv-container .skills-list li {
        color: #e0e0e0 !important;
    }

    [data-theme="dark"] .cv-container .reference-item {
        color: #e0e0e0 !important;
    }

    [data-theme="dark"] .page-controls {
        background: #333 !important;
        box-shadow: 0 -2px 10px rgba(255, 255, 255, 0.1) !important;
    }

    [data-theme="dark"] .page-controls #prev-page,
    [data-theme="dark"] .page-controls #next-page {
        color: #ffffff !important;
        background: #555 !important;
    }

    [data-theme="dark"] .page-controls #prev-page:hover,
    [data-theme="dark"] .page-controls #next-page:hover {
        background-color: #66b0ff;
        color: #ffffff;
    }

    [data-theme="dark"] .cv-container .photo-placeholder {
        color: #cccccc !important;
    }

    /* Modo Oscuro para la Top Bar */
    [data-theme="dark"] .top-bar {
        background: #333 !important;
        box-shadow: 0 2px 5px rgba(255, 255, 255, 0.1) !important;
    }

    [data-theme="dark"] .top-bar .nombre-local {
        color: #ffffff !important;
    }

    [data-theme="dark"] .top-bar .icono-ws i {
        color: #ffffff !important;
    }

    [data-theme="dark"] .top-bar .editor-toggle i {
        color: #ffffff !important;
    }

    [data-theme="dark"] .top-bar .editor-toggle i:hover {
        color: #66b0ff;
    }

    [data-theme="dark"] .top-bar .theme-icon {
        color: #ffffff !important;
    }

    [data-theme="dark"] .top-bar .theme-icon:hover {
        color: #66b0ff;
    }

    [data-theme="dark"] .top-bar .search-bar {
        background: #444 !important;
        color: #e0e0e0 !important;
        border: 1px solid #666 !important;
    }

    [data-theme="dark"] .menu-toggle:hover {
        background-color: #555;
        color: #66b0ff;
    }

    /* Modificado: Hover para nav-bar a en modo oscuro */
    [data-theme="dark"] .nav-bar a:hover {
        background-color: #555; /* Fondo gris oscuro */
        color: #66b0ff; /* Texto azul claro */
    }

    [data-theme="dark"] .editor-toggle:hover {
        background-color: #555;
        color: #66b0ff;
    }

    /* Modo Oscuro para el Editor (Sidebar) */
    [data-theme="dark"] .sidebar {
        background: #333 !important;
        box-shadow: 0 2px 5px rgba(255, 255, 255, 0.1) !important;
    }

    [data-theme="dark"] .sidebar::before {
        color: #e0e0e0;
        border-bottom: 1px solid #666;
    }

    [data-theme="dark"] .sidebar .toggle-section {
        background: #555 !important;
        color: #ffffff !important;
    }

    [data-theme="dark"] .sidebar .toggle-section:hover {
        background: #666 !important;
    }

    [data-theme="dark"] .sidebar .format-btn,
    [data-theme="dark"] .sidebar #increase-font-size,
    [data-theme="dark"] .sidebar #decrease-font-size {
        background: #555 !important;
        color: #ffffff !important;
    }

    [data-theme="dark"] .sidebar .format-btn:hover,
    [data-theme="dark"] .sidebar #increase-font-size:hover,
    [data-theme="dark"] .sidebar #decrease-font-size:hover {
        background: #666 !important;
    }

    [data-theme="dark"] .sidebar .format-font,
    [data-theme="dark"] .sidebar .format-color {
        background: #444 !important;
        color: #ffffff !important;
        border: 1px solid #666 !important;
    }

    [data-theme="dark"] .sidebar .color-picker,
    [data-theme="dark"] .sidebar .format-toolbar {
        background: #444 !important;
    }

    [data-theme="dark"] .sidebar .color-picker label,
    [data-theme="dark"] .sidebar #font-size-display,
    [data-theme="dark"] .sidebar #opacity-value {
        color: #e0e0e0 !important;
    }

    [data-theme="dark"] .sidebar .close-sidebar {
        color: #ffffff !important;
    }

    [data-theme="dark"] .sidebar .close-sidebar:hover {
        color: #ff6666;
    }

    [data-theme="dark"] .sidebar .add-section {
        border: 1px solid #666 !important;
    }

    [data-theme="dark"] .sidebar .add-section-header {
        background: #555 !important;
        color: #e0e0e0 !important;
    }

    [data-theme="dark"] .sidebar .add-section-header:hover {
        background-color: #666;
    }

    [data-theme="dark"] .sidebar .add-section-content {
        background: #4a4a4a !important;
    }
}