/* Mobile-responsive improvements for Monster Manager */
/* Mobile-first responsive design approach */

/*
 * MOBILE TABLE RESPONSIVENESS REQUIREMENTS:
 * 
 * For tables to work properly with .table-stack-mobile class on small screens:
 * 1. Add class="table-stack-mobile" to the <table> element
 * 2. Add data-label="Column Name" attribute to EVERY <td> element
 * 3. The data-label value should match the column header text
 * 
 * WHEN TO USE .table-stack-mobile:
 * - Data tables with multiple columns (3+ columns)
 * - Tables where each row represents a distinct record
 * - Tables with text-heavy content that benefits from vertical stacking
 * 
 * WHEN NOT TO USE .table-stack-mobile:
 * - Compact stat tables (like ability scores) with many narrow columns
 * - Tables designed to be viewed as a grid (like ability score matrices)
 * - Tables where the layout itself conveys meaning (like calendars)
 * 
 * Example:
 * <table class="table table-striped table-stack-mobile">
 *   <thead>
 *     <tr><th>Name</th><th>Type</th><th>Actions</th></tr>
 *   </thead>
 *   <tbody>
 *     <tr>
 *       <td data-label="Name">Dragon</td>
 *       <td data-label="Type">Ancient</td>
 *       <td data-label="Actions">[buttons]</td>
 *     </tr>
 *   </tbody>
 * </table>
 * 
 * On mobile, this will stack each row as a card with labels.
 */

/* ===== BASE RESPONSIVE IMPROVEMENTS ===== */

/* Mobile-first card improvements */
.card {
    margin-bottom: 1rem;
}

.monster-card {
    min-height: auto;
    font-size: 0.95rem;
    transition: var(--transition-base);
}

.monster-card:hover {
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

/* Typography - Mobile First */
.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    line-height: 1.3;
}

.card-text {
    font-size: 0.9rem;
    line-height: 1.4;
}

/* Better button sizing on mobile */
.btn-sm {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    min-height: 38px; /* Minimum touch target */
}

.btn {
    min-height: 44px; /* Standard touch target */
}

/* Container spacing improvements */
.container {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
}

/* ===== MOBILE-SPECIFIC STYLES ===== */

/* Monster view improvements for mobile */
.monster-view-header {
    margin-bottom: 1rem;
}

