/* CHECKUP+.ai - 검진고객관리 자동화 프로그램 스타일 */

/* ===== CSS Variables ===== */
:root {
    /* Colors - Dark Theme */
    --color-bg-primary: #0d1117;
    --color-bg-secondary: #161b22;
    --color-bg-tertiary: #21262d;
    --color-bg-canvas: #1a1f2e;

    --color-border-primary: #30363d;
    --color-border-secondary: #21262d;

    --color-text-primary: #c9d1d9;
    --color-text-secondary: #8b949e;
    --color-text-muted: #6e7681;

    --color-accent-blue: #58a6ff;
    --color-accent-purple: #a371f7;
    --color-accent-green: #3fb950;
    --color-accent-red: #f85149;
    --color-accent-yellow: #d29922;
    --color-accent-orange: #db6d28;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.4);
    --shadow-xl: 0 25px 50px rgba(0, 0, 0, 0.5);

    /* Border radius */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;

    /* Sidebar */
    --sidebar-width: 260px;
}

/* ===== Reset & Base ===== */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: var(--color-bg-primary);
    color: var(--color-text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: var(--color-accent-blue);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: var(--color-accent-purple);
}

/* ===== Layout ===== */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* ===== Sidebar ===== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--color-bg-secondary);
    border-right: 1px solid var(--color-border-primary);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--color-border-primary);
}

.sidebar-logo {
    font-size: 1.25rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--color-accent-blue) 0%, var(--color-accent-purple) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar-logo-img {
    max-width: 160px;
    height: auto;
    filter: brightness(1.1);
}

.sidebar-subtitle {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    margin-top: 0.25rem;
}

.sidebar-nav {
    padding: 1rem 0;
}

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

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

.nav-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    margin: 0.125rem 0.5rem;
    border-radius: var(--radius-md);
    color: var(--color-text-secondary);
    transition: all 0.2s ease;
}

.nav-item:hover {
    background: var(--color-bg-tertiary);
    color: var(--color-text-primary);
}

.nav-item.active {
    background: rgba(88, 166, 255, 0.15);
    color: var(--color-accent-blue);
}

.nav-item-icon {
    width: 20px;
    height: 20px;
    margin-right: 0.75rem;
    opacity: 0.8;
}

/* ===== Main Content ===== */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
}

.content-header {
    background: var(--color-bg-secondary);
    border-bottom: 1px solid var(--color-border-primary);
    padding: 1.25rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 50;
}

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

.content-body {
    padding: 2rem;
}

/* ===== Cards ===== */
.card {
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border-primary);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--color-border-primary);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.card-body {
    padding: 1.5rem;
}

/* Card variant for search bars with dropdowns */
.card-search {
    overflow: visible;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    gap: 0.5rem;
}

.btn-primary {
    background: linear-gradient(135deg, #238636 0%, #2ea043 100%);
    color: #ffffff;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #2ea043 0%, #3fb950 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(46, 160, 67, 0.4);
}

.btn-secondary {
    background: var(--color-bg-tertiary);
    border-color: var(--color-border-primary);
    color: var(--color-text-primary);
}

.btn-secondary:hover {
    background: var(--color-border-primary);
    border-color: var(--color-accent-blue);
    color: var(--color-accent-blue);
}

.btn-danger {
    background: rgba(248, 81, 73, 0.15);
    border-color: rgba(248, 81, 73, 0.4);
    color: var(--color-accent-red);
}

.btn-danger:hover {
    background: rgba(248, 81, 73, 0.25);
}

/* ===== Tables ===== */
.table-wrapper {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border-primary);
}

.table th {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--color-bg-tertiary);
}

.table td {
    font-size: 0.875rem;
    color: var(--color-text-primary);
}

.table tbody tr:hover {
    background: rgba(88, 166, 255, 0.05);
}

