/* 768px 이상: 미리보기(왼쪽) · 설정(오른쪽) 좌우 배치 */
@media (min-width: 768px) {
    .banner-layout-row {
        align-items: flex-start;
        flex-wrap: nowrap;
    }

    .banner-settings-col {
        min-width: 0; /* 플렉스에서 줄바꿈 방지, 설정 카드가 오른쪽에 유지 */
    }

    .banner-settings-col .card,
    .banner-settings-card {
        min-width: 0;
    }

    /* 설정 카드 컴팩트 모드 */
    .banner-settings-card .card-header {
        padding: 0.5rem 0.75rem;
    }

    .banner-settings-card .card-header h5 {
        font-size: 0.95rem;
    }

    .banner-settings-card .card-body {
        padding: 0.75rem;
    }

    .banner-settings-card .nav-tabs {
        margin-bottom: 0.5rem;
    }

    .banner-settings-card .nav-tabs .nav-link {
        padding: 0.4rem 0.6rem;
        font-size: 0.8rem;
        margin-right: 2px;
    }

    .banner-settings-card .tab-pane {
        min-height: 0;
        padding: 0.5rem 0;
    }

    .banner-settings-card .compact-settings .form-label {
        font-size: 0.75rem;
        margin-bottom: 0.25rem;
    }

    .banner-settings-card .compact-settings .form-control,
    .banner-settings-card .compact-settings .form-select {
        padding: 0.35rem 0.5rem;
        font-size: 0.8rem;
    }


    .banner-settings-card .compact-settings .row {
        --bs-gutter-x: 0.5rem;
        --bs-gutter-y: 0.5rem;
    }

    .banner-settings-card .compact-settings .mb-2,
    .banner-settings-card .compact-settings .mb-3 {
        margin-bottom: 0.5rem !important;
    }

    .banner-settings-card .btn-group .btn {
        padding: 0.25rem 0.5rem;
        font-size: 0.8rem;
    }

    .banner-settings-card .compact-settings select.form-select,
    .banner-settings-card .compact-settings input.form-control {
        max-width: 100%;
    }
}

.banner-preview-container {
    text-align: center;
    min-height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
    max-width: 100%;
    padding: 10px;
}

/* 탭 네비게이션 스타일 */
.nav-tabs {
    border-bottom: 2px solid #e9ecef;
}

.nav-tabs .nav-link {
    border: none;
    border-radius: 8px 8px 0 0;
    color: var(--text-muted);
    font-weight: 600;
    padding: 12px 20px;
    margin-right: 4px;
    transition: all 0.3s ease;
}

.nav-tabs .nav-link:hover {
    border: none;
    color: #3b6fe0;
    background: #ffffff;
}

.nav-tabs .nav-link.active {
    background: linear-gradient(135deg, #3b6fe0 0%, #2c56b8 100%);
    color: white;
    border: none;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.tab-content {
    padding-top: 0;
}

.tab-pane {
    min-height: 400px;
    padding: 1rem 0;
}

/* 컴팩트 설정 스타일 */
.compact-settings {
    padding: 0 0.5rem;
}

.compact-settings .form-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.compact-settings .form-label-xs {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 3px;
}

.compact-settings .form-label-sm {
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 5px;
}

/* 텍스트 탭: 왼쪽 텍스트+색상, 오른쪽 range 세로 배치 */
.text-tab-layout {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-start;
}

.text-tab-left {
    flex: 1 1 200px;
    min-width: 0;
}

.text-tab-right {
    flex: 0 0 auto;
    width: 200px;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.text-input-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.text-input-row .form-label {
    flex: 0 0 72px;
    font-size: 0.75rem;
    margin-bottom: 0;
    white-space: nowrap;
}

.text-input-row .form-control {
    flex: 1;
    min-width: 0;
    padding: 0.3rem 0.5rem;
    font-size: 0.8125rem;
    min-height: auto;
}

.text-input-row .text-color-btn {
    flex: 0 0 auto;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0.15rem;
    cursor: pointer;
    border-radius: 4px;
}

.range-row {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.range-row .form-label {
    font-size: 0.75rem;
    margin-bottom: 0;
}

.range-wrap {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.range-wrap .form-range {
    flex: 1;
    min-width: 0;
    margin: 0;
}

.range-wrap .range-value {
    flex: 0 0 auto;
    min-width: 2.8em;
    font-size: 0.75rem;
    text-align: right;
}

/* 왼쪽 정렬 행: 버튼 그룹 크기만큼만 */
.text-tab-left .align-row .btn-group {
    flex: 0 0 auto;
}

.text-tab-left .align-row .btn-group .btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
}

@media (max-width: 575px) {
    .text-tab-right {
        width: 100%;
    }
}

/* 텍스트 탭: 기타 컴포넌트 크기 */
#text-content .form-label {
    font-size: 0.75rem;
    margin-bottom: 0.2rem;
}

#text-content .form-control,
#text-content .form-select {
    padding: 0.35rem 0.5rem;
    font-size: 0.8125rem;
    min-height: auto;
    height: auto;
}

#text-content .form-control-color {
    width: 2.25rem;
    height: 2.25rem;
    padding: 0.15rem;
    cursor: pointer;
}

#text-content .range-value {
    font-size: 0.75rem;
}

