/* Estilos responsive para el Planificador de Feria */

/* Mobile sidebar styles */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: -250px; /* Hide sidebar */
        width: 250px;
        height: 100vh;
        transition: left 0.3s ease;
        z-index: 9999; /* Very high z-index to ensure visibility */
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(10px);
        overflow-y: auto; /* Enable scroll in sidebar */
    }

    .sidebar.open {
        left: 0 !important;
        transform: translateX(0) !important;
    }

    body.dark-mode .sidebar {
        background: rgba(45, 52, 54, 0.95);
    }

    .main-content {
        margin-left: 0;
        transition: margin-left 0.3s ease;
        width: 100%;
        overflow-x: hidden; /* Prevent horizontal scroll */
    }

    .main-content.sidebar-open {
        margin-left: 0; /* Don't shift content on mobile */
    }

    .sidebar-toggle {
        position: fixed;
        top: 15px;
        left: 15px;
        background: var(--primary);
        color: white;
        padding: 12px;
        border-radius: 50%;
        cursor: pointer;
        z-index: 10000; /* Highest z-index to ensure visibility */
        display: block !important;
        width: 45px;
        height: 45px;
        border: none;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    }

    .sidebar-toggle:hover {
        transform: scale(1.1);
    }

    /* Overlay when sidebar is open */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 9998; /* Just below sidebar */
        backdrop-filter: blur(2px);
    }

    .sidebar-overlay.show {
        display: block;
        animation: fadeIn 0.3s ease;
    }

    @keyframes fadeIn {
        from { opacity: 0; }
        to { opacity: 1; }
    }

    /* Fix scroll issues */
    .container {
        overflow-x: hidden;
        position: relative;
    }

    .tasks-container {
        overflow: visible;
    }

    .task-list {
        overflow: visible;
    }
}

@media (min-width: 769px) {
    .sidebar-toggle {
        display: none;
    }
}

/* Ensure sidebar toggle is always visible on mobile */
@media (max-width: 768px) {
    .sidebar-toggle {
        display: block !important;
        position: fixed;
        top: 15px;
        left: 15px;
        z-index: 10000;
        background: var(--primary);
        color: white;
        border: none;
        border-radius: 50%;
        width: 45px;
        height: 45px;
        cursor: pointer;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
        font-size: 1.2rem;
    }
}

/* Force sidebar toggle visibility on all screen sizes for testing */
.sidebar-toggle {
    display: block !important;
    z-index: 10000 !important;
}

/* Debug: Ensure sidebar is visible */
.sidebar {
    z-index: 9999 !important;
}

/* Debug: Make sidebar toggle more visible */
.sidebar-toggle {
    background: #ff0000 !important; /* Red background for debugging */
    border: 3px solid #ffffff !important;
    box-shadow: 0 0 20px rgba(255, 0, 0, 0.8) !important;
}

/* Mobile-specific sidebar toggle styles */
@media (max-width: 768px) {
    .sidebar-toggle {
        display: block !important;
        position: fixed !important;
        top: 15px !important;
        left: 15px !important;
        z-index: 10000 !important;
        background: #ff0000 !important;
        color: white !important;
        border: 3px solid #ffffff !important;
        border-radius: 50% !important;
        width: 50px !important;
        height: 50px !important;
        cursor: pointer !important;
        box-shadow: 0 0 20px rgba(255, 0, 0, 0.8) !important;
        font-size: 1.5rem !important;
        text-align: center !important;
        line-height: 44px !important;
    }
}

/* Emergency button styles - always visible */
#emergencySidebarToggle {
    display: block !important;
    position: fixed !important;
    top: 50px !important;
    left: 15px !important;
    z-index: 10001 !important;
    background: #00ff00 !important;
    color: black !important;
    border: 3px solid #000000 !important;
    border-radius: 10px !important;
    width: 60px !important;
    height: 40px !important;
    cursor: pointer !important;
    box-shadow: 0 0 20px rgba(0, 255, 0, 0.8) !important;
    font-size: 1rem !important;
    font-weight: bold !important;
    text-align: center !important;
    line-height: 34px !important;
}

/* Test button styles */
#testButton {
    display: block !important;
    position: fixed !important;
    top: 100px !important;
    left: 15px !important;
    z-index: 10001 !important;
    background: #ff00ff !important;
    color: white !important;
    border: 3px solid #ffffff !important;
    border-radius: 10px !important;
    width: 60px !important;
    height: 40px !important;
    cursor: pointer !important;
    box-shadow: 0 0 20px rgba(255, 0, 255, 0.8) !important;
    font-size: 0.8rem !important;
    font-weight: bold !important;
    text-align: center !important;
    line-height: 34px !important;
}

/* Ensure sidebar is visible when open */
.sidebar.open {
    left: 0 !important;
    z-index: 9999 !important;
}

.sidebar-overlay.show {
    display: block !important;
    z-index: 9998 !important;
}

