/* ============================================
   Fail2Ban UI - 커스텀 CSS
   다크 모드 기반 프리미엄 디자인
   ============================================ */

/* ── 변수 정의 ──────────────────────────────── */
:root {
    --sidebar-width: 260px;
    --navbar-height: 60px;
    --bg-primary: #0f1117;
    --bg-secondary: #161822;
    --bg-tertiary: #1c1f2e;
    --bg-card: rgba(28, 31, 46, 0.8);
    --bg-glass: rgba(255, 255, 255, 0.03);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-glow: rgba(99, 102, 241, 0.3);
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent-primary: #6366f1;
    --accent-secondary: #8b5cf6;
    --accent-gradient: linear-gradient(135deg, #6366f1, #8b5cf6);
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #06b6d4;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.15);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── 기본 스타일 ────────────────────────────── */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

::selection {
    background: var(--accent-primary);
    color: #fff;
}

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

a {
    color: var(--accent-primary);
    text-decoration: none;
    transition: var(--transition);
}
a:hover {
    color: var(--accent-secondary);
}

/* ── 인증 페이지 ────────────────────────────── */
.auth-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    background-image:
        radial-gradient(ellipse at 20% 50%, rgba(99, 102, 241, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 50%, rgba(139, 92, 246, 0.06) 0%, transparent 50%);
}

.auth-container {
    width: 100%;
    max-width: 440px;
    padding: 1rem;
}

.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    backdrop-filter: blur(20px);
    box-shadow: var(--shadow-lg);
    animation: fadeInUp 0.5s ease;
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-logo {
    width: 70px;
    height: 70px;
    background: var(--accent-gradient);
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
    font-size: 2rem;
    color: #fff;
    box-shadow: var(--shadow-glow);
    animation: pulse-glow 3s ease-in-out infinite;
}

.auth-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.auth-link {
    color: var(--accent-primary);
    font-weight: 500;
    margin-left: 0.5rem;
}
.auth-link:hover {
    color: var(--accent-secondary);
    text-decoration: underline;
}

.auth-footer {
    text-align: center;
    margin-top: 2rem;
}
.auth-footer a {
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* 비밀번호 강도 */
.password-strength {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.strength-bar {
    flex: 1;
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: 2px;
    overflow: hidden;
}
.strength-fill {
    height: 100%;
    width: 0;
    border-radius: 2px;
    transition: var(--transition);
}
.strength-text {
    font-size: 0.75rem;
    min-width: 60px;
    text-align: right;
}

/* ── 앱 레이아웃 ────────────────────────────── */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* ── 사이드바 ───────────────────────────────── */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1050;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    overflow-y: auto;
}

.sidebar-header {
    padding: 1.25rem 1.25rem 0.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-primary);
    font-weight: 700;
    font-size: 1.15rem;
    text-decoration: none;
}
.sidebar-brand:hover {
    color: var(--text-primary);
}
.sidebar-brand i {
    font-size: 1.5rem;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar-server-select {
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
}
.sidebar-server-select .form-select {
    background-color: var(--bg-tertiary);
    border-color: var(--border-color);
    color: var(--text-primary);
    font-size: 0.85rem;
}

.sidebar-nav {
    flex: 1;
    padding: 0.5rem 0;
    overflow-y: auto;
}

.nav-section {
    padding: 0.5rem 0;
}

.nav-section-title {
    display: block;
    padding: 0.5rem 1.5rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1.5rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 400;
    border-radius: 0;
    transition: var(--transition);
    border-left: 3px solid transparent;
}
.sidebar-nav .nav-link:hover {
    background: var(--bg-glass);
    color: var(--text-primary);
    border-left-color: rgba(99, 102, 241, 0.3);
}
.sidebar-nav .nav-link.active {
    background: rgba(99, 102, 241, 0.1);
    color: var(--accent-primary);
    border-left-color: var(--accent-primary);
    font-weight: 500;
}
.sidebar-nav .nav-link i {
    font-size: 1rem;
    width: 20px;
    text-align: center;
}

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border-color);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.user-info > i {
    font-size: 1.75rem;
    color: var(--text-muted);
}
.user-details {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.user-email {
    font-size: 0.8rem;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.user-role {
    font-size: 0.65rem;
    width: fit-content;
    margin-top: 2px;
}

/* ── 메인 콘텐츠 ────────────────────────────── */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ── 상단 네비바 ────────────────────────────── */
.top-navbar {
    height: var(--navbar-height);
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 1040;
}

.page-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.navbar-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ── 콘텐츠 영역 ────────────────────────────── */
.content-area {
    flex: 1;
    padding: 1.5rem;
}

/* ── 푸터 ───────────────────────────────────── */
.app-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    font-size: 0.8rem;
    color: var(--text-muted);
}
.footer-link {
    color: var(--text-muted);
}
.footer-link:hover {
    color: var(--accent-primary);
}

/* ── 카드 스타일 ────────────────────────────── */
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    backdrop-filter: blur(10px);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}
.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--accent-gradient);
    opacity: 0;
    transition: var(--transition);
}
.stat-card:hover {
    border-color: var(--border-glow);
    box-shadow: var(--shadow-glow);
    transform: translateY(-2px);
}
.stat-card:hover::before {
    opacity: 1;
}

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}
.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.2;
}
.stat-card .stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* 카드 색상 변형 */
.stat-icon.bg-primary-subtle { background: rgba(99, 102, 241, 0.15); color: var(--accent-primary); }
.stat-icon.bg-success-subtle { background: rgba(16, 185, 129, 0.15); color: var(--success); }
.stat-icon.bg-danger-subtle { background: rgba(239, 68, 68, 0.15); color: var(--danger); }
.stat-icon.bg-warning-subtle { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.stat-icon.bg-info-subtle { background: rgba(6, 182, 212, 0.15); color: var(--info); }

/* ── 글래스모피즘 카드 ──────────────────────── */
.glass-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    backdrop-filter: blur(10px);
    overflow: hidden;
}
.glass-card .card-header {
    background: var(--bg-glass);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.25rem;
    font-weight: 600;
    font-size: 0.9rem;
}
.glass-card .card-body {
    padding: 1.25rem;
}