#text-content .row.g-2 {
    --bs-gutter-x: 0.5rem;
    --bs-gutter-y: 0.35rem;
}

.compact-settings .form-range-sm {
    height: 6px;
}

.compact-settings .range-value-sm {
    display: inline-block;
    min-width: 30px;
    text-align: center;
    font-weight: 600;
    color: #ffffff;
    background: linear-gradient(135deg, #3b6fe0 0%, #2c56b8 100%);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    box-shadow: 0 1px 3px rgba(102, 126, 234, 0.3);
}

.compact-settings .form-control-color-sm {
    width: 100%;
    height: 30px;
    border-radius: 4px;
    border: 2px solid #dee2e6;
}

.compact-settings .mb-1 {
    margin-bottom: 0.5rem !important;
}

.compact-settings .mb-2 {
    margin-bottom: 0.75rem !important;
}

.compact-settings .mb-3 {
    margin-bottom: 1rem !important;
}

/* 탭별 일관된 여백 - 활성 탭에만 적용 */
.tab-pane .row.mb-3:last-child {
    margin-bottom: 0 !important;
}

.tab-pane .mb-2 {
    margin-bottom: 0.75rem !important;
}

/* 각 탭 콘텐츠의 여백 통일 */
#text-content,
#size-content,
#background-content,
#frame-content {
    padding: 0;
    margin: 0;
}

/* 프레임 옵션 여백 조정 */
.frame-options .row {
    margin-bottom: 0;
}

/* 폼 요소들의 일관된 간격 */
.compact-settings .form-control,
.compact-settings .form-select,
.compact-settings .form-range {
    margin-bottom: 0.5rem;
}

/* 버튼 그룹 여백 */
.compact-settings .btn-group {
    margin-bottom: 0.5rem;
}

/* 반응형 탭 디자인 */
@media (max-width: 768px) {
    .nav-tabs .nav-link {
        padding: 8px 12px;
        font-size: 14px;
    }

    .nav-tabs .nav-link i {
        display: none;
    }

    .tab-pane {
        min-height: 300px;
        padding: 0.5rem 0;
    }

    .compact-settings {
        padding: 0 0.25rem;
    }

    .border-frame-selector, .image-frame-selector {
        grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
        gap: 8px;
    }

    #text-content,
    #size-content,
    #background-content,
    #frame-content {
        padding-top: 0;
        padding-bottom: 0;
    }
}

#bannerCanvas {
    max-width: 100%;
    max-height: 400px;
    height: auto;
    width: auto;
    box-shadow: 0 4px 6px rgba(27, 30, 36, 0.05);
    border-radius: 8px;
}

.template-card {
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border: 2px solid transparent;
    border-radius: 8px;
    overflow: hidden;
}

.template-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(27, 30, 36, 0.075);
    border-color: var(--bs-primary);
}

.template-preview {
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(27, 30, 36, 0.16);
}

.template-name {
    display: block;
    padding: 8px;
    text-align: center;
    background: #ffffff;
    color: var(--text-muted);
    font-weight: 500;
}

.form-control-color {
    width: 100%;
    height: 38px;
    border-radius: 6px;
}

.btn-group .btn-check:checked + .btn {
    background-color: var(--bs-primary);
    border-color: var(--bs-primary);
    color: white;
}






.btn-outline-success {
    border-radius: 8px;
    padding: 10px 20px;
    font-weight: 600;
}

.form-select,

.form-select:focus,

.form-check-input:checked {
    background-color: #3b6fe0;
    border-color: #3b6fe0;
}

/* 배경 이미지 미리보기 */
#backgroundImagePreview {
    padding: 10px;
    background: #ffffff;
    border-radius: 8px;
    border: 2px dashed #dee2e6;
}

