/* Custom styles for Japanese healthcare facility directory */

/* Japanese typography */
body {
    font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", Meiryo, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f8f9fa;
}

/* Navigation */
.navbar-brand {
    font-size: 1.5rem;
    color: #2c3e50 !important;
}

.navbar-nav .nav-link {
    font-weight: 500;
    color: #6c757d !important;
    transition: color 0.3s ease;
}

.navbar-nav .nav-link:hover {
    color: #007bff !important;
}

/* Cards */
.card {
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    border: none;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
}

.card-header {
    background-color: #053285;
    color: white;
    border-bottom: 1px solid #dee2e6;
    border-radius: 0.5rem 0.5rem 0 0 !important;
}

/* Tables */
.table {
    margin-bottom: 0;
    min-width: 940px; /* Ensure minimum table width */
}

.table th {
    border-top: none;
    font-weight: 600;
    color: #495057;
    font-size: 0.9rem;
    padding: 1rem 0.75rem;
    white-space: nowrap;
}

/* テーブルヘッダーの背景色を指定 */
.table-light th {
    background-color: #053285 !important;
    color: white !important;
    font-weight: 600 !important;
}

.table td {
    vertical-align: middle;
    padding: 1rem 0.75rem;
    font-size: 0.9rem;
}

.table-hover tbody tr:hover {
    background-color: rgba(0, 123, 255, 0.05);
}

/* Specific column widths for optimal layout */
.table th:nth-child(1), .table td:nth-child(1) { /* 事業 */
    width: 60px !important;
    min-width: 60px !important;
    max-width: 60px !important;
}

.table th:nth-child(2), .table td:nth-child(2) { /* 事業所名 */
    width: 170px !important;
    min-width: 170px !important;
    max-width: 170px !important;
}

.table th:nth-child(3), .table td:nth-child(3) { /* 所在地 */
    width: 300px !important;
    min-width: 300px !important;
    max-width: 300px !important;
}

.table th:nth-child(4), .table td:nth-child(4) { /* 電話番号 */
    width: 90px !important;
    min-width: 90px !important;
    max-width: 90px !important;
}

.table th:nth-child(5), .table td:nth-child(5) { /* 事業所番号 */
    width: 80px !important;
    min-width: 80px !important;
    max-width: 80px !important;
}

.table th:nth-child(6), .table th:nth-child(7), .table td:nth-child(6), .table td:nth-child(7) { /* PDFダウンロード */
    width: 70px !important;
    min-width: 70px !important;
    max-width: 70px !important;
    text-align: center !important;
}