/* ── 테이블 스타일 ──────────────────────────── */
.table-dark-custom {
    --bs-table-bg: transparent;
    --bs-table-border-color: var(--border-color);
    --bs-table-hover-bg: rgba(99, 102, 241, 0.05);
    --bs-table-striped-bg: rgba(255, 255, 255, 0.02);
    color: var(--text-primary);
    font-size: 0.875rem;
}
.table-dark-custom th {
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    border-bottom-width: 2px;
}

/* DataTables 커스텀 */
.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
    background-color: var(--bg-tertiary) !important;
    border-color: var(--border-color) !important;
    color: var(--text-primary) !important;
    border-radius: var(--radius-sm);
    padding: 0.4rem 0.75rem;
}
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate {
    color: var(--text-muted) !important;
    font-size: 0.85rem;
    margin-top: 1rem;
}
.dataTables_wrapper .paginate_button {
    color: var(--text-secondary) !important;
    border-radius: var(--radius-sm) !important;
}
.dataTables_wrapper .paginate_button.current {
    background: var(--accent-primary) !important;
    border-color: var(--accent-primary) !important;
    color: #fff !important;
}

/* ── 배지/상태 ──────────────────────────────── */
.badge-status {
    font-size: 0.7rem;
    font-weight: 500;
    padding: 0.3em 0.65em;
    border-radius: 50px;
}
.badge-online { background: rgba(16, 185, 129, 0.2); color: var(--success); }
.badge-offline { background: rgba(239, 68, 68, 0.2); color: var(--danger); }
.badge-unknown { background: rgba(100, 116, 139, 0.2); color: var(--text-muted); }

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}
.status-dot.online { background: var(--success); box-shadow: 0 0 6px var(--success); }
.status-dot.offline { background: var(--danger); box-shadow: 0 0 6px var(--danger); }

/* ── 폼 스타일 ──────────────────────────────── */
.form-control, .form-select {
    background-color: var(--bg-tertiary);
    border-color: var(--border-color);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    transition: var(--transition);
}
.form-control:focus, .form-select:focus {
    background-color: var(--bg-tertiary);
    border-color: var(--accent-primary);
    color: var(--text-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}
.form-control::placeholder {
    color: var(--text-muted);
}

.form-label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
}

