/* Responsive CSS for LifeRx App */

/* Mobile-first responsive design */
@media (max-width: 640px) {
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    /* Make tables responsive */
    .tabulator {
        font-size: 0.875rem;
    }
    
    .tabulator .tabulator-header {
        font-size: 0.75rem;
    }
    
    .tabulator .tabulator-cell {
        padding: 0.5rem 0.25rem;
    }
    
    /* Hide less important columns on mobile */
    .tabulator .tabulator-col[data-field="timestamp"] {
        display: none;
    }
    
    .tabulator .tabulator-col[data-field="note"] {
        display: none;
    }
    
    /* Make action buttons smaller on mobile */
    .tabulator .tabulator-cell .btn-sm {
        padding: 0.25rem 0.5rem;
        font-size: 0.75rem;
    }
}

/* Tablet responsive design */
@media (min-width: 641px) and (max-width: 1024px) {
    .tabulator .tabulator-col[data-field="note"] {
        display: none;
    }
}

/* Ensure modals are properly centered on all devices */
.modal-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1rem;
}

/* Make sure buttons are touch-friendly on mobile */
@media (max-width: 640px) {
    button, .btn {
        min-height: 44px;
        min-width: 44px;
    }
    
    .tab-btn {
        min-height: 48px;
    }
}

/* Responsive text sizing */
@media (max-width: 640px) {
    h1 {
        font-size: 1.5rem;
    }
    
    h2 {
        font-size: 1.25rem;
    }
    
    h3 {
        font-size: 1.125rem;
    }
}

/* Ensure proper spacing on mobile */
@media (max-width: 640px) {
    .space-y-4 > * + * {
        margin-top: 0.75rem;
    }
    
    .space-y-6 > * + * {
        margin-top: 1rem;
    }
}

/* Make sure images in modals are responsive */
.modal img {
    max-width: 100%;
    height: auto;
}

/* Responsive grid adjustments */
@media (max-width: 640px) {
    .grid-cols-2 {
        grid-template-columns: repeat(1, minmax(0, 1fr));
    }
}

@media (min-width: 641px) and (max-width: 768px) {
    .grid-cols-4 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* Ensure proper overflow handling */
.overflow-x-auto {
    -webkit-overflow-scrolling: touch;
}

/* Make sure tables don't break layout on mobile */
.tabulator-tableHolder {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ===== Storico tables: mobile card list (Tabulator hidden via JS on <=768px) ===== */
.storico-table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.storico-mobile-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.storico-section .storico-mobile-card {
    border-radius: 0.75rem;
    border: 1px solid #e5e7eb;
    background: #fff;
    padding: 0.875rem 1rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.storico-section .storico-mobile-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 0.25rem;
}

.storico-section .storico-mobile-card-title {
    font-weight: 700;
    color: #111827;
    font-size: 0.95rem;
    line-height: 1.3;
    word-break: break-word;
    flex: 1;
    min-width: 0;
}

.storico-section .storico-mobile-card-time {
    font-size: 0.8rem;
    color: #6b7280;
    white-space: nowrap;
    flex-shrink: 0;
}

.storico-section .storico-mobile-card-sub {
    font-size: 0.85rem;
    color: #4b5563;
    margin-bottom: 0.75rem;
    word-break: break-word;
}

.storico-section .storico-mobile-card-actions {
    display: flex;
    gap: 0.5rem;
}

.storico-section .storico-mobile-card-actions > div {
    display: flex;
    flex: 1;
    gap: 0.5rem;
    width: 100%;
}

.storico-section .storico-mobile-card-actions .action-btn {
    flex: 1;
    min-height: 44px;
    justify-content: center;
    font-size: 0.8rem;
}

@media (min-width: 769px) {
    .storico-mobile-list {
        display: none !important;
    }
}

@media (max-width: 768px) {
    .storico-table-container {
        overflow-x: hidden;
    }
}

/* Responsive padding adjustments */
@media (max-width: 640px) {
    .p-6 {
        padding: 1rem;
    }
    
    .px-4 {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
    
    .py-2 {
        padding-top: 0.5rem;
        padding-bottom: 0.5rem;
    }
}
