/* ==========================================================================
   Responsive Design - Mobile & Tablet Styles
   ========================================================================== */

/* ===== DESKTOP - Hide refresh button ===== */
#refreshBtn {
    display: none !important;
    pointer-events: none;
}

/* ===== HIDE ACTION COLUMN (< 950px) ===== */
@media (max-width: 949px) {
    table th:last-child,
    table td:last-child,
    .notify-btn,
    .hide-btn,
    .low-stock-btn {
        display: none !important;
        visibility: hidden !important;
        width: 0 !important;
        padding: 0 !important;
        margin: 0 !important;
        border: none !important;
        height: 0 !important;
    }
}

/* ===== TABLET (1024px - 1200px) ===== */
@media (max-width: 1200px) {
    .watched-table table {
        min-width: 1000px;
    }
}

/* ===== TABLET LANDSCAPE (769px - 1024px) ===== */
@media (max-width: 1024px) {
    .container {
        padding: 15px;
        max-width: 100%;
    }

    .header h1 {
        font-size: 2rem;
    }

    .controls {
        padding: 1rem;
    }

    /* Buttons layout */
    .refresh-btn,
    .stock-filter-btn,
    .reset-filters-btn {
        padding: 0.6rem 1rem;
        font-size: 0.95rem;
        margin-bottom: 0.75rem;
    }

    /* Search and filters */
    .search-container,
    .manufacturer-filter-container {
        margin-top: 0.75rem;
    }

    .search-input,
    .manufacturer-filter {
        font-size: 0.95rem;
        padding: 0.75rem;
    }

    /* Table adjustments */
    table {
        font-size: 0.8rem;
    }

    th, td {
        padding: 0.5rem 0.3rem;
    }
}