/* ===== Forms ===== */
.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text-primary);
    margin-bottom: 0.5rem;
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--color-bg-primary);
    border: 1px solid var(--color-border-primary);
    border-radius: var(--radius-md);
    color: var(--color-text-primary);
    font-size: 0.875rem;
    transition: all 0.2s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--color-accent-blue);
    box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.15);
}

.form-control::placeholder {
    color: var(--color-text-muted);
}

/* ===== Badges ===== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 9999px;
}

.badge-waiting {
    background: rgba(210, 153, 34, 0.15);
    color: var(--color-accent-yellow);
}

.badge-ready {
    background: rgba(88, 166, 255, 0.15);
    color: var(--color-accent-blue);
}

.badge-complete {
    background: rgba(63, 185, 80, 0.15);
    color: var(--color-accent-green);
}

.badge-stopped {
    background: rgba(248, 81, 73, 0.15);
    color: var(--color-accent-red);
}

/* ===== Alerts ===== */
.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.alert-success {
    background: rgba(63, 185, 80, 0.15);
    border: 1px solid rgba(63, 185, 80, 0.4);
    color: var(--color-accent-green);
}

.alert-error {
    background: rgba(248, 81, 73, 0.2);
    border: 1px solid rgba(248, 81, 73, 0.5);
    color: #ff7b72;
}

.alert-warning {
    background: rgba(210, 153, 34, 0.15);
    border: 1px solid rgba(210, 153, 34, 0.4);
    color: var(--color-accent-yellow);
}

.alert-info {
    background: rgba(88, 166, 255, 0.15);
    border: 1px solid rgba(88, 166, 255, 0.4);
    color: var(--color-accent-blue);
}

/* ===== Search Bar ===== */
.search-bar {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    align-items: center;
}

.search-bar .form-control {
    flex: 1;
    min-width: 200px;
    height: 42px;
}

.search-bar .form-select {
    min-width: 180px;
    height: 42px;
}

.search-bar .btn {
    height: 42px;
}

/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--color-text-muted);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state-title {
    font-size: 1.125rem;
    font-weight: 500;
    color: var(--color-text-secondary);
    margin-bottom: 0.5rem;
}

/* ===== User Info ===== */
.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--color-bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--color-accent-blue);
}

.user-name {
    font-size: 0.875rem;
    font-weight: 500;
}

.user-role {
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

/* ===== Responsive ===== */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }
}

@media (max-width: 768px) {
    .search-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .search-bar .form-control,
    .search-bar select,
    .search-bar .choices {
        max-width: 100% !important;
        width: 100%;
    }

    .search-bar .btn {
        width: 100%;
    }
}

/* ===== Utility Classes ===== */

/* Layout */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

/* Flexbox */
.flex {
    display: flex;
}

.flex-wrap {
    flex-wrap: wrap;
}

.items-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.justify-end {
    justify-content: flex-end;
}

.gap-1 {
    gap: 0.5rem;
}

.gap-2 {
    gap: 1rem;
}

.gap-3 {
    gap: 1.5rem;
}

/* Spacing */
.mb-0 {
    margin-bottom: 0 !important;
}

.mb-1 {
    margin-bottom: 1rem;
}

.mb-2 {
    margin-bottom: 1.5rem;
}

.mt-1 {
    margin-top: 1rem;
}

.mt-2 {
    margin-top: 1.5rem;
}

.p-0 {
    padding: 0 !important;
}

.p-2 {
    padding: 1.5rem;
}

.p-4 {
    padding: 2rem;
}

/* Width */
.w-full {
    width: 100%;
}

.w-200 {
    max-width: 200px;
}

.w-160 {
    max-width: 160px;
}

/* Text */
.text-center {
    text-align: center;
}

.text-muted {
    color: var(--color-text-muted);
}

.text-secondary {
    color: var(--color-text-secondary);
}

.text-sm {
    font-size: 0.875rem;
}

.text-xs {
    font-size: 0.75rem;
}

.font-semibold {
    font-weight: 600;
}

