/* ============================================
   App-specific styles (Bootstrap 5.3 base)
   ============================================ */

/* ---- Global font override ---- */
body,
.modal, .form-control, .form-select, .btn {
    font-family: "Noto Sans KR", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ---- Navbar ---- */
.app-navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 48px;
    padding: 0 16px;
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    position: sticky;
    top: 0;
    z-index: 20;
}

.navbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.navbar-logo {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: linear-gradient(135deg, #1976D2, #1565C0);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.navbar-logo svg {
    stroke: #fff;
    fill: none;
}

.navbar-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: #1a1a2e;
    letter-spacing: -0.02em;
}

.navbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.navbar-user {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: #6b7280;
}

.navbar-user svg {
    stroke: #9ca3af;
    fill: none;
}

.navbar-logout-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    color: #6b7280;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 4px 10px;
    cursor: pointer;
    transition: all 0.15s;
    margin: 0;
    width: auto;
}

.navbar-logout-btn:hover {
    color: #dc2626;
    background: #fef2f2;
    border-color: #fecaca;
}

.navbar-logout-btn svg {
    stroke: currentColor;
    fill: none;
}


/* ---- Sidebar ---- */
.app-sidebar {
    width: 220px;
    min-width: 220px;
    background: #fff;
    border-right: 1px solid #e5e7eb;
    padding: 16px 12px;
    overflow-y: auto;
    height: calc(100vh - 48px);
    position: sticky;
    top: 48px;
}

.sidebar-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar-section-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #6b7280;
    margin-bottom: 4px;
}

.sidebar-section-title svg {
    stroke: #9ca3af;
    fill: none;
    flex-shrink: 0;
}

.sidebar-label {
    font-size: 0.95rem;
    font-weight: 500;
    color: #374151;
    margin-bottom: 0;
}

.sidebar-label select,
.sidebar-label input {
    font-size: 0.88rem;
    padding: 6px 10px;
    margin-top: 2px;
    margin-bottom: 0;
    border-radius: 6px;
    height: auto;
}

.sidebar-divider {
    height: 1px;
    background: #e5e7eb;
    margin: 12px 0;
}

.sidebar-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.88rem;
    font-weight: 500;
    color: #fff;
    background: linear-gradient(135deg, #1976D2, #1565C0);
    border: none;
    border-radius: 6px;
    padding: 7px 12px;
    cursor: pointer;
    transition: all 0.15s;
    width: 100%;
    justify-content: center;
    margin: 0;
}

.sidebar-action-btn:hover {
    background: linear-gradient(135deg, #1565C0, #0D47A1);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(25, 118, 210, 0.25);
}

.sidebar-action-btn svg {
    stroke: #fff;
    fill: none;
    flex-shrink: 0;
}


/* ---- Tab bar ---- */
.tab-bar {
    display: flex;
    gap: 2px;
    background: #f3f4f6;
    border-radius: 8px;
    padding: 3px;
    margin-bottom: 16px;
    width: fit-content;
}

.tab-btn {
    padding: 6px 18px;
    font-size: 0.9rem;
    font-weight: 500;
    color: #6b7280;
    background: transparent;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
    margin: 0;
    width: auto;
}

.tab-btn:hover {
    color: #374151;
    background: rgba(255, 255, 255, 0.6);
}

.tab-btn.active {
    background: #fff;
    color: #1976D2;
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}


/* ---- Sub-tab bar (within cards) ---- */
.sub-tab-btn {
    padding: 5px 14px;
    font-size: 0.88rem;
    font-weight: 500;
    color: #6b7280;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all 0.15s;
}

.sub-tab-btn:hover {
    color: #374151;
}

.sub-tab-btn.active {
    color: #1976D2;
    border-bottom-color: #1976D2;
    font-weight: 600;
}

/* ---- Chart container ---- */
#chart-container {
    position: relative;
    width: 100%;
    height: 100%;
    padding: 20px;
    background: #f9fafb;
    border-radius: 8px;
}

#chart-container canvas {
    max-height: 100%;
}

/* ---- Content panels ---- */
.content-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 20px;
}

.content-card h6 {
    font-size: 0.95rem;
    font-weight: 700;
    color: #1a1a2e;
    margin: 0 0 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.content-card h6 svg {
    stroke: #1976D2;
    fill: none;
    flex-shrink: 0;
}

.section-desc {
    font-size: 0.88rem;
    color: #9ca3af;
    margin: 0 0 12px;
}

.action-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, #1976D2, #1565C0);
    border: none;
    border-radius: 8px;
    padding: 8px 20px;
    cursor: pointer;
    transition: all 0.15s;
    margin: 0;
    width: auto;
}