/* ===== TABLET PORTRAIT & SMALL SCREENS (769px - 1024px) ===== */
@media (max-width: 768px) {
    /* Show refresh button on mobile */
    #refreshBtn {
        display: inline-block !important;
        pointer-events: auto;
    }

    /* Hide notification and hide columns on mobile */
    table th:nth-child(1),
    table td:nth-child(1),
    table th:nth-child(2),
    table td:nth-child(2),
    .notify-btn,
    .hide-btn,
    #manageHiddenBtn {
        display: none !important;
        visibility: hidden !important;
        width: 0 !important;
        padding: 0 !important;
        margin: 0 !important;
        border: none !important;
        height: 0 !important;
    }

    /* Freeze table header while scrolling */
    table thead {
        position: sticky;
        top: 0;
        z-index: 10;
        background: white;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    }

    table th {
        position: sticky;
        top: 0;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        color: white;
    }

    /* Column separators for stock columns */
    table th:nth-child(n+5) {
        border-right: 1px solid rgba(255, 255, 255, 0.3);
    }

    table td:nth-child(n+5) {
        border-right: 1px solid #e0e0e0;
    }

    /* Layout */
    .container {
        padding: 10px;
        max-width: 100%;
        margin: 0;
    }

    body {
        margin: 0;
        padding: 0;
    }

    /* Header */
    .header {
        padding: 0.5rem 0.75rem;
        margin-bottom: 1rem;
        border-radius: 6px;
    }

    .header h1 {
        font-size: 1.5rem;
        margin-bottom: 0.25rem;
    }

    .header p {
        font-size: 0.9rem;
    }

    /* Controls */
    .controls {
        padding: 0.75rem;
        margin-bottom: 1rem;
        border-radius: 6px;
    }

    /* Hide refresh button on mobile */
    #refreshBtn {
        display: none !important;
    }

    /* Buttons - Display in single row with flex */
    .stock-filter-btn,
    .reset-filters-btn,
    #viewWatchedBtn {
        display: block;
        flex: 1;
        min-width: 0;
        padding: 0.6rem 0.5rem;
        margin-bottom: 0 !important;
        margin-right: 0.3rem !important;
        margin-left: 0 !important;
        font-size: 0.85rem;
        text-align: center;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    #viewWatchedBtn {
        margin-right: 0 !important;
    }

    /* Create flex container for buttons */
    .controls {
        display: flex;
        flex-wrap: wrap;
        gap: 0.3rem;
        align-items: center;
    }

    .file-status {
        flex: 1 100%;
    }

    .search-container,
    .manufacturer-filter-container {
        flex: 1 100%;
    }

    /* File Status - Hide on mobile */
    .file-status {
        display: none !important;
        margin-bottom: 0.75rem;
        padding: 0.75rem;
        font-size: 0.9rem;
        border-radius: 6px;
    }

    .file-status small {
        display: none;
    }

    .progress-bar {
        margin-top: 0.25rem;
        height: 5px;
    }

    /* Search container */
    .search-container {
        margin-top: 0.5rem;
        position: relative;
    }

    .search-container label,
    .manufacturer-filter-container label {
        font-size: 0.85rem;
        margin-bottom: 0.25rem;
    }

    .search-input,
    .manufacturer-filter {
        width: 100%;
        padding: 0.6rem 0.75rem;
        font-size: 0.9rem;
        border-radius: 6px;
    }

    .manufacturer-filter-container {
        margin-top: 0.5rem;
    }

    .search-debounce {
        font-size: 0.75rem;
    }

    /* Stats */
    .stats {
        flex-direction: column;
        gap: 0.5rem;
        margin-bottom: 1rem;
    }

    .stat-card {
        padding: 0.75rem;
        min-width: auto;
    }

    .stat-number {
        font-size: 1.5rem;
    }

    .stat-label {
        font-size: 0.8rem;
    }

    /* Pagination */
    .pagination-container {
        flex-direction: column;
        text-align: center;
        padding: 0.5rem;
        margin-bottom: 0.75rem;
        gap: 0.5rem;
        border-radius: 6px;
        overflow-x: hidden;
    }

    .pagination-info {
        font-size: 0.75rem;
        width: 100%;
        word-wrap: break-word;
    }

    .pagination-controls {
        width: 100%;
        gap: 0.3rem;
        flex-wrap: wrap;
        justify-content: center;
        display: flex;
    }

    .pagination-btn {
        padding: 0.35rem 0.5rem;
        font-size: 0.7rem;
        flex: 0 1 auto;
        min-width: 35px;
        white-space: nowrap;
    }

    .page-input {
        width: 38px;
        padding: 0.35rem;
        font-size: 0.7rem;
    }

    /* Table */
    .table-container {
        border-radius: 6px;
        overflow: hidden;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    }

    .table-wrapper {
        max-height: 60vh;
        overflow-x: auto;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    table {
        font-size: 0.75rem;
        table-layout: fixed;
        min-width: 600px;
    }

    th {
        padding: 0.5rem 0.3rem;
        font-size: 0.75rem;
        white-space: normal;
        word-break: break-word;
        overflow: hidden;
    }

    th:nth-child(1) { width: 50px; }
    th:nth-child(2) { width: 70px; }
    th:nth-child(3) { width: 200px; }
    th:nth-child(4) { width: 40px; }
    th:nth-child(n+5) { width: 40px; }

    td {
        padding: 0.4rem 0.3rem;
        font-size: 0.75rem;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Version Display */
    .version-display {
        font-size: 0.65rem;
        padding: 0.3rem 0.6rem;
        top: 5px;
        right: 5px;
        border-radius: 15px;
        height: 20px !important;
        line-height: 1.2 !important;
        white-space: nowrap;
        overflow: hidden;
        top: 8px !important;
    }

    /* Watched Items */
    .watched-container {
        padding: 10px;
    }

    .watched-table {
        margin-top: 0.75rem;
    }

    .watched-table th,
    .watched-table td {
        padding: 0.5rem 0.3rem;
        font-size: 0.75rem;
    }

    .delete-btn {
        padding: 0.3rem 0.6rem;
        font-size: 0.75rem;
    }

    /* Buttons/Links in table */
    .notify-btn {
        font-size: 1rem;
        padding: 0.15rem 0.3rem;
    }

    /* Hide column resizer on mobile */
    .resizer {
        display: none;
    }

    /* Better touch targets */
    button, input[type="button"], input[type="submit"] {
        min-height: 44px;
        min-width: 44px;
    }

    /* Adjust logo */
    .header-logo {
        max-height: 50px;
    }
}

/* ===== SMALL PHONES (480px - 768px) ===== */
@media (max-width: 480px) {
    /* Hide notification and hide columns on mobile */
    table th:nth-child(1),
    table td:nth-child(1),
    table th:nth-child(2),
    table td:nth-child(2),
    .notify-btn,
    .hide-btn,
    #manageHiddenBtn {
        display: none !important;
        visibility: hidden !important;
        width: 0 !important;
        padding: 0 !important;
        margin: 0 !important;
        border: none !important;
        height: 0 !important;
    }

    .container {
        padding: 8px;
    }

    .header {
        padding: 0.5rem;
        margin-bottom: 0.75rem;
    }

    .header h1 {
        font-size: 1.25rem;
    }

    .header p {
        font-size: 0.8rem;
    }

    .controls {
        padding: 0.5rem;
        margin-bottom: 0.75rem;
    }

    /* Hide refresh button on mobile */
    #refreshBtn {
        display: none !important;
    }

    /* Buttons - Display in single row with flex */
    .stock-filter-btn,
    .reset-filters-btn,
    #viewWatchedBtn {
        display: block;
        flex: 1;
        min-width: 0;
        padding: 0.5rem 0.4rem;
        margin-bottom: 0 !important;
        margin-right: 0.25rem !important;
        margin-left: 0 !important;
        font-size: 0.75rem;
        text-align: center;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    #viewWatchedBtn {
        margin-right: 0 !important;
    }

    /* Create flex container for buttons */
    .controls {
        display: flex;
        flex-wrap: wrap;
        gap: 0.25rem;
        align-items: center;
    }

    .file-status {
        flex: 1 100%;
    }

    .search-container,
    .manufacturer-filter-container {
        flex: 1 100%;
    }

    .file-status {
        display: none !important;
        padding: 0.5rem;
        font-size: 0.8rem;
    }

    .file-status small {
        display: none;
    }

    .search-input,
    .manufacturer-filter {
        padding: 0.5rem;
        font-size: 0.85rem;
    }

    .search-container label,
    .manufacturer-filter-container label {
        font-size: 0.75rem;
    }

    .pagination-container {
        padding: 0.4rem;
        margin-bottom: 0.5rem;
        gap: 0.3rem;
        overflow-x: hidden;
    }

    .pagination-info {
        font-size: 0.65rem;
        word-wrap: break-word;
    }

    .pagination-controls {
        gap: 0.2rem;
    }

    .pagination-btn {
        padding: 0.3rem 0.4rem;
        font-size: 0.65rem;
        min-width: 32px;
    }

    .page-input {
        width: 35px;
        padding: 0.3rem;
        font-size: 0.65rem;
    }

    table {
        font-size: 0.7rem;
        table-layout: fixed;
        min-width: 550px;
    }

    th {
        padding: 0.4rem 0.25rem;
        font-size: 0.7rem;
        overflow: hidden;
    }

    th:nth-child(1) { width: 45px; }
    th:nth-child(2) { width: 65px; }
    th:nth-child(3) { width: 200px; }
    th:nth-child(4) { width: 40px; }
    th:nth-child(n+5) { width: 40px; }

    td {
        padding: 0.35rem 0.25rem;
        font-size: 0.7rem;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .stat-card {
        padding: 0.5rem;
    }

    .stat-number {
        font-size: 1.25rem;
    }

    .stat-label {
        font-size: 0.7rem;
    }

    .header-logo {
        max-height: 40px;
    }

    .version-display {
        font-size: 0.6rem;
        padding: 0.2rem 0.5rem;
        top: 8px !important;
        right: 5px;
        height: 20px !important;
        line-height: 1.2 !important;
        white-space: nowrap;
        overflow: hidden;
    }

    .notify-btn {
        font-size: 0.9rem;
    }
}