/* ===== Stat Cards ===== */
.stat-card {
    text-decoration: none;
    display: block;
}

.stat-card:hover .card {
    border-color: var(--color-accent-blue);
    transform: translateY(-2px);
    transition: all 0.2s ease;
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 700;
}

.stat-value-yellow {
    color: var(--color-accent-yellow);
}

.stat-value-blue {
    color: var(--color-accent-blue);
}

.stat-value-purple {
    color: #8b5cf6;
}

.stat-value-green {
    color: var(--color-accent-green);
}

.stat-value-red {
    color: var(--color-accent-red);
}

.stat-label {
    color: var(--color-text-secondary);
    margin-top: 0.5rem;
}

/* ===== Button Modifiers ===== */
.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
}

/* ===== Badge Modifiers ===== */
.badge-success {
    background: rgba(63, 185, 80, 0.15);
    color: var(--color-accent-green);
}

.badge-danger {
    background: rgba(248, 81, 73, 0.15);
    color: var(--color-accent-red);
}

.badge-sending {
    background: rgba(139, 92, 246, 0.2);
    color: #8b5cf6;
}

/* ===== Message Cards ===== */
.message-card {
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border-primary);
    border-radius: var(--radius-lg);
    margin-bottom: 1rem;
    overflow: hidden;
}

.message-card-header {
    padding: 1rem 1.25rem;
    background: var(--color-bg-tertiary);
    border-bottom: 1px solid var(--color-border-primary);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.message-card-title {
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.message-card-body {
    padding: 1.25rem;
}

.message-content {
    background: var(--color-bg-tertiary);
    padding: 1rem;
    border-radius: var(--radius-md);
    white-space: pre-wrap;
    font-size: 0.9rem;
    line-height: 1.6;
}

/* Message Type Badges */
.message-type-badge {
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-full);
    font-size: 0.7rem;
    font-weight: 500;
}

.type-disease {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.type-checkup {
    background: rgba(59, 130, 246, 0.2);
    color: #3b82f6;
}

.type-postcare {
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
}

/* Status Badges */
.status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 500;
}

.status-waiting {
    background: rgba(234, 179, 8, 0.2);
    color: #eab308;
}

.status-approved {
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
}

.status-sent {
    background: rgba(59, 130, 246, 0.2);
    color: #3b82f6;
}

.status-failed {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.status-stopped {
    background: rgba(107, 114, 128, 0.2);
    color: #6b7280;
}

/* ===== Progress Bar ===== */
.progress-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.progress-track {
    flex: 1;
    background: var(--color-bg-tertiary);
    border-radius: 4px;
    height: 8px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--color-accent-blue);
    transition: width 0.3s;
}

.progress-text {
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

/* ===== Form Sections ===== */
.form-section {
    background: var(--color-bg-tertiary);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    margin-bottom: 1.5rem;
}

.form-section-title {
    font-size: 1rem;
    margin-bottom: 1rem;
    color: var(--color-accent-blue);
}

/* ===== Target Info ===== */
.target-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.target-info-title {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.target-info-subtitle {
    font-size: 0.875rem;
    color: var(--color-text-muted);
}

.target-info-meta {
    color: var(--color-text-muted);
}

/* ===== Radio/Checkbox Groups ===== */
.radio-group,
.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin-top: 0.5rem;
}

.radio-group label,
.checkbox-group label {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.875rem;
    line-height: 1;
}

/* ===== Message Variables (pending_detail) ===== */
.message-card-meta {
    display: flex;
    gap: 1rem;
    align-items: center;
    font-size: 0.875rem;
    color: var(--color-text-muted);
}

.message-card-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    padding: 1.25rem;
}

.message-variables {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.variable-row {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 0.5rem;
    align-items: center;
}

.variable-label {
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.variable-input {
    padding: 0.375rem 0.5rem;
    border: 1px solid var(--color-border-primary);
    border-radius: var(--radius-md);
    background: var(--color-bg-tertiary);
    color: var(--color-text-primary);
    font-size: 0.85rem;
}

.variable-input:focus {
    outline: none;
    border-color: var(--color-accent-blue);
}

.variable-input.readonly {
    background: var(--color-bg-primary);
    color: var(--color-text-muted);
}

.message-preview-container {
    position: relative;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.message-editor {
    width: 100%;
    flex: 1;
    background: var(--color-bg-tertiary);
    padding: 1rem;
    border: 1px solid var(--color-border-primary);
    border-radius: var(--radius-md);
    white-space: pre-wrap;
    font-size: 0.85rem;
    line-height: 1.6;
    color: var(--color-text-primary);
    resize: vertical;
    min-height: 180px;
    font-family: inherit;
    box-sizing: border-box;
}

.message-editor:focus {
    outline: none;
    border-color: var(--color-accent-blue);
    box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.15);
}

.message-editor[readonly] {
    background: var(--color-bg-primary);
    color: var(--color-text-muted);
    cursor: not-allowed;
}

.reset-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    font-size: 0.7rem;
    padding: 0.25rem 0.5rem;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--color-border-primary);
    color: var(--color-text-secondary);
}

.btn-outline:hover {
    border-color: var(--color-accent-blue);
    color: var(--color-accent-blue);
}

.btn-xs {
    padding: 0.25rem 0.5rem;
    font-size: 0.7rem;
}

.message-card-footer {
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--color-border-primary);
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

/* ===== Sidebar User Section ===== */
.sidebar-user {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1rem;
    border-top: 1px solid var(--color-border-primary);
    background: var(--color-bg-secondary);
}

.sidebar-user .btn {
    width: 100%;
    margin-top: 1rem;
}

/* ===== Login Page ===== */
body.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1a1f2e 0%, #0d1117 50%, #161b22 100%);
}

