/* ======================================================
   Common Components & Interactive Elements
   ====================================================== */

button {
    border: none;
    border-radius: var(--radius-small);
    background: var(--primary-color);
    color: white;
    cursor: pointer;
}

button:hover {
    opacity: .9;
}

input {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-small);
    padding: 8px;
    box-sizing: border-box;
    background-color: var(--input-bg);
    color: var(--text-color);
}

.section-divider {
    margin-top: 5px;
    margin-bottom: 10px;
    padding-bottom: 5px;
    border-bottom: 2px solid var(--border-color);
    font-size: 16px;
    font-weight: bold;
    color: #333;
}

[data-theme="dark"] .section-divider {
    color: #cbd5e1;
}

/* User Info Section */
.user-info-row {
    display: flex;
    gap: 20px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.user-info-item {
    min-width: 150px;
}

.user-info-label {
    font-size: 11px;
    color: var(--sub-text-color);
    margin-bottom: 2px;
}

.user-info-value {
    font-size: 16px;
    font-weight: bold;
}

/* Search Condition Row */
.search-row {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.search-group {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 220px;
}

.search-group label {
    font-size: 14px;
    font-weight: bold;
    margin-bottom: 0;
    white-space: nowrap;
}

.search-group input {
    flex: 1;
    height: 34px;
    padding-left: 8px;
    font-size: 14px;
    box-sizing: border-box;
}

.search-group input[list] {
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%2364748b'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 18px;
    padding-right: 28px;
    cursor: pointer;
}

.search-group input[list]::-webkit-calendar-picker-indicator {
    opacity: 0;
    cursor: pointer;
}

.search-group .static-value {
    padding: 6px 10px;
    background: var(--table-header-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-small);
    font-size: 14px;
}

/* Action Buttons Area */
.action-buttons {
    display: flex;
    gap: 8px;
    margin-bottom: 15px;
}

.action-buttons button {
    min-width: 100px;
    height: 36px;
    font-size: 14px;
}

/* ======================================================
   Data Tables
   ====================================================== */

.table-container {
    flex: 1;
    overflow: auto; /* Enable both horizontal and vertical scrolling */
    border: 1px solid var(--border-color);
    min-height: 0;
    -webkit-overflow-scrolling: touch; /* Momentum scrolling for iOS */
    will-change: transform; /* Hint GPU rendering for ultra-smooth scrolls */
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--table-header-bg);
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    text-align: left;
    white-space: nowrap;
}

.data-table th.sortable {
    cursor: pointer;
    user-select: none;
    padding-right: 25px;
}

.data-table th.sortable::after {
    content: "▲▼";
    position: absolute;
    right: 8px;
    font-size: 10px;
    color: #999;
    letter-spacing: -2px;
}

.data-table th.sort-asc::after {
    content: "▲";
    color: var(--primary-color);
}

.data-table th.sort-desc::after {
    content: "▼";
    color: var(--primary-color);
}

.data-table td {
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    white-space: nowrap;
}

.data-table tbody tr:hover {
    background: var(--table-hover-bg);
}

.data-table tbody tr.clickable {
    cursor: pointer;
}

.data-table tbody tr.clickable:hover {
    background: var(--table-clickable-hover);
}

.data-table tbody tr.selected {
    background: #dbeafe;
}

.data-table tbody tr.search-match {
    background-color: #d1e9ff !important;
}

[data-theme="dark"] .data-table tbody tr.selected {
    background: #1e3a8a;
}

.thumbnail {
    width: 80px;
    height: 60px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    object-fit: cover;
}

/* ==========================================================================
   Help Modal UI Component
   ========================================================================== */
.header-help {
    height: 36px;
    padding: 0 12px;
    border: 1px solid rgba(255,255,255,.5);
    border-radius: var(--radius-small, 4px);
    background: transparent;
    color: var(--header-text, #ffffff);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    margin-right: 8px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 4px;
}

.header-help:hover {
    background: rgba(255,255,255,.1);
    border-color: rgba(255,255,255,.8);
}

.help-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    transition: opacity 0.25s ease;
}

.help-modal.open {
    display: flex;
    align-items: center;
    justify-content: center;
}

.help-modal-content {
    background-color: var(--card-bg, #ffffff);
    color: var(--text-color, #1e293b);
    border-radius: var(--radius-large, 8px);
    width: 90%;
    max-width: 600px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--border-color, #e2e8f0);
    display: flex;
    flex-direction: column;
    max-height: 85vh;
    animation: helpModalSlide 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes helpModalSlide {
    from { transform: translateY(-30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.help-modal-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color, #e2e8f0);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.help-modal-header h2 {
    font-size: 18px;
    font-weight: 800;
    margin: 0;
    color: var(--primary-color, #1e3a8a);
}

.help-modal-close {
    background: transparent;
    border: none;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    color: #94a3b8;
    line-height: 1;
}

.help-modal-close:hover {
    color: #ef4444;
}

.help-modal-body {
    padding: 24px;
    overflow-y: auto;
    line-height: 1.6;
    white-space: normal; /* テーブル等の white-space: nowrap を打ち消し */
}

.help-modal-body h3 {
    margin-top: 0;
    font-size: 16px;
    font-weight: 800;
    border-left: 4px solid var(--primary-color, #3b82f6);
    padding-left: 8px;
    margin-bottom: 12px;
}

.help-modal-body p {
    font-size: 14px;
    color: var(--text-color, #475569);
    margin-bottom: 16px;
}

.help-modal-body ol, .help-modal-body ul {
    margin: 0;
    padding-left: 20px;
    margin-bottom: 16px;
}

.help-modal-body li {
    font-size: 13.5px;
    margin-bottom: 8px;
}

.help-modal-body .help-warning-box {
    background-color: #fffbeb;
    border: 1px solid #fef3c7;
    border-left: 4px solid #f59e0b;
    border-radius: 6px;
    padding: 12px;
    font-size: 13px;
    color: #b45309;
}

/* ダークテーマへのアダプティブ対応 */
[data-theme="dark"] .help-modal-body .help-warning-box {
    background-color: #2d2112;
    border-color: #451a03;
    color: #fcd34d;
}

.help-modal-footer {
    padding: 12px 24px;
    border-top: 1px solid var(--border-color, #e2e8f0);
    display: flex;
    justify-content: flex-end;
}

@media (max-width: 480px) {
    .help-modal-content {
        width: 95%;
        max-height: 92vh;
        border-radius: 8px;
    }
    .help-modal-body {
        padding: 16px;
    }
    .help-modal-header {
        padding: 12px 16px;
    }
    .help-modal-footer {
        padding: 8px 16px;
    }
}

/* ======================================================
   Responsive Components Overrides
   ====================================================== */

.filter-accordion-toggle {
    display: none; /* Hidden by default on desktop */
}

@media (max-width: 1024px) {
    .search-row {
        gap: 8px;
    }
    .search-group {
        min-width: 100%; /* Stack search filters vertically on smaller screens */
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
    .search-group label {
        font-size: 13px;
    }
    .search-group input {
        width: 100%;
    }
    .action-buttons {
        flex-wrap: wrap;
        gap: 6px;
        width: 100%;
    }
    .action-buttons button {
        flex: 1;
        min-width: calc(50% - 3px);
        font-size: 13px;
    }
    .user-info-row {
        gap: 10px;
    }
    .user-info-item {
        min-width: calc(50% - 5px);
    }
    .user-info-value {
        font-size: 14px;
    }

    /* Mobile Filter Accordion Styles */
    .filter-accordion-toggle {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        padding: 12px 16px;
        background-color: var(--table-header-bg, #f8fafc);
        border: 2px solid var(--border-color, #e2e8f0);
        border-radius: var(--radius-medium, 8px);
        font-size: 14px;
        font-weight: bold;
        color: var(--primary-color, #1e3a8a);
        cursor: pointer;
        margin-bottom: 12px;
        transition: all 0.2s ease;
        box-shadow: 0 1px 3px rgba(0,0,0,0.05);
        box-sizing: border-box;
    }

    .filter-accordion-toggle:hover {
        background-color: var(--table-clickable-hover, #f1f5f9);
    }

    .filter-accordion-toggle .arrow {
        transition: transform 0.2s ease;
    }

    .filter-accordion-wrapper-mobile-only {
        border: 2px solid var(--border-color, #e2e8f0);
        border-radius: var(--radius-medium, 8px);
        background: var(--card-bg, #ffffff);
        padding: 12px;
        margin-bottom: 15px;
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
        box-sizing: border-box;
    }

    /* Wrap dense fields in mobile view inside the wrapper */
    .filter-accordion-wrapper-mobile-only .search-row,
    .filter-accordion-wrapper-mobile-only .action-buttons {
        margin-bottom: 12px !important;
    }
    
    .filter-accordion-wrapper-mobile-only .action-buttons:last-child {
        margin-bottom: 0 !important;
    }

    .filter-accordion-content-mobile-collapsed {
        display: none; /* Collapse dense forms on mobile by default */
        margin-top: 12px;
        border-top: 1px dashed var(--border-color, #cbd5e1);
        padding-top: 12px;
    }

    .filter-accordion-content-mobile-collapsed.open {
        display: block !important;
        animation: accordionSlideDown 0.22s ease-out;
    }

    .filter-accordion-toggle.open .arrow {
        transform: rotate(180deg);
    }
}

@keyframes accordionSlideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 480px) {
    .action-buttons button {
        min-width: 100%; /* Fully stack buttons on mobile */
    }
    .user-info-item {
        min-width: 100%; /* Fully stack user info */
    }
}


/* ======================================================
   Environment Badge System
   ====================================================== */
.env-badge {
    display: inline-block;
    padding: 8px 18px;
    font-size: 13px;
    font-weight: 800;
    border-radius: var(--radius-large, 100px);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
    margin-top: 5px;
    transition: all 0.3s ease;
    color: #ffffff !important; /* Force high contrast white text */
}

.env-badge-mini {
    display: inline-block;
    padding: 3px 8px;
    font-size: 10px;
    font-weight: 900;
    border-radius: 4px;
    margin-left: 10px;
    margin-right: 5px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    vertical-align: middle;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
    color: #ffffff !important; /* Force high contrast white text */
}

.env-local {
    background-color: #10b981; /* High contrast Emerald Green */
    border: 1px solid #047857;
}

.env-develop {
    background-color: #06b6d4; /* High contrast Cyan / Teal */
    border: 1px solid #0e7490;
}

.env-staging {
    background-color: #f59e0b; /* High contrast Amber / Orange */
    border: 1px solid #b45309;
}

.env-production {
    background-color: #ef4444; /* High contrast Vivid Red */
    border: 1px solid #b91c1c;
    animation: env-pulse 1.5s infinite alternate;
}

@keyframes env-pulse {
    0% {
        box-shadow: 0 0 4px 1px rgba(239, 68, 68, 0.4);
    }
    100% {
        box-shadow: 0 0 12px 4px rgba(239, 68, 68, 0.6);
    }
}