/* Prevent text wrapping in phone column only */
.table td:nth-child(4) {
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

/* Address column specific styling - allow wrapping */
.table td:nth-child(3) {
    max-width: 300px !important;
    word-wrap: break-word !important;
    white-space: normal !important;
    line-height: 1.4 !important;
    padding: 0.8rem 0.75rem !important;
}

/* Admin table adjustments (has extra column for operations and drag handle) */
.admin-table {
    min-width: 1050px;
}

/* Drag and drop styles */
.drag-handle {
    cursor: grab;
    user-select: none;
    padding: 0.8rem 0.75rem !important;
    text-align: center;
    width: 30px !important;
    min-width: 30px !important;
    max-width: 30px !important;
}

.drag-handle:active {
    cursor: grabbing;
}

.sortable-row.sortable-ghost {
    opacity: 0.4;
    background-color: #f8f9fa;
}

.sortable-row.sortable-drag {
    background-color: #e3f2fd;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

.sortable-row:hover .drag-handle {
    color: #007bff !important;
}

/* Admin table column widths with drag handle */
.admin-table th:nth-child(1), .admin-table td:nth-child(1) { /* ドラッグハンドル */
    width: 30px !important;
    min-width: 30px !important;
    max-width: 30px !important;
}

.admin-table th:nth-child(2), .admin-table td:nth-child(2) { /* 事業 */
    width: 60px !important;
    min-width: 60px !important;
    max-width: 60px !important;
}

.admin-table th:nth-child(3), .admin-table td:nth-child(3) { /* 事業所名 */
    width: 170px !important;
    min-width: 170px !important;
    max-width: 170px !important;
}

.admin-table th:nth-child(4), .admin-table td:nth-child(4) { /* 所在地 */
    width: 300px !important;
    min-width: 300px !important;
    max-width: 300px !important;
}

.admin-table th:nth-child(5), .admin-table td:nth-child(5) { /* 電話番号 */
    width: 90px !important;
    min-width: 90px !important;
    max-width: 90px !important;
}

.admin-table th:nth-child(6), .admin-table td:nth-child(6) { /* 事業所番号 */
    width: 80px !important;
    min-width: 80px !important;
    max-width: 80px !important;
}

.admin-table th:nth-child(7), .admin-table th:nth-child(8) { /* PDFダウンロード */
    width: 70px !important;
    min-width: 70px !important;
    max-width: 70px !important;
    text-align: center;
}

.admin-table td:nth-child(7), .admin-table td:nth-child(8) { /* PDFダウンロード */
    text-align: center;
}

.admin-table th:nth-child(9) { /* 操作 */
    width: 100px;
    min-width: 100px;
}

@media (max-width: 1200px) {
    .admin-table {
        min-width: 870px;
    }
}

@media (max-width: 768px) {
    .admin-table {
        min-width: 950px;
    }
}

/* Buttons */
.btn {
    border-radius: 0.375rem;
    font-weight: 500;
    padding: 0.5rem 1rem;
    transition: all 0.3s ease;
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

.btn-primary {
    background-color: #007bff;
    border-color: #007bff;
}

.btn-primary:hover {
    background-color: #0056b3;
    border-color: #0056b3;
    transform: translateY(-1px);
}

.btn-outline-primary {
    color: #007bff;
    border-color: #007bff;
}

.btn-outline-primary:hover {
    background-color: #007bff;
    border-color: #007bff;
    color: white;
}

.btn-outline-danger {
    color: #dc3545;
    border-color: #dc3545;
}

.btn-outline-danger:hover {
    background-color: #dc3545;
    border-color: #dc3545;
    color: white;
}

/* Badges */
.badge {
    font-size: 0.8rem;
    padding: 0.375rem 0.75rem;
    font-weight: 500;
}

/* Remove gray background from facility number badges */
.badge.bg-secondary {
    background-color: transparent !important;
    color: #333 !important;
    border: 1px solid #dee2e6;
}

/* Custom orange badge for daycare facilities */
.badge.bg-orange {
    background-color: #fd7e14 !important;
    color: white !important;
}

/* Compact spacing for business type column */
.table td:first-child {
    padding-right: 0.5rem;
}

.table th:first-child {
    padding-right: 0.5rem;
}

/* Forms */
.form-label {
    font-weight: 600;
    color: #495057;
    margin-bottom: 0.5rem;
}

.form-control {
    border-radius: 0.375rem;
    border: 1px solid #ced4da;
    padding: 0.75rem 0.75rem;
    font-size: 0.9rem;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.form-control:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.form-text {
    font-size: 0.8rem;
    color: #6c757d;
}

/* Alerts */
.alert {
    border: none;
    border-radius: 0.5rem;
    font-weight: 500;
}

.alert-success {
    background-color: #d4edda;
    color: #155724;
}

.alert-danger {
    background-color: #f8d7da;
    color: #721c24;
}

/* Icons */
.fas {
    font-size: 1rem;
}

.fa-3x {
    font-size: 3rem;
}

.fa-5x {
    font-size: 5rem;
}

/* Empty states */
.text-muted {
    color: #6c757d !important;
}

/* Responsive design */
@media (max-width: 1400px) {
    .container {
        max-width: 100%;
        padding-left: 20px;
        padding-right: 20px;
    }
}

@media (max-width: 1200px) {
    .table {
        min-width: 840px;
    }
    
    .table th:nth-child(3) { /* 所在地 */
        width: 250px;
        min-width: 250px;
    }
    
    .table td:nth-child(3) {
        max-width: 250px;
    }
}

@media (max-width: 768px) {
    .container {
        padding-left: 5px;
        padding-right: 5px;
    }
    
    .table-responsive {
        font-size: 0.75rem;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .table {
        min-width: 905px; /* Increased to accommodate wider columns */
    }
    
    .table th:nth-child(1), .table td:nth-child(1) { /* 事業 */
        width: 80px !important;
        min-width: 80px !important;
        max-width: 80px !important;
    }
    
    .table th:nth-child(2), .table td:nth-child(2) { /* 事業所名 */
        width: 200px !important;
        min-width: 200px !important;
        max-width: 200px !important;
    }
    
    .table th:nth-child(3), .table td:nth-child(3) { /* 所在地 */
        width: 230px !important;
        min-width: 230px !important;
        max-width: 230px !important;
    }
    
    .table td:nth-child(1) { /* 事業 アイコンサイズ調整 */
        font-size: 0.8rem !important;
    }
    
    /* スマホ版バッジサイズ調整 */
    .table td:nth-child(1) .badge {
        font-size: 0.65rem !important;
        padding: 0.2rem 0.4rem !important;
        line-height: 1.1 !important;
    }
    
    .table td:nth-child(3) { /* 所在地 データ行のみ */
        font-size: 0.8rem !important;
        line-height: 1.2 !important;
    }
    
    .table th:nth-child(4), .table td:nth-child(4) { /* 電話番号 */
        width: 120px !important;
        min-width: 120px !important;
        max-width: 120px !important;
    }
    
    .table td:nth-child(4) { /* 電話番号 データ行のみ */
        font-size: 0.8rem !important;
        line-height: 1.2 !important;
    }
    
    .table th:nth-child(5), .table td:nth-child(5) { /* 事業所番号 */
        width: 110px !important;
        min-width: 110px !important;
        max-width: 110px !important;
    }
    
    .table td:nth-child(5) { /* 事業所番号 データ行のみ */
        font-size: 0.8rem !important;
        line-height: 1.2 !important;
    }
    
    .table th:nth-child(6), .table td:nth-child(6) { /* 重要事項説明書 */
        width: 110px !important;
        min-width: 110px !important;
        max-width: 110px !important;
    }
    
    .table th:nth-child(7), .table td:nth-child(7) { /* 運営規程 */
        width: 80px !important;
        min-width: 80px !important;
        max-width: 80px !important;
    }
    
    /* スマホ版テーブルヘッダーの文字サイズ調整 */
    .table th {
        font-size: 0.9rem !important;
    }
    
    .btn-group-sm .btn {
        padding: 0.125rem 0.25rem;
        font-size: 0.75rem;
    }
    
    .card-header .card-title {
        font-size: 1.1rem;
    }
    
    /* Smaller button icons for mobile */
    .table .btn-sm {
        padding: 0.2rem 0.3rem;
        font-size: 0.7rem;
    }
}

/* Footer */
footer {
    background-color: #f8f9fa !important;
    border-top: 1px solid #dee2e6;
    margin-top: auto;
}

/* Modal */
.modal-content {
    border-radius: 0.5rem;
    border: none;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

.modal-header {
    border-bottom: 1px solid #dee2e6;
    padding: 1rem 1.5rem;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    border-top: 1px solid #dee2e6;
    padding: 1rem 1.5rem;
}

/* Loading states */
.spinner-border-sm {
    width: 1rem;
    height: 1rem;
}

/* File input styling */
.form-control[type="file"] {
    padding: 0.375rem 0.75rem;
}

/* Japanese text improvements */
.fw-medium {
    font-weight: 500;
}

.text-break {
    word-break: break-word;
}

/* Print styles */
@media print {
    .navbar, .btn, .modal, footer {
        display: none !important;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid #dee2e6;
    }
    
    .table {
        font-size: 0.8rem;
    }
}

/* Treatment improvement page specific styles */
.treatment-section-title {
    font-size: 1.1rem !important;
    font-weight: 700 !important;
    color: #495057 !important;
}