.action-btn:hover {
    background: linear-gradient(135deg, #1565C0, #0D47A1);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(25, 118, 210, 0.25);
}

.action-btn:active {
    transform: translateY(0);
}

.action-btn svg {
    stroke: #fff;
    fill: none;
}

.action-btn-outline {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.88rem;
    font-weight: 500;
    color: #1976D2;
    background: #fff;
    border: 1px solid #1976D2;
    border-radius: 8px;
    padding: 7px 16px;
    cursor: pointer;
    transition: all 0.15s;
    margin: 0;
    width: auto;
}

.action-btn-outline:hover {
    background: #e3f2fd;
}

.action-btn-outline svg {
    stroke: #1976D2;
    fill: none;
}

.action-btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.88rem;
    font-weight: 500;
    color: #374151;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 7px 16px;
    cursor: pointer;
    transition: all 0.15s;
    margin: 0;
    width: auto;
    text-decoration: none;
    text-align: center;
}

.action-btn-secondary:hover {
    background: #e5e7eb;
    color: #1f2937;
}

.action-btn-secondary svg {
    stroke: currentColor;
    fill: none;
}


/* ---- Table scroll containers ---- */
.table-scroll-container {
    position: relative;
    overflow-x: auto;
    overflow-y: auto;
    max-height: 54vh;
    width: 100%;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
}

/* Result table: fill parent container height */
.table-scroll-container.result-table {
    max-height: none;
    height: 100%;
}

.table-scroll-container table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.88rem;
    margin: 0;
}

.table-scroll-container thead {
    position: sticky;
    top: 0;
    z-index: 1;
}

.table-scroll-container th {
    text-align: left;
    padding: 8px 10px;
    background: #f8f9fa;
    border-bottom: 2px solid #e5e7eb;
    font-weight: 600;
    color: #374151;
    white-space: nowrap;
    font-size: 0.88rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.table-scroll-container td {
    text-align: left;
    padding: 8px 10px;
    border-bottom: 1px solid #f3f4f6;
    color: #4b5563;
    white-space: normal;
    word-wrap: break-word;
    word-break: break-word;
}

.table-scroll-container tbody tr:hover {
    background: #f8fafc;
}

/* Result table: allow wrapping */
.result-table th,
.result-table td {
    white-space: normal;
    word-wrap: break-word;
}

/* Code frame table column widths */
.table-scroll-container th:first-child,
.table-scroll-container td:first-child {
    width: 60px;
    text-align: center;
}

/* Result table column hints */
.result-table th:nth-child(1),
.result-table td:nth-child(1) {
    width: 8%;
    text-align: center;
}

.result-table th:nth-child(2),
.result-table td:nth-child(2) {
    width: 12%;
}

.result-table th:nth-child(3),
.result-table td:nth-child(3) {
    width: 40%;
}

.result-table th:nth-child(n+4),
.result-table td:nth-child(n+4) {
    width: 20%;
}

/* ---- Custom scrollbar ---- */
.table-scroll-container::-webkit-scrollbar {
    height: 6px;
    width: 6px;
}

.table-scroll-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.table-scroll-container::-webkit-scrollbar-thumb {
    background: #c5c5c5;
    border-radius: 3px;
}

.table-scroll-container::-webkit-scrollbar-thumb:hover {
    background: #999;
}

.table-scroll-container {
    scrollbar-width: thin;
    scrollbar-color: #c5c5c5 #f1f1f1;
}


/* ---- Modal title ---- */
.dialog-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1rem;
    font-weight: 700;
    color: #1a1a2e;
    margin: 0;
}

.dialog-title svg {
    stroke: #1976D2;
    fill: none;
}

.dialog-body {
    font-size: 0.88rem;
    color: #4b5563;
    line-height: 1.6;
}


/* ---- Toast animation ---- */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.tw-animate-fade-in {
    animation: fadeIn 0.3s ease-out;
}


/* ---- Input area ---- */
.data-textarea {
    font-family: "Noto Sans KR", 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
    font-size: 0.8rem;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 12px;
    resize: vertical;
    background: #fafbfc;
    transition: border-color 0.2s, box-shadow 0.2s;
    line-height: 1.5;
}

.data-textarea:focus {
    border-color: #1976D2;
    box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.1);
    background: #fff;
}

.data-textarea::placeholder {
    color: #c5c8ce;
}


/* ---- Empty states ---- */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: #9ca3af;
    text-align: center;
}

.empty-state svg {
    stroke: #d1d5db;
    fill: none;
    margin-bottom: 12px;
}

.empty-state p {
    font-size: 0.82rem;
    margin: 0;
}


/* ---- Badge / Count ---- */
.count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    background: #e3f2fd;
    color: #1976D2;
    font-size: 0.7rem;
    font-weight: 600;
}


/* ---- Misc ---- */
textarea {
    resize: vertical;
}

details summary {
    font-size: 0.82rem;
    font-weight: 600;
    color: #374151;
    cursor: pointer;
}

details summary:hover {
    color: #1976D2;
}

.htmx-indicator {
    display: none;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
    display: inline-block;
}

/* ---- Notice / alert banners ---- */
.notice {
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.82rem;
    border-left: 3px solid #2563eb;
    background: #eff6ff;
    color: #1e40af;
    margin-bottom: 4px;
}

.notice[role="alert"],
.notice-error {
    border-left-color: #dc2626;
    background: #fef2f2;
    color: #991b1b;
}

.notice-info {
    border-left-color: #2563eb;
    background: #eff6ff;
    color: #1e40af;
}