/* ===== EXTRA SMALL PHONES (< 375px) ===== */
@media (max-width: 375px) {
    /* Hide notification column on mobile */
    table th:nth-child(1),
    table td:nth-child(1),
    .notify-btn {
        display: none !important;
        visibility: hidden !important;
        width: 0 !important;
        padding: 0 !important;
        margin: 0 !important;
        border: none !important;
        height: 0 !important;
    }

    .container {
        padding: 5px;
    }

    .header h1 {
        font-size: 1rem;
    }

    .header p {
        font-size: 0.75rem;
    }

    .controls {
        padding: 0.4rem;
    }

    /* Hide refresh button on mobile */
    #refreshBtn {
        display: none !important;
    }

    /* Buttons - Display in single row with flex */
    .stock-filter-btn,
    .reset-filters-btn,
    #viewWatchedBtn {
        display: block;
        flex: 1;
        min-width: 0;
        padding: 0.4rem 0.3rem;
        margin-bottom: 0 !important;
        margin-right: 0.2rem !important;
        margin-left: 0 !important;
        font-size: 0.7rem;
        text-align: center;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    #viewWatchedBtn {
        margin-right: 0 !important;
    }

    /* Create flex container for buttons */
    .controls {
        display: flex;
        flex-wrap: wrap;
        gap: 0.2rem;
        align-items: center;
    }

    .file-status {
        flex: 1 100%;
    }

    .search-container,
    .manufacturer-filter-container {
        flex: 1 100%;
    }

    .file-status {
        display: none !important;
        padding: 0.4rem;
        font-size: 0.75rem;
    }

    .file-status small {
        display: none;
    }

    .pagination-container {
        padding: 0.3rem;
        gap: 0.25rem;
        overflow-x: hidden;
    }

    .pagination-info {
        font-size: 0.6rem;
        word-wrap: break-word;
    }

    .pagination-controls {
        gap: 0.15rem;
    }

    .pagination-btn {
        padding: 0.25rem 0.35rem;
        font-size: 0.6rem;
        min-width: 30px;
    }

    .page-input {
        width: 32px;
        padding: 0.25rem;
        font-size: 0.6rem;
    }

    table {
        font-size: 0.65rem;
        table-layout: fixed;
        min-width: 520px;
    }

    th {
        padding: 0.35rem 0.2rem;
        font-size: 0.65rem;
        overflow: hidden;
    }

    th:nth-child(1) { width: 40px; }
    th:nth-child(2) { width: 60px; }
    th:nth-child(3) { width: 200px; }
    th:nth-child(4) { width: 40px; }
    th:nth-child(n+5) { width: 40px; }

    td {
        padding: 0.3rem 0.2rem;
        font-size: 0.65rem;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .stat-number {
        font-size: 1rem;
    }

    .notify-btn {
        font-size: 0.85rem;
        padding: 0.1rem 0.2rem;
    }

    /* Hide "Cacher" column and "Gérer les cachés" button on mobile */
    table th:nth-child(2),
    table td:nth-child(2),
    .hide-btn,
    #manageHiddenBtn {
        display: none !important;
        visibility: hidden !important;
        width: 0 !important;
        height: 0 !important;
        padding: 0 !important;
        margin: 0 !important;
        border: none !important;
    }

    .version-display {
        height: 20px !important;
        line-height: 1.2 !important;
        top: 8px !important;
        white-space: nowrap;
        overflow: hidden;
    }
}