.monster-view-header h1 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.monster-stats-table {
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

.monster-stats-table th {
    font-size: 0.75rem;
    padding: 0.25rem;
}

.monster-stats-table td {
    padding: 0.35rem;
}

/* Ability scores table improvements */
.ability-table {
    width: 100%;
    font-size: 0.8rem;
}

.ability-table th {
    font-size: 0.7rem;
    padding: 0.25rem 0.15rem;
}

.ability-table td {
    padding: 0.3rem 0.15rem;
    text-align: center;
}

/* Monster actions and traits */
.monster-section {
    margin-bottom: 1.5rem;
}

.monster-section h4 {
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
    color: #495057;
}

.monster-section ul {
    margin-bottom: 0;
}

.monster-section li {
    margin-bottom: 0.5rem;
    line-height: 1.4;
}

/* Badge improvements */
.badge {
    font-size: 0.75rem;
    margin-right: 0.25rem;
    margin-bottom: 0.25rem;
    display: inline-block;
}

/* Button group improvements */
.btn-group {
    flex-wrap: wrap;
    gap: 0.25rem;
}

.btn-group .btn {
    flex: 1;
    min-width: 80px;
}

/* ===== TABLET STYLES (768px+) ===== */
@media (min-width: 768px) {
    .monster-card {
        font-size: 1rem;
    }
    
    .card-title {
        font-size: 1.25rem;
    }
    
    .card-text {
        font-size: 1rem;
    }
    
    .container {
        padding-left: 1.5rem;
        padding-right: 1.5rem;
    }
    
    .monster-view-header h1 {
        font-size: 2rem;
    }
    
    .monster-stats-table {
        font-size: 0.9rem;
    }
    
    .ability-table {
        font-size: 0.85rem;
    }
    
    .monster-section h4 {
        font-size: 1.25rem;
    }
}

/* ===== DESKTOP STYLES (992px+) ===== */
@media (min-width: 992px) {
    .monster-card {
        min-height: 200px;
    }
    
    .monster-view-header h1 {
        font-size: 2.25rem;
    }
    
    .monster-stats-table {
        font-size: 1rem;
    }
    
    .ability-table {
        font-size: 0.9rem;
    }
}

/* ===== NAVIGATION IMPROVEMENTS ===== */
.navbar-nav .nav-link {
    padding: 0.75rem 1rem;
}

@media (max-width: 991.98px) {
    .navbar-nav .nav-link {
        padding: 0.5rem 0;
        border-bottom: 1px solid rgba(255,255,255,0.1);
        font-size: 1rem;
    }
}

/* ===== TABLE RESPONSIVE IMPROVEMENTS ===== */
@media (max-width: 767.98px) {
    .table-responsive-stack {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .table-responsive-stack .table {
        margin-bottom: 0;
    }
    
    /* Stack table rows on very small screens */
    /* IMPORTANT: Requires data-label attributes on all <td> elements */
    /* Example: <td data-label="Name">John Doe</td> */
    .table-stack-mobile {
        border: 0;
    }
    
    .table-stack-mobile thead {
        display: none;
    }
    
    .table-stack-mobile tbody,
    .table-stack-mobile tr,
    .table-stack-mobile td {
        display: block;
        width: 100%;
    }
    
    .table-stack-mobile tr {
        border: 1px solid var(--border-light);
        margin-bottom: 1rem;
        padding: 0.75rem;
        border-radius: var(--border-radius);
    }
    
    .table-stack-mobile td {
        padding: 0.25rem 0;
        border: none;
        text-align: left;
    }
    
    .table-stack-mobile td:before {
        content: attr(data-label) ": ";
        font-weight: bold;
        display: inline-block;
        width: 30%;
    }

    /* Hide ::before for td elements without data-label */
    .table-stack-mobile td:not([data-label]):before,
    .table-stack-mobile td[data-label=""]:before {
        display: none !important;
    }

    /* Exclude footer elements from mobile stacking */
    .table-stack-mobile tfoot td:before,
    .table-stack-mobile tfoot th:before {
        display: none !important;
    }
}

/* ===== TOUCH IMPROVEMENTS ===== */
@media (hover: none) and (pointer: coarse) {
    /* Touch device specific styles */
    .btn:hover {
        transform: none;
    }
    
    .card:hover {
        transform: none;
    }
    
    /* Larger touch targets */
    .btn-sm {
        min-height: 44px;
        padding: 0.6rem 1rem;
    }
    
    .badge {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
    }
}

/* ===== FORM IMPROVEMENTS ===== */
@media (max-width: 767.98px) {
    .form-control, 
    .form-select {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 0.75rem;
    }
    
    .btn-group-vertical .btn {
        margin-bottom: 0.25rem;
    }
    
    .btn-group-vertical .btn:last-child {
        margin-bottom: 0;
    }
}

/* ===== UTILITY CLASSES ===== */
.mobile-stack {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

@media (min-width: 768px) {
    .mobile-stack {
        flex-direction: row;
        align-items: center;
    }
}

.touch-target {
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* ===== SPACING UTILITIES ===== */
@media (max-width: 767.98px) {
    .mobile-mb-2 { margin-bottom: 0.5rem !important; }
    .mobile-mb-3 { margin-bottom: 1rem !important; }
    .mobile-mt-2 { margin-top: 0.5rem !important; }
    .mobile-mt-3 { margin-top: 1rem !important; }
    .mobile-p-2 { padding: 0.5rem !important; }
    .mobile-p-3 { padding: 1rem !important; }
}

/* ===== MONSTER LIST SPECIFIC STYLES ===== */

/* Force responsive panels to stack below 1200px */
@media (max-width: 1199px) {
    .encounter-panels-container {
        display: flex !important;
        flex-direction: column !important;
    }
    
    .encounter-panel-party {
        order: 1 !important;
        width: 100% !important;
    }
    
    .encounter-panel-management {
        order: 2 !important;
        width: 100% !important;
    }
}

/* Mobile monster cards */
@media (max-width: 767.98px) {
    .monster-card .card-body {
        padding: 1rem;
    }
    
    .monster-card .card-title {
        font-size: 1.1rem;
        line-height: 1.3;
    }
    
    .monster-card .badge {
        font-size: 0.7rem;
        padding: 0.25rem 0.5rem;
    }
    
    .monster-card .btn {
        font-size: 0.85rem;
        padding: 0.5rem 0.75rem;
    }
}