.login-container {
    width: 100%;
    max-width: 420px;
    padding: 2rem;
}

.login-card {
    background: rgba(22, 27, 34, 0.95);
    border: 1px solid rgba(48, 54, 61, 0.8);
    border-radius: 16px;
    padding: 3rem 2.5rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
}

.login-logo {
    text-align: center;
    margin-bottom: 2.5rem;
}

.login-logo h1 {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, #58a6ff 0%, #a371f7 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
}

.login-logo-img {
    max-width: 180px;
    height: auto;
    filter: brightness(1.1);
}

.login-logo p {
    color: #8b949e;
    margin-top: 0.5rem;
    font-size: 0.875rem;
}

.btn-login {
    width: 100%;
    padding: 1rem;
    background: linear-gradient(135deg, #238636 0%, #2ea043 100%);
    border: none;
    border-radius: 8px;
    color: #ffffff;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 0.5rem;
}

.btn-login:hover {
    background: linear-gradient(135deg, #2ea043 0%, #3fb950 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(46, 160, 67, 0.4);
}

.btn-login:active {
    transform: translateY(0);
}

.footer-text {
    text-align: center;
    margin-top: 2rem;
    color: #6e7681;
    font-size: 0.75rem;
}

/* Login page form styles */
.login-card .form-group {
    margin-bottom: 1.5rem;
}

.login-card .form-group label {
    display: block;
    color: #c9d1d9;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.login-card .form-group input {
    width: 100%;
    padding: 0.875rem 1rem;
    background: rgba(13, 17, 23, 0.8);
    border: 1px solid rgba(48, 54, 61, 0.8);
    border-radius: 8px;
    color: #c9d1d9;
    font-size: 1rem;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.login-card .form-group input:focus {
    outline: none;
    border-color: #58a6ff;
    box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.15);
}

.login-card .form-group input::placeholder {
    color: #6e7681;
}

/* ===== Custom Form Elements ===== */

/* Custom Select Dropdown */
select.form-control,
.form-control[type="select"],
select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238b949e' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    padding-right: 2.5rem;
    cursor: pointer;
}

select.form-control:focus,
select:focus {
    outline: none;
    border-color: var(--color-accent-blue);
    box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.15);
}