#backgroundImageThumb {
    border: 2px solid #dee2e6;
    box-shadow: 0 2px 4px rgba(27, 30, 36, 0.05);
}

/* range 슬라이더: 심플, 일반 높이 */
.form-range {
    height: 6px;
    padding: 0;
    margin: 0.5rem 0;
    background: transparent;
    border: none;
    outline: none;
    cursor: pointer;
}

.form-range::-webkit-slider-runnable-track {
    height: 6px;
    background: var(--border-color-light, #dee2e6);
    border-radius: 3px;
}

.form-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    margin-top: -6px;
    background: var(--accent-primary, #0d6efd);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.15s;
}

.form-range::-webkit-slider-thumb:hover {
    background: var(--accent-primary-light, #0b5ed7);
}

.form-range::-moz-range-track {
    height: 6px;
    background: var(--border-color-light, #dee2e6);
    border-radius: 3px;
    border: none;
}

.form-range::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: var(--accent-primary, #0d6efd);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.15s;
}

.form-range::-moz-range-thumb:hover {
    background: var(--accent-primary-light, #0b5ed7);
}

.compact-settings .form-range-sm {
    height: 6px;
}

.compact-settings .form-range-sm::-webkit-slider-thumb {
    width: 18px;
    height: 18px;
    margin-top: -6px;
}

.compact-settings .form-range-sm::-moz-range-thumb {
    width: 18px;
    height: 18px;
}

/* range 값 표시: 심플 */
.range-value {
    display: inline-block;
    min-width: 2.5em;
    text-align: center;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary, #6c757d);
}

/* 프레임 선택 스타일 */
.frame-options {
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
}

.frame-options .form-label {
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.border-frame-selector, .image-frame-selector {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 12px;
    padding: 0.5rem 0;
}

.border-frame-option {
    position: relative;
    cursor: pointer;
    border: 3px solid transparent;
    border-radius: 12px;
    padding: 10px;
    background: #ffffff;
    transition: all 0.3s ease;
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.border-frame-option:hover {
    border-color: #3b6fe0;
    background: #e7f1ff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

.border-frame-option.selected {
    border-color: #3b6fe0;
    background: linear-gradient(135deg, #e7f1ff 0%, #f0f8ff 100%);
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.3);
}

.border-frame-preview {
    width: 80px;
    height: 50px;
    background: var(--bg-card);
    border-radius: 4px;
    position: relative;
    overflow: hidden;
}

.border-frame-preview::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, #3b6fe0 0%, #2c56b8 100%);
    opacity: 0.1;
}

/* 각 프레임 스타일 */
.border-frame-preview.frame-none {
    border: none;
}

.border-frame-preview.frame-solid {
    border: 3px solid #3b6fe0;
}

.border-frame-preview.frame-dashed {
    border: 3px dashed #3b6fe0;
}

.border-frame-preview.frame-dotted {
    border: 3px dotted #3b6fe0;
}

.border-frame-preview.frame-double {
    border: 6px double #3b6fe0;
}

.border-frame-preview.frame-groove {
    border: 4px groove #3b6fe0;
}

.border-frame-preview.frame-ridge {
    border: 4px ridge #3b6fe0;
}

.border-frame-preview.frame-inset {
    border: 4px inset #3b6fe0;
}

.border-frame-preview.frame-outset {
    border: 4px outset #3b6fe0;
}

.border-frame-preview.frame-shadow {
    border: 2px solid #3b6fe0;
    box-shadow: 0 2px 10px rgba(102, 126, 234, 0.5);
}

/* 이미지 프레임 옵션 스타일 */
.image-frame-option {
    position: relative;
    cursor: pointer;
    border: 2px solid transparent;
    border-radius: 8px;
    padding: 6px;
    background: #ffffff;
    transition: all 0.3s ease;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-frame-preview {
    width: 70px;
    height: 40px;
    border-radius: 3px;
    position: relative;
    overflow: hidden;
}

.image-frame-name {
    position: absolute;
    bottom: 3px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.6rem;
    font-weight: 500;
    color: var(--text-muted);
    background: #ffffff;
    padding: 1px 4px;
    border-radius: 3px;
    line-height: 1.1;
}

/* 각 이미지 프레임 스타일 */
.image-frame-preview.frame-vintage {
    background: linear-gradient(45deg, #8B4513, #D2B48C);
    border: 8px ridge #8B4513;
    box-shadow: inset 0 2px 10px rgba(139, 69, 19, 0.5);
}

.image-frame-preview.frame-modern {
    background: linear-gradient(135deg, #5b6472, #c9ced7);
    border: 4px solid #34495e;
    box-shadow: 0 3px 15px rgba(52, 73, 94, 0.3);
}

.image-frame-preview.frame-ornate {
    background: linear-gradient(45deg, #FFD700, #FFA500);
    border: 6px groove #FFD700;
    box-shadow: inset 0 2px 8px rgba(255, 215, 0, 0.6);
}

.image-frame-preview.frame-simple {
    background: linear-gradient(135deg, #ecf0f1, #bdc3c7);
    border: 2px solid #95a5a6;
}

.image-frame-preview.frame-wooden {
    background: linear-gradient(45deg, #8B4513, #CD853F);
    border: 10px solid;
    border-image: linear-gradient(45deg, #8B4513, #CD853F) 1;
    box-shadow: inset 0 3px 12px rgba(139, 69, 19, 0.4);
}

.image-frame-preview.frame-gold {
    background: linear-gradient(135deg, #FFD700, #FFA500);
    border: 6px solid #FFD700;
    box-shadow: 0 5px 20px rgba(255, 215, 0, 0.5), inset 0 2px 10px rgba(255, 215, 0, 0.3);
}

.image-frame-preview.frame-silver {
    background: linear-gradient(135deg, #C0C0C0, #808080);
    border: 5px solid #C0C0C0;
    box-shadow: 0 3px 15px rgba(192, 192, 192, 0.5);
}

.image-frame-preview.frame-polaroid {
    background: var(--bg-card);
    border: 15px solid #ffffff;
    border-bottom: 40px solid #ffffff;
    box-shadow: 0 4px 8px rgba(27, 30, 36, 0.15);
    position: relative;
}

.border-frame-name {
    position: absolute;
    bottom: 3px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.6rem;
    font-weight: 500;
    color: var(--text-muted);
    background: #ffffff;
    padding: 1px 4px;
    border-radius: 3px;
    line-height: 1.1;
}

/* 배경 타입 버튼 그룹 */
.btn-group .btn-check:checked + .btn {
    background: linear-gradient(135deg, #3b6fe0 0%, #2c56b8 100%);
    border-color: #3b6fe0;
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

/* 파일 업로드 스타일 개선 */
input[type="file"] {
    border: 2px dashed #dee2e6;
    border-radius: 8px;
    padding: 12px;
    background: #ffffff;
    transition: all 0.3s ease;
}

input[type="file"]:hover {
    border-color: #3b6fe0;
    background: #e7f1ff;
}

/* 반응형 디자인 */
@media (max-width: 768px) {
    .container {
        padding: 20px 15px;
    }

    .row {
        margin: 0 -10px;
    }

    .col-md-6,
    .col-md-3 {
        padding: 0 10px;
        margin-bottom: 20px;
    }

    .template-preview {
        height: 60px;
        font-size: 14px;
    }

    .banner-preview-container {
        min-height: 250px;
        padding: 10px;
    }

    #bannerCanvas {
        max-width: calc(100vw - 40px);
        max-height: 250px;
    }

    #backgroundImagePreview {
        text-align: center;
    }

    #backgroundImageThumb {
        max-width: 150px;
        max-height: 75px;
    }
}

@media (max-width: 480px) {
    .banner-preview-container {
        min-height: 200px;
        padding: 5px;
    }

    #bannerCanvas {
        max-width: calc(100vw - 30px);
        max-height: 200px;
    }
}

/* 로딩 스피너 */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #ffffff;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 알림 스타일 */

.alert-info {
    background: linear-gradient(135deg, #d1ecf1 0%, #bee5eb 100%);
    color: #0c5460;
}

.alert-success {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    color: #155724;
}

.alert-warning {
    background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
    color: #856404;
}

body.dark-theme .alert-warning {
    background: linear-gradient(135deg, #fdf0e3 0%, #f7e2c6 100%) !important;
    color: #96521f !important;
    border-color: #96521f !important;
}

.tool-page .alert-info {
    background: rgba(59, 111, 224, 0.12) !important;
    border-color: var(--accent-primary);
    color: var(--text-primary) !important;
}

.tool-page .alert-success {
    background: rgba(16, 185, 129, 0.15) !important;
    border-color: var(--accent-success);
    color: var(--text-primary) !important;
}