/* Add close button to sidebar */
.sidebar-close-btn {
    position: absolute !important;
    top: 15px !important;
    right: 15px !important;
    background: #ff0000 !important;
    color: white !important;
    border: none !important;
    border-radius: 50% !important;
    width: 30px !important;
    height: 30px !important;
    cursor: pointer !important;
    font-size: 1.2rem !important;
    z-index: 10000 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* Tablet styles */
@media (max-width: 992px) and (min-width: 769px) {
    .sidebar {
        width: 70px;
        left: 0; /* Ensure sidebar is visible */
    }
    
    .sidebar .app-title,
    .sidebar .section-title,
    .sidebar .nav-link span,
    .sidebar .template-item span {
        display: none;
    }
    
    .sidebar .nav-link,
    .sidebar .template-item {
        justify-content: center;
        padding: 15px;
    }
    
    .sidebar .nav-link i,
    .sidebar .template-item i {
        margin-right: 0;
    }
    
    .main-content {
        margin-left: 70px;
    }
    
    .controls {
        left: 70px;
    }
}

/* Mobile styles */
@media (max-width: 768px) {
    .container {
        flex-direction: column;
        overflow-x: hidden;
        position: relative;
    }
    
    .sidebar {
        width: 250px;
        height: 100vh;
        position: fixed;
        left: -250px;
        overflow-y: auto;
    }
    
    .main-content {
        margin-left: 0;
        width: 100%;
        padding: 20px 15px;
        overflow-x: hidden;
        position: relative;
    }
    
    .controls {
        left: 0;
        right: 0;
        flex-direction: column;
        padding: 15px;
        position: fixed;
        bottom: 0;
        z-index: 100;
    }
    
    .export-btn,
    .whatsapp-btn,
    .reset-btn {
        width: 100%;
        justify-content: center;
    }
    
    .search-container {
        width: 100%;
        margin-top: 15px;
    }
    
    .search-input {
        width: 100%;
    }

    .content-header {
        flex-direction: column;
        gap: 15px;
        padding: 15px 20px;
    }

    .category-title {
        font-size: 1.5rem;
    }

    .filters {
        gap: 8px;
        margin-bottom: 15px;
    }

    .filter-btn {
        padding: 6px 12px;
        font-size: 0.9rem;
    }

    .add-task-form {
        flex-direction: column;
        gap: 15px;
    }

    .task-input,
    .priority-select {
        width: 100%;
        min-width: auto;
    }

    .task-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .task-content {
        width: 100%;
    }

    .task-actions {
        align-self: flex-end;
        gap: 15px;
    }

    .floating-btn {
        bottom: 20px;
        right: 20px;
        width: 55px;
        height: 55px;
        font-size: 1.5rem;
    }

    /* Fix scroll issues */
    .tasks-container {
        overflow: visible;
        margin-bottom: 120px; /* Make space for fixed controls */
    }

    .task-list {
        overflow: visible;
    }

    .progress-section {
        overflow: visible;
    }

    /* Ensure body scroll works */
    body {
        overflow-x: hidden;
        position: relative;
    }

    html {
        overflow-x: hidden;
    }
}

@media (max-width: 480px) {
    .content-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
        padding: 15px;
    }
    
    .category-title {
        font-size: 1.3rem;
    }
    
    .add-task-form {
        flex-direction: column;
        gap: 12px;
    }
    
    .task-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
        padding: 12px;
    }
    
    .task-content {
        margin: 0;
        width: 100%;
    }
    
    .task-actions {
        align-self: flex-end;
        gap: 10px;
    }

    .task-meta {
        flex-direction: column;
        gap: 8px;
    }

    .filters {
        gap: 6px;
    }

    .filter-btn {
        padding: 5px 10px;
        font-size: 0.8rem;
    }

    .progress-section,
    .tasks-container {
        padding: 15px;
        margin-bottom: 20px;
    }

    .controls {
        padding: 12px 15px;
    }

    .export-btn,
    .whatsapp-btn,
    .reset-btn {
        padding: 10px 15px;
        font-size: 0.85rem;
    }

    /* Improve touch targets on mobile */
    .task-checkbox {
        width: 24px;
        height: 24px;
    }

    .task-edit,
    .task-delete {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
    }

    .nav-link {
        padding: 15px 12px;
        margin-bottom: 10px;
    }

    .template-item {
        padding: 12px 15px;
        margin-bottom: 10px;
    }

    .template-action {
        width: 32px;
        height: 32px;
    }
}

/* Modal responsive styles */
@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        padding: 20px;
        max-height: 85vh;
    }
    
    .modal-header {
        margin-bottom: 15px;
    }
    
    .modal-title {
        font-size: 1.3rem;
    }
    
    .form-group {
        margin-bottom: 15px;
    }
    
    .form-input,
    .form-textarea,
    .form-select {
        padding: 10px 12px;
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .form-actions {
        flex-direction: column;
        gap: 10px;
    }
    
    .btn {
        width: 100%;
        padding: 12px 15px;
    }
}