select option {
    background: var(--color-bg-secondary);
    color: var(--color-text-primary);
    padding: 0.5rem;
}

/* Custom Checkbox */
input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    width: 20px;
    height: 20px;
    min-width: 20px;
    background: var(--color-bg-primary);
    border: 2px solid var(--color-border-primary);
    border-radius: 4px;
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
    vertical-align: middle;
}

input[type="checkbox"]:hover {
    border-color: var(--color-accent-blue);
}

input[type="checkbox"]:checked {
    background: var(--color-accent-blue);
    border-color: var(--color-accent-blue);
}

input[type="checkbox"]:checked::after {
    content: "";
    position: absolute;
    left: 5px;
    top: 1px;
    width: 6px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

input[type="checkbox"]:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.15);
}

/* Custom Radio Button */
input[type="radio"] {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    width: 20px;
    height: 20px;
    min-width: 20px;
    background: var(--color-bg-primary);
    border: 2px solid var(--color-border-primary);
    border-radius: 50%;
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
    vertical-align: middle;
}

input[type="radio"]:hover {
    border-color: var(--color-accent-blue);
}

input[type="radio"]:checked {
    border-color: var(--color-accent-blue);
}

input[type="radio"]:checked::after {
    content: "";
    position: absolute;
    left: 4px;
    top: 4px;
    width: 8px;
    height: 8px;
    background: var(--color-accent-blue);
    border-radius: 50%;
}

input[type="radio"]:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.15);
}

/* Custom Date Input */
input[type="date"] {
    color-scheme: dark;
}

input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(0.7);
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s;
}

input[type="date"]::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
}

/* ===== Custom Scrollbar ===== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--color-bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--color-border-primary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--color-text-muted);
}

/* Firefox scrollbar */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--color-border-primary) var(--color-bg-primary);
}

/* ===== Enhanced Table Styles ===== */
.table th {
    background: var(--color-bg-canvas);
    border-bottom: 2px solid var(--color-border-primary);
    color: var(--color-text-primary);
    font-size: 0.8rem;
    font-weight: 600;
}

.table tbody tr {
    transition: background-color 0.15s ease;
}

.table tbody tr:hover {
    background: rgba(88, 166, 255, 0.08);
}

