/* ==================== 관리자 설정 페이지 스타일 ==================== */

/* 설정 페이지 전체 컨테이너 */
#settingsView,
#settingsContentArea {
    width: 100%;
    padding: 0;
    margin: 0;
}

/* settingsView도 왼쪽에 완전히 붙이기 */
#settingsView {
    margin: 0;
    padding: 0;
    width: 100%;
}

/* adminSettingsContainer도 명시적으로 설정 */
#adminSettingsContainer {
    margin: 0;
    padding: 0;
    width: 100%;
}

/* 설정 컨테이너 - 세로 배치 */
.settings-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    min-height: calc(100vh - 100px);
    padding: 1.5rem !important;
    background: #f9fafb;
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    box-sizing: border-box;
}

/* 설정 사이드바 - 가로 배치 */
.settings-sidebar {
    width: 100%;
    background: white;
    border-radius: 12px;
    padding: 1rem 1.5rem 1rem 1.5rem;  /* 내부 콘텐츠 간격 확보 */
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    box-sizing: border-box;
}

.settings-sidebar h3 {
    margin: 0 0 0.75rem 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: #1a1a1a;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* 설정 메뉴 리스트 - 가로 1줄 */
.settings-menu {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: row;
    gap: 0.5rem;
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.settings-menu::-webkit-scrollbar {
    height: 6px;
}

.settings-menu::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.settings-menu::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 10px;
}

.settings-menu::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.settings-menu li {
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: #6b7280;
    border: 1px solid transparent;
    white-space: nowrap;
    flex-shrink: 0;
}

.settings-menu li:hover {
    background: #f3f4f6;
    color: #374151;
}

.settings-menu li.active {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.settings-menu li .icon {
    font-size: 1rem;
}

/* 설정 콘텐츠 영역 (너비 확장) */
.settings-content {
    flex: 1;
    background: white;
    border-radius: 12px;
    padding: 2rem 2rem 2rem 2rem;  /* 명시적 padding */
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    width: 100%;
    box-sizing: border-box;
}

/* 설정 섹션 */
.settings-section {
    animation: fadeIn 0.3s ease;
    width: 100%;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 섹션 헤더 */
.section-header {
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #e5e7eb;
}

.section-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1a1a1a;
    margin: 0 0 0.5rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.section-desc {
    color: #6b7280;
    font-size: 0.9rem;
    margin: 0;
    line-height: 1.5;
}

/* 투어 테이블 - 헤더 고정 */
.tours-list,
.booking-sources-list {
    margin-top: 1rem;
    max-height: 500px;
    overflow-y: auto;
    overflow-x: auto;
    position: relative;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    width: 100%;
    -webkit-overflow-scrolling: touch;
}

.data-table {
    width: 100%;
    min-width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.data-table thead {
    background: #f9fafb;
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.data-table thead th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: #374151;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 2px solid #e5e7eb;
    background: #f9fafb;
}

.data-table tbody tr {
    border-bottom: 1px solid #e5e7eb;
    transition: background 0.2s ease;
}

.data-table tbody tr:hover {
    background: #f9fafb;
}

.data-table tbody td {
    padding: 1rem;
    color: #4b5563;
    font-size: 0.95rem;
}

/* 상태 배지 */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.375rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
}

.status-badge.active {
    background: #dcfce7;
    color: #16a34a;
}

.status-badge.inactive {
    background: #fee2e2;
    color: #dc2626;
}

/* 빈 상태 */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: #9ca3af;
}

.empty-state p {
    margin: 0.5rem 0;
    font-size: 1rem;
}

.empty-state p:first-child {
    font-size: 1.25rem;
    font-weight: 600;
    color: #6b7280;
}

/* 알림 박스 */
.alert {
    padding: 1rem 1.25rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.alert strong {
    font-weight: 600;
}

.alert p {
    margin: 0;
    font-size: 0.95rem;
}

.alert-info {
    background: #eff6ff;
    border-left: 4px solid #3b82f6;
    color: #1e40af;
}

.alert-success {
    background: #f0fdf4;
    border-left: 4px solid #22c55e;
    color: #15803d;
}

.alert-warning {
    background: #fffbeb;
    border-left: 4px solid #f59e0b;
    color: #b45309;
}

/* 템플릿 그리드 */
.templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

/* 템플릿 카드 */
.template-card {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 1.5rem;
    transition: all 0.3s ease;
}

.template-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    border-color: #3b82f6;
}

.template-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e5e7eb;
}

.template-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #1a1a1a;
    margin: 0;
}

.template-content {
    background: white;
    border-radius: 6px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.template-content pre {
    margin: 0;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-size: 0.85rem;
    line-height: 1.6;
    color: #4b5563;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.template-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    flex-wrap: wrap;
}

/* 폼 그룹 */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #374151;
    font-size: 0.95rem;
}

.form-group small {
    display: block;
    margin-top: 0.375rem;
    color: #6b7280;
    font-size: 0.85rem;
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 0.95rem;
    transition: all 0.2s ease;
    background: white;
    box-sizing: border-box;
}

.form-control:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-control:disabled {
    background: #f3f4f6;
    cursor: not-allowed;
}

/* 체크박스 라벨 */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    font-weight: 500;
    color: #374151;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* 폼 버튼 그룹 */
.form-buttons {
    display: flex;
    gap: 0.75rem;
    margin-top: 2rem;
    flex-wrap: wrap;
}

/* 폼 행 */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