/* Large screen optimizations */
@media (min-width: 1200px) {
    .container {
        max-width: 1400px;
        margin: 0 auto;
    }
    
    .sidebar {
        width: 280px;
    }
    
    .main-content {
        margin-left: 280px;
        padding: 30px;
    }
    
    .controls {
        left: 280px;
    }
    
    .content-header {
        padding: 20px 30px;
    }
    
    .category-title {
        font-size: 2rem;
    }
    
    .search-input {
        width: 300px;
    }
}

/* Ultra-wide screen support */
@media (min-width: 1600px) {
    .container {
        max-width: 1600px;
    }
    
    .sidebar {
        width: 300px;
    }
    
    .main-content {
        margin-left: 300px;
        padding: 40px;
    }
    
    .controls {
        left: 300px;
    }
    
    .content-header {
        padding: 25px 40px;
    }
    
    .category-title {
        font-size: 2.2rem;
    }
}

/* Print styles */
@media print {
    .sidebar,
    .floating-btn,
    .controls,
    .sidebar-toggle,
    .sidebar-overlay {
        display: none !important;
    }
    
    .main-content {
        margin-left: 0 !important;
        padding: 0 !important;
    }
    
    .task-item {
        break-inside: avoid;
        page-break-inside: avoid;
    }
    
    .progress-section {
        break-inside: avoid;
        page-break-inside: avoid;
    }
    
    body {
        background: white !important;
        color: black !important;
    }
    
    .task-item {
        background: white !important;
        border: 1px solid #ccc !important;
        box-shadow: none !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --primary: #000000;
        --secondary: #333333;
        --accent: #666666;
        --light: #ffffff;
        --dark: #000000;
        --success: #006600;
        --warning: #cc6600;
        --info: #0066cc;
        --danger: #cc0000;
        --border-radius: 0px;
        --box-shadow: 0 0 0 2px #000000;
    }
    
    .task-item {
        border: 2px solid #000000;
    }
    
    .btn {
        border: 2px solid #000000;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .floating-btn:hover {
        transform: none;
    }
    
    .btn:hover {
        transform: none;
    }
    
    .theme-toggle:hover {
        transform: none;
    }
}

/* Dark mode preference support */
@media (prefers-color-scheme: dark) {
    :root:not(.light-mode) {
        --primary: #6a0dad;
        --secondary: #003049;
        --accent: #dd2476;
        --light: #2d3436;
        --dark: #f8f9fa;
        --success: #2ed573;
        --box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    }
    
    body:not(.light-mode) {
        background: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
        color: var(--light);
    }
    
    body:not(.light-mode) .sidebar {
        background: rgba(45, 52, 54, 0.9);
    }
    
    body:not(.light-mode) .sidebar-header {
        border-bottom-color: #555;
    }
    
    body:not(.light-mode) .app-title {
        color: var(--secondary);
    }
    
    body:not(.light-mode) .theme-toggle {
        color: var(--light);
    }
    
    body:not(.light-mode) .nav-link:hover {
        background: rgba(30, 144, 255, 0.1);
    }
    
    body:not(.light-mode) .section-title {
        color: var(--secondary);
    }
    
    body:not(.light-mode) .template-item {
        background: rgba(50, 50, 50, 0.5);
    }
    
    body:not(.light-mode) .template-item:hover {
        background: rgba(30, 144, 255, 0.1);
    }
    
    body:not(.light-mode) .search-input {
        background: rgba(45, 52, 54, 0.9);
        color: white;
    }
    
    body:not(.light-mode) .filter-btn {
        background: rgba(45, 52, 54, 0.8);
        color: white;
    }
    
    body:not(.light-mode) .filter-btn.active {
        background: var(--secondary);
    }
    
    body:not(.light-mode) .progress-section {
        background: rgba(45, 52, 54, 0.9);
    }
    
    body:not(.light-mode) .progress-bar {
        background-color: #555;
    }
    
    body:not(.light-mode) .tasks-container {
        background: rgba(45, 52, 54, 0.9);
    }
    
    body:not(.light-mode) .task-input {
        background: #3d3d3d;
        border-color: #555;
        color: white;
    }
    
    body:not(.light-mode) .priority-select {
        background: #3d3d3d;
        border-color: #555;
        color: white;
    }
    
    body:not(.light-mode) .task-item {
        background: #3d3d3d;
    }
    
    body:not(.light-mode) .task-meta {
        color: #aaa;
    }
    
    body:not(.light-mode) .controls {
        background: rgba(45, 52, 54, 0.9);
    }
}

/* Ocultar botón móvil en desktop */
#simpleSidebarToggle {
    display: none;
}

/* Mostrar botón móvil solo en pantallas pequeñas */
@media (max-width: 768px) {
    #simpleSidebarToggle {
        display: block !important;
        position: fixed !important;
        top: 15px !important;
        left: 15px !important;
        z-index: 10001 !important;
        background: #ff0000 !important;
        color: white !important;
        border: 3px solid #ffffff !important;
        border-radius: 50% !important;
        width: 50px !important;
        height: 50px !important;
        cursor: pointer !important;
        font-size: 1.5rem !important;
        text-align: center !important;
        line-height: 44px !important;
    }
}