/* ===== Enhanced Button Effects ===== */
.btn {
    transition: all 0.2s ease;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary:hover {
    filter: brightness(1.1);
}

.btn-secondary:hover {
    filter: brightness(1.15);
}

.btn-danger:hover {
    filter: brightness(1.1);
}

/* ===== Enhanced Card Effects ===== */
.card {
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.stat-card:hover .card {
    box-shadow: var(--shadow-lg);
}

/* ===== Small Text Utility ===== */
small {
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

/* ===== Focus Ring Standardization ===== */
.form-control:focus,
.btn:focus,
select:focus,
input:focus,
textarea:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.15);
}

/* ===== Number Input ===== */
input[type="number"] {
    -moz-appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* ===== Choices.js Dark Theme ===== */
.choices {
    margin-bottom: 0;
    position: relative;
}

/* Ensure proper width */
/* Ensure proper width */
.search-bar .choices {
    min-width: 180px;
}

.choices.w-160 {
    min-width: 180px;
    max-width: 180px;
}

.choices.w-200 {
    min-width: 240px;
    max-width: 240px;
}

.choices-dark {
    font-size: 0.875rem;
}

.choices-dark .choices__inner {
    background: var(--color-bg-primary);
    border: 1px solid var(--color-border-primary);
    border-radius: var(--radius-md);
    min-height: 42px;
    padding: 0.5rem 2.5rem 0.5rem 0.75rem;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
}

.choices-dark.is-focused .choices__inner,
.choices-dark.is-open .choices__inner {
    border-color: var(--color-accent-blue);
    box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.15);
}

.choices-dark .choices__input {
    background: transparent;
    color: var(--color-text-primary);
    font-size: 0.875rem;
    padding: 0;
    margin-bottom: 0;
}

.choices-dark .choices__input::placeholder {
    color: var(--color-text-muted);
}

.choices-dark .choices__list--single {
    padding: 0;
    display: flex;
    align-items: center;
}

.choices-dark .choices__list--single .choices__item {
    color: var(--color-text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
}

.choices-dark .choices__list--dropdown,
.choices-dark .choices__list[aria-expanded] {
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border-primary);
    border-radius: var(--radius-md);
    margin-top: 4px;
    box-shadow: var(--shadow-lg);
    z-index: 100;
    min-width: 200px;
}

.choices-dark .choices__list--dropdown .choices__item,
.choices-dark .choices__list[aria-expanded] .choices__item {
    color: var(--color-text-primary);
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
}

.choices-dark .choices__list--dropdown .choices__item--selectable.is-highlighted,
.choices-dark .choices__list[aria-expanded] .choices__item--selectable.is-highlighted {
    background: var(--color-bg-tertiary);
    color: var(--color-accent-blue);
}

.choices-dark .choices__list--dropdown .choices__item--selectable:hover {
    background: var(--color-bg-tertiary);
}

.choices-dark .choices__placeholder {
    color: var(--color-text-muted);
    opacity: 1;
}

/* Search input within dropdown */
.choices-dark .choices__list--dropdown .choices__input {
    background: var(--color-bg-primary);
    border: none;
    border-bottom: 1px solid var(--color-border-primary);
    color: var(--color-text-primary);
    padding: 0.75rem 1rem;
}

.choices-dark .choices__list--dropdown .choices__input:focus {
    outline: none;
    box-shadow: none;
}

/* Custom Arrow icon */
.choices-dark::after {
    content: "";
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid var(--color-text-secondary);
    pointer-events: none;
}

.choices-dark.is-open::after {
    border-top: none;
    border-bottom: 6px solid var(--color-text-secondary);
}

/* Remove default select styling when Choices is applied */
.choices select {
    display: none !important;
}

/* Width constraint classes */
.search-bar .choices.w-200,
.choices.w-200 {
    min-width: 200px;
    max-width: 200px;
}

.search-bar .choices.w-160,
.choices.w-160 {
    min-width: 160px;
    max-width: 160px;
}

/* ===== Health Data Display ===== */
.health-data-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
}

.health-section {
    flex: 1 1 300px;
    background: var(--color-bg-tertiary);
    border-radius: var(--radius-md);
    padding: 1rem;
    border: 1px solid var(--color-border-primary);
    max-height: 450px;
    display: flex;
    flex-direction: column;
}

.origin-data-section {
    flex: 1 1 100%;
    width: 100%;
}

.health-section-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--color-text-primary);
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    background: var(--color-bg-tertiary);
    padding-bottom: 0.5rem;
    z-index: 1;
}

.health-icon {
    font-size: 1.1rem;
}

.health-date {
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--color-text-muted);
    margin-left: auto;
}

.health-items {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    overflow-y: auto;
    flex: 1;
}

.origin-data-content {
    overflow-y: auto;
    flex: 1;
    line-height: 1.6;
    font-size: 0.9rem;
    color: var(--color-text-secondary);
    white-space: pre-wrap;
    word-break: break-word;
}

.followup-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    overflow-y: auto;
    flex: 1;
}

/* 클릭 가능한 사후관리 항목 */
.followup-clickable {
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid var(--color-bg-secondary);
}

.followup-clickable:hover {
    border-color: var(--color-accent-blue);
}

.followup-active {
    border-color: var(--color-accent-blue);
    background: rgba(88, 166, 255, 0.08);
}

