/* Estilos globales compartidos */

/* Reset y configuración base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f5f5f5;
    min-height: 100vh;
    padding: 20px;
    overflow-y: auto;
}

/* Contenedor principal */
.container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 15px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
    overflow: visible;
    min-height: auto;
}

/* Header general */
.header {
    background: #ffffff;
    color: #1f2937;
    padding: 30px;
    text-align: center;
}

.header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    font-weight: 700;
}

.header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* Contenido general */
.content {
    padding: 25px;
    overflow: visible;
}

/* Contenedor de tablas para la calculadora principal */
.tables-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
    margin-bottom: 30px;
}

.table-section {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    overflow: hidden;
    border: 1px solid #e5e7eb;
    padding-bottom: 15px;
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding: 15px 20px;
    background: #ffffff;
    border-radius: 10px;
}

.table-title {
    font-size: 1.3rem;
    font-weight: 600;
    color: #20c5bf;
}

.total-summary {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 12px 15px;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.total-summary h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: #20c5bf;
}

.total-display {
    display: flex;
    gap: 20px;
    align-items: center;
}

.total-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 60px;
}

.total-label {
    font-size: 0.75rem;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.total-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: #20c5bf;
}

.table-container {
    overflow-x: auto;
    overflow-y: visible;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    max-height: none;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

th, td {
    padding: 12px;
    text-align: center;
    border-bottom: 1px solid #e5e7eb;
}

th {
    background: linear-gradient(135deg, #20c5bf 0%, #7543e9 100%);
    color: white;
    font-weight: 600;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

tbody tr:hover {
    background: #f9fafb;
}

.date-input {
    padding: 10px 14px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 0.9rem;
    width: 140px;
    background: white;
    transition: all 0.3s ease;
    font-family: inherit;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.date-input:focus {
    outline: none;
    border-color: #20c5bf;
    box-shadow: 0 0 0 3px rgba(32, 197, 191, 0.15), 0 2px 8px rgba(32, 197, 191, 0.1);
    transform: translateY(-1px);
}

.date-input:hover:not(:focus) {
    border-color: #d1d5db;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.total-cell {
    font-weight: 600;
    color: #20c5bf;
    background: #f9fafb;
}

.add-row-btn {
    background: linear-gradient(135deg, #20c5bf 0%, #7543e9 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: transform 0.2s ease;
}

.add-row-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(32, 197, 191, 0.3);
}

.remove-row-btn {
    background: #d1d5db;
    color: #374151;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: background-color 0.2s ease;
}

.remove-row-btn:hover {
    background: #9ca3af;
}

.actions-cell {
    width: 80px;
}

.table-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 0 20px;
    margin-top: 15px;
}

.clear-btn {
    background: #17a2b8;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: background-color 0.2s ease;
}

.clear-btn:hover {
    background: #138496;
}

.date-input.readonly {
    background: #f9fafb;
    color: #6b7280;
    cursor: not-allowed;
    border-color: #e5e7eb;
    box-shadow: none;
}

.date-input.readonly:hover {
    border-color: #e5e7eb;
    box-shadow: none;
    transform: none;
}

.readonly-row {
    background: #fefce8;
}

.readonly-row .total-cell {
    background: #fefce8;
}

.readonly-indicator {
    font-size: 0.7rem;
    color: #d97706;
    font-weight: 600;
    background: #fef3c7;
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid #f59e0b;
}

.footer {
    background: #f9fafb;
    padding: 20px;
    text-align: center;
    color: #4b5563;
    border-top: 1px solid #e5e7eb;
}

.footer a {
    color: #20c5bf;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s ease;
}

.footer a:hover {
    color: #7543e9;
    text-decoration: underline;
}

/* Responsive design para la calculadora principal */
@media (max-width: 768px) {
    .header {
        padding: 15px;
    }

    .header h1 {
        font-size: 1.8rem;
    }

    .content {
        padding: 15px;
    }

    .tables-container {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    th, td {
        padding: 8px 6px;
        font-size: 0.8rem;
    }

    .date-input {
        width: 150px;
        padding: 8px 10px;
    }

    .table-header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }

    .table-actions {
        flex-direction: column;
        gap: 10px;
        padding: 0 15px;
    }

    .total-summary {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }

    .total-display {
        justify-content: center;
        flex-direction: row;
        gap: 15px;
        align-items: center;
        flex-wrap: wrap;
    }

    .total-item {
        flex-direction: row;
        align-items: center;
        min-width: auto;
        gap: 8px;
    }

    .total-label {
        margin-bottom: 0;
        font-size: 0.7rem;
    }

    /* Mejorar responsividad de la tabla */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table {
        min-width: 600px; /* Evitar que la tabla se comprima demasiado */
    }

    /* Ajustes para móviles pequeños */
    .date-input {
        width: 100px;
        font-size: 0.75rem;
    }

    .add-row-btn, .clear-btn {
        width: 100%;
        margin-bottom: 5px;
    }
}

/* Media query para tablets */
@media (max-width: 1024px) and (min-width: 769px) {
    .tables-container {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table {
        min-width: 700px;
    }
}

/* Media query para móviles muy pequeños */
@media (max-width: 480px) {
    .header h1 {
        font-size: 1.5rem;
    }

    .header p {
        font-size: 0.9rem;
    }

    .content {
        padding: 10px;
    }

    th, td {
        padding: 6px 4px;
        font-size: 0.75rem;
    }

    .date-input {
        width: 130px;
        padding: 6px 8px;
        font-size: 0.7rem;
    }

    .table-header {
        padding: 10px 15px;
    }

    .total-summary {
        padding: 10px 12px;
    }

    .total-value {
        font-size: 0.9rem;
    }

    .total-label {
        font-size: 0.65rem;
    }

    .total-display {
        gap: 10px;
    }

    .total-item {
        gap: 5px;
    }

    .add-row-btn, .clear-btn {
        padding: 8px 16px;
        font-size: 0.85rem;
    }

    table {
        min-width: 500px;
    }
}

/* Estilos específicos para inputs de fecha en móviles - permitir edición manual */
@media (max-width: 768px) {
    .date-input {
        -webkit-appearance: none;
        -moz-appearance: none;
        appearance: none;
        background: white !important;
        cursor: text !important;
    }

    .date-input::-webkit-date-and-time-value {
        text-align: left;
        padding: 0;
    }

    .date-input::-webkit-calendar-picker-indicator {
        cursor: pointer;
        opacity: 1;
        filter: invert(0.5);
    }

    .date-input::-webkit-inner-spin-button,
    .date-input::-webkit-outer-spin-button {
        -webkit-appearance: none;
        margin: 0;
    }

    .date-input::-webkit-clear-button {
        -webkit-appearance: none;
    }

    /* Para Firefox */
    .date-input::-moz-focus-inner {
        border: 0;
    }

    /* Para Edge */
    .date-input::-ms-clear {
        display: none;
    }

    .date-input::-ms-expand {
        display: none;
    }
}

/* Para dispositivos táctiles específicamente */
@media (hover: none) and (pointer: coarse) {
    .date-input {
        -webkit-appearance: none !important;
        -moz-appearance: none !important;
        appearance: none !important;
        background: white !important;
        cursor: text !important;
        font-family: monospace;
    }

    .date-input:focus {
        background: white !important;
    }
}

/* Estilos para SweetAlert2 */
.swal-confirm-btn {
    background: linear-gradient(135deg, #20c5bf 0%, #7543e9 100%) !important;
    border: none !important;
    color: white !important;
    border-radius: 6px !important;
}

.swal-cancel-btn {
    background: #6b7280 !important;
    border: none !important;
    color: white !important;
    border-radius: 6px !important;
}

/* Language Selector Styles */
.header-top {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 20px;
}

.language-selector {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f9fafb;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.language-selector label {
    font-size: 0.9rem;
    font-weight: 500;
    color: #374151;
    margin: 0;
}

.language-selector select {
    padding: 4px 8px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    background: white;
    font-size: 0.85rem;
    color: #374151;
    cursor: pointer;
    transition: border-color 0.2s ease;
}

.language-selector select:focus {
    outline: none;
    border-color: #20c5bf;
    box-shadow: 0 0 0 2px rgba(32, 197, 191, 0.1);
}

.language-selector select:hover {
    border-color: #9ca3af;
}

/* Estilos para inputs en modales de SweetAlert2 */
.swal2-input {
    max-width: 300px !important;
    width: 100% !important;
    margin: 0 auto !important;
}

/* Ajustar el ancho del modal para evitar scroll horizontal */
.swal2-popup {
    max-width: 400px !important;
    width: 90% !important;
}

/* Sección de guardar para la calculadora principal */
.save-section {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    padding: 20px;
}

.save-btn {
    background: linear-gradient(135deg, #20c5bf 0%, #1aa3a0 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(32, 197, 191, 0.3);
}

.save-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(32, 197, 191, 0.4);
}

.save-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(32, 197, 191, 0.3);
}

.view-saved-btn {
    background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
    color: white;
    text-decoration: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(107, 114, 128, 0.3);
    display: none; /* Oculto por defecto */
}

.view-saved-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(107, 114, 128, 0.4);
    color: white;
}

.view-saved-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(107, 114, 128, 0.3);
}

/* Estilos para el logo */
.header img {
    max-width: 200px;
    height: auto;
    margin-bottom: 20px;
}

/* Estilos para el indicador de edición */
#editing-indicator {
    display: none;
    background: #fff3cd;
    color: #856404;
    padding: 10px;
    border-radius: 5px;
    margin: 10px 0;
    border: 1px solid #ffeaa7;
}

#editing-indicator button {
    margin-left: 10px;
    background: #6c757d;
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 3px;
    cursor: pointer;
}

#editing-indicator button:hover {
    background: #5a6268;
}