/* 템플릿 타입 배지 */
.template-type-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    background: #e0e7ff;
    color: #4338ca;
    margin-top: 0.5rem;
}


/* 가로 모드 최적화 */
@media (max-height: 600px) and (orientation: landscape) {
    .settings-container {
        padding: 1rem;
    }
    
    .section-header {
        margin-bottom: 1rem;
    }
    
    .tours-list,
    .booking-sources-list {
        max-height: 300px;
    }
}

/* 터치 디바이스 최적화 */
@media (hover: none) and (pointer: coarse) {
    .settings-menu li {
        min-height: 44px;
    }

    /* 설정 화면 전용 — 전역 button/.form-control에 걸면 앱 전체 버튼이
       터치 기기에서 44px로 부풀어 인박스 정렬·시트복사 등이 커진다 */
    .settings-container .form-control {
        min-height: 44px;
    }

    .settings-container button {
        min-height: 44px;
    }
}

/* ==================== 부모 컨테이너 재정의 (깔끔한 방법) ==================== */

/* 설정 페이지 전용 레이아웃 재정의 - 강력한 선택자 */
div#adminSettingsContent {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0;
}

div#adminSettingsContainer {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0;
}

div#settingsView {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0;
}

/* ==================== settings-container 구체적 타겟팅 ==================== */

/* 관리자 설정 페이지 내부의 settings-container는 무조건 왼쪽 정렬 */
/* 11-settings-teacher.css의 중앙 정렬 스타일 덮어쓰기 */
div#adminSettingsContent .settings-container,
div#adminSettingsContainer .settings-container,
div#settingsView .settings-container {
    max-width: none;     /* 11-settings-teacher.css의 max-width: 1200px 덮어쓰기 */
    margin: 0;           /* 11-settings-teacher.css의 margin: 0 auto 덮어쓰기 */
    margin-left: 0;      /* 명시적 왼쪽 정렬 */
    width: 100%;
}

/* ==================== 통합 설정 셸 · 투어 관리 ==================== */
.tour-settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.tour-settings-header-actions {
    display: flex;
    gap: 0.5rem;
}

.tour-settings-add-button {
    min-height: 42px;
    padding: 0.625rem 1.125rem;
    border: 0;
    border-radius: 7px;
    background: #2563eb;
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
}

.tour-settings-toolbar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    padding: 0.875rem;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #f8fafc;
}

.tour-settings-search {
    flex: 1 1 320px;
    min-width: 0;
}

.tour-settings-search input {
    width: 100%;
    min-height: 42px;
    box-sizing: border-box;
    padding: 0.625rem 0.875rem;
    border: 1px solid #cbd5e1;
    border-radius: 7px;
    background: #fff;
    color: #0f172a;
    font-size: 14px;
}

.tour-settings-search input:focus {
    outline: 0;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.tour-settings-filter-group {
    display: flex;
    flex: 0 0 auto;
    gap: 0.5rem;
}

.tour-filter-button {
    min-height: 42px;
    white-space: nowrap;
}

.tour-settings-grid {
    display: grid;
    gap: 0.75rem;
}

.tour-settings-card {
    padding: 1.25rem;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #fff;
}

.tour-settings-card-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

.tour-settings-card-main {
    flex: 1 1 auto;
    min-width: 0;
}

.tour-settings-title-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.tour-settings-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.25rem;
    margin-top: 0.5rem;
    color: #64748b;
    font-size: 14px;
}

.tour-settings-card-actions {
    display: flex;
    flex: 0 0 auto;
    gap: 0.5rem;
}

.tour-settings-action {
    min-height: 38px;
}

@media (max-width: 768px) {
    div#adminSettingsContent .settings-container,
    div#adminSettingsContainer .settings-container,
    div#settingsView .settings-container {
        min-width: 0 !important;
        padding: 16px 12px 28px !important;
        gap: 1rem;
    }

    .settings-content {
        padding: 1rem;
        border-radius: 8px;
    }

    .templates-grid {
        grid-template-columns: 1fr;
        gap: 0.875rem;
    }

    .form-row {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .tour-settings-header {
        gap: 0.75rem;
        margin-bottom: 1rem;
    }

    .tour-settings-header-actions {
        margin-left: auto;
    }

    .tour-settings-add-button {
        min-height: 42px;
        padding: 0.625rem 0.875rem;
        white-space: nowrap;
    }

    .tour-settings-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 0.625rem;
        margin-bottom: 0.875rem;
        padding: 0.75rem;
    }

    .tour-settings-search {
        flex-basis: auto;
    }

    .tour-settings-filter-group {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 0.375rem;
    }

    .tour-filter-button {
        width: 100%;
        min-width: 0;
        padding: 0.5rem 0.25rem !important;
        font-size: 12px !important;
    }

    .tour-settings-card {
        padding: 0.875rem;
    }

    .tour-settings-card-row {
        flex-direction: column;
        gap: 0.75rem;
    }

    .tour-settings-title-row {
        gap: 0.375rem;
    }

    .tour-settings-title-row h4 {
        max-width: 100%;
        overflow-wrap: anywhere;
    }

    .tour-settings-meta {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 0.375rem;
        font-size: 12px;
    }

    .tour-settings-meta span {
        min-width: 0;
        white-space: nowrap;
    }

    .tour-settings-card-actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        width: 100%;
    }

    .tour-settings-action {
        width: 100%;
        min-height: 42px;
    }
}

@media (max-width: 380px) {
    .tour-settings-meta {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