/* 전체소견 내 하이라이트 */
.highlight-match {
    background: rgba(210, 153, 34, 0.35);
    color: var(--color-accent-yellow);
    padding: 0.1rem 0.2rem;
    border-radius: 2px;
    font-weight: 500;
}

.health-item-badge {
    display: block;
    padding: 0.6rem 0.8rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    line-height: 1.4;
    text-align: left;
}

.health-item-badge.risk {
    background: rgba(248, 81, 73, 0.15);
    color: var(--color-accent-red);
    border: 1px solid rgba(248, 81, 73, 0.3);
}

.health-item-badge.checkup {
    background: rgba(88, 166, 255, 0.15);
    color: var(--color-accent-blue);
    border: 1px solid rgba(88, 166, 255, 0.3);
}

.followup-item {
    background: var(--color-bg-secondary);
    padding: 0.6rem 0.8rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    color: var(--color-text-primary);
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.followup-item strong {
    color: var(--color-accent-yellow);
}

.followup-hospital {
    color: var(--color-accent-green);
    font-size: 0.8rem;
}

.followup-period {
    color: var(--color-text-muted);
    font-size: 0.75rem;
}

/* ===== Pagination ===== */
.pager {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.25rem;
    padding: 1rem;
}

.pager a,
.pager span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s ease;
}

.pager a {
    background: var(--color-bg-tertiary);
    color: var(--color-text-secondary);
    border: 1px solid var(--color-border-primary);
}

.pager a:hover {
    background: var(--color-bg-secondary);
    color: var(--color-text-primary);
    border-color: var(--color-accent-blue);
}

.pager span.active,
.pager a.active {
    background: var(--color-accent-blue);
    color: #fff;
    border-color: var(--color-accent-blue);
}

.pager span:not(.active) {
    color: var(--color-text-muted);
}

/* CodeIgniter pager classes */
nav ul.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.25rem;
    list-style: none;
    padding: 1rem;
    margin: 0;
}

nav ul.pagination li {
    display: inline-block;
}

nav ul.pagination li a,
nav ul.pagination li span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s ease;
    background: var(--color-bg-tertiary);
    color: var(--color-text-secondary);
    border: 1px solid var(--color-border-primary);
}

nav ul.pagination li a:hover {
    background: var(--color-bg-secondary);
    color: var(--color-text-primary);
    border-color: var(--color-accent-blue);
}

nav ul.pagination li.active span,
nav ul.pagination li.active a {
    background: var(--color-accent-blue);
    color: #fff;
    border-color: var(--color-accent-blue);
}

nav ul.pagination li.disabled span {
    color: var(--color-text-muted);
    cursor: not-allowed;
}

nav ul.pagination li a.icon-link {
    padding: 0;
    width: 36px;
    font-size: 1.1rem;
}

/* ===== Sortable Table Headers ===== */
.sort-link {
    color: var(--color-text-secondary);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    cursor: pointer;
    transition: color 0.2s ease;
}

.sort-link:hover {
    color: var(--color-accent-blue);
}

.table th .sort-link {
    color: inherit;
}

/* Followup Message Styles */

.followup-header {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.followup-meta {
    display: flex;
    gap: 12px;
    margin-top: 6px;
    font-size: 0.875rem;
    color: var(--color-text-secondary);
}

.followup-scheduled {
    color: var(--color-accent-blue);
}

.followup-message {
    margin-top: 10px;
    padding: 10px;
    background: var(--color-bg-tertiary);
    border-radius: 6px;
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--color-text-primary);
    border-left: 3px solid var(--color-accent-purple);
}

.badge-info {
    background: rgba(0, 150, 255, 0.15);
    color: #0096ff;
    border: 1px solid rgba(0, 150, 255, 0.3);
}

.badge-warning {
    background: rgba(210, 153, 34, 0.15);
    color: var(--color-accent-yellow);
    border: 1px solid rgba(210, 153, 0, 0.3);
}