/* ── 버튼 ───────────────────────────────────── */
.btn-primary {
    background: var(--accent-gradient);
    border: none;
    font-weight: 500;
    transition: var(--transition);
}
.btn-primary:hover {
    background: linear-gradient(135deg, #5558e6, #7c52e0);
    transform: translateY(-1px);
    box-shadow: var(--shadow-glow);
}

.btn-outline-secondary {
    border-color: var(--border-color);
    color: var(--text-secondary);
}
.btn-outline-secondary:hover {
    background: var(--bg-glass);
    border-color: var(--text-muted);
    color: var(--text-primary);
}

/* ── AI 관련 스타일 ─────────────────────────── */
.ai-card {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.08), rgba(139, 92, 246, 0.05));
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    position: relative;
}
.ai-card::before {
    content: '';
    position: absolute;
    top: -1px;
    left: -1px;
    right: -1px;
    bottom: -1px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.3), rgba(139, 92, 246, 0.1));
    z-index: -1;
    opacity: 0;
    transition: var(--transition);
}
.ai-card:hover::before {
    opacity: 1;
}
.ai-badge {
    background: var(--accent-gradient);
    color: #fff;
    font-size: 0.7rem;
    padding: 0.2em 0.6em;
    border-radius: 50px;
    font-weight: 600;
}
.ai-content {
    font-size: 0.875rem;
    line-height: 1.7;
    color: var(--text-secondary);
    white-space: pre-wrap;
}
.ai-loading {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}
.ai-loading .spinner-border {
    width: 1rem;
    height: 1rem;
    border-width: 2px;
}

/* ── 코드 에디터 영역 ──────────────────────── */
.code-editor {
    font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 0.85rem;
    line-height: 1.6;
    background: #0d1117;
    color: #e6edf3;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 1rem;
    min-height: 300px;
    resize: vertical;
    tab-size: 4;
    white-space: pre;
    overflow-x: auto;
}
.code-editor:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
    outline: none;
}

/* ── 로그 뷰어 ──────────────────────────────── */
.log-viewer {
    font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 0.8rem;
    line-height: 1.5;
    background: #0d1117;
    color: #8b949e;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 1rem;
    max-height: 600px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
}
.log-viewer .log-error { color: #f85149; }
.log-viewer .log-warning { color: #d29922; }
.log-viewer .log-info { color: #58a6ff; }
.log-viewer .log-ban { color: #f85149; font-weight: 600; }
.log-viewer .log-unban { color: #3fb950; }

/* ── 모바일 오버레이 ────────────────────────── */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1045;
    backdrop-filter: blur(4px);
}
.sidebar-overlay.show {
    display: block;
}

/* ── 애니메이션 ─────────────────────────────── */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 20px rgba(99, 102, 241, 0.2); }
    50% { box-shadow: 0 0 40px rgba(99, 102, 241, 0.4); }
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.fade-in {
    animation: fadeIn 0.3s ease;
}

/* ── 반응형 ─────────────────────────────────── */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.show {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
    }
    .content-area {
        padding: 1rem;
    }
}

@media (max-width: 767.98px) {
    .auth-card {
        padding: 1.75rem;
    }
    .stat-card .stat-value {
        font-size: 1.35rem;
    }
    .content-area {
        padding: 0.75rem;
    }
    .top-navbar {
        padding: 0 1rem;
    }
}

@media (max-width: 575.98px) {
    .auth-card {
        padding: 1.5rem;
        border-radius: var(--radius-md);
    }
    .auth-logo {
        width: 56px;
        height: 56px;
        font-size: 1.5rem;
    }
}

/* ── reCAPTCHA 배지 숨기기 ──────────────────── */
.grecaptcha-badge {
    visibility: hidden !important;
}

/* ── 기타 유틸리티 ──────────────────────────── */
.text-gradient {
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.border-accent {
    border-color: var(--accent-primary) !important;
}

.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--text-muted);
}
.empty-state > i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}
.empty-state h5 {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}
