/* ---------- TIKITAKA AI DASHBOARD STYLES ---------- */
/* Designer-Delta: Modern, Glassmorphic & Clean SaaS UI */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    /* Color Palette */
    --primary: #4F46E5;
    --primary-hover: #4338CA;
    --bg-body: #F4F7FE;
    --bg-sidebar: #0B1437;
    --bg-card: #FFFFFF;
    
    --text-main: #1B2559;
    --text-muted: #A3AED0;
    --text-sidebar: #A3AED0;
    --text-sidebar-active: #FFFFFF;
    
    --border-color: #E9EDF7;
    
    /* Shadows & Effects */
    --shadow-soft: 0 18px 40px rgba(112, 144, 176, 0.12);
    --shadow-hover: 0 20px 45px rgba(112, 144, 176, 0.2);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Status Colors */
    --status-pending-bg: #F1F5F9;
    --status-pending-txt: #64748B;
    --status-calling-bg: #E0E7FF;
    --status-calling-txt: #4338CA;
    --status-completed-bg: #DCFCE7;
    --status-completed-txt: #15803D;
}

/* ---------- 1. Reset & Global ---------- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

#app-container {
    display: flex;
    height: 100vh;
    width: 100%;
    overflow: hidden;
}
#app-container.hidden {
    display: none !important;
}

/* Login Wrapper */
.login-wrapper {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: var(--bg-body);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: var(--transition);
}
.login-wrapper.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}
.login-box {
    background: var(--bg-card);
    width: 100%;
    max-width: 420px;
    padding: 40px;
    border-radius: 24px;
    box-shadow: 0 24px 50px rgba(112, 144, 176, 0.2);
}
.login-header {
    text-align: center;
    margin-bottom: 32px;
}
.login-header h2 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-main);
}
.login-header p {
    color: var(--text-muted);
    font-size: 14px;
    margin-top: 8px;
}
.login-options {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13.5px;
    color: var(--text-muted);
    cursor: pointer;
    font-weight: 500;
}
.checkbox-label input {
    accent-color: var(--primary);
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* ---------- 2. Sidebar ---------- */
.sidebar {
    width: 280px;
    background-color: var(--bg-sidebar);
    display: flex;
    flex-direction: column;
    transition: var(--transition);
    z-index: 100;
}

.sidebar-header {
    padding: 36px 28px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 22px;
    font-weight: 700;
    color: #FFFFFF;
    letter-spacing: -0.5px;
}

.logo-icon-wrapper {
    background: linear-gradient(135deg, #868CFF 0%, #4318FF 100%);
    width: 38px;
    height: 38px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(67, 24, 255, 0.4);
}

.sidebar-nav {
    flex: 1;
    padding: 0 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    color: var(--text-sidebar);
    text-decoration: none;
    border-radius: 12px;
    font-weight: 500;
    font-size: 15px;
    transition: var(--transition);
}

.nav-item i {
    font-size: 18px;
    width: 24px;
    text-align: center;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-sidebar-active);
}

.nav-item.active {
    background: var(--primary);
    color: var(--text-sidebar-active);
    box-shadow: 0 4px 15px rgba(79, 70, 229, 0.3);
}

.sidebar-footer {
    padding: 28px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 14px;
}

.user-profile img {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.1);
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-weight: 600;
    font-size: 14px;
    color: #FFFFFF;
}

.user-role {
    font-size: 12px;
    color: var(--text-sidebar);
    margin-top: 2px;
}

/* ---------- 3. Main Content & Topbar ---------- */
.main-content {
    flex: 1;
    padding: 40px;
    overflow-y: auto;
}

.view-section {
    display: none;
    flex-direction: column;
    gap: 36px;
}

.view-section.active {
    display: flex;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

.page-title h1 {
    font-size: 32px;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.8px;
    color: var(--text-main);
}

.page-title p {
    color: var(--text-muted);
    font-size: 15px;
    margin-top: 6px;
    font-weight: 400;
}

.control-panel {
    display: flex;
    gap: 16px;
}

.btn {
    padding: 12px 24px;
    border-radius: 12px;
    border: none;
    font-family: inherit;
    font-weight: 600;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: var(--transition);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-main);
    box-shadow: var(--shadow-soft);
}

.btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.btn-primary {
    background: var(--primary);
    color: #FFFFFF;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
}

.btn-primary:disabled {
    background: #94A3B8;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.glow-effect {
    animation: pulseGlow 2s infinite alternate;
}

@keyframes pulseGlow {
    from { box-shadow: 0 4px 15px rgba(79, 70, 229, 0.3); }
    to { box-shadow: 0 8px 25px rgba(79, 70, 229, 0.6); }
}

/* ---------- 4. Dashboard Stats ---------- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 24px;
}

.stat-card {
    background: var(--bg-card);
    padding: 24px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 20px;
    box-shadow: var(--shadow-soft);
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.bg-blue { background: rgba(67, 24, 255, 0.1); color: #4318FF; }
.bg-orange { background: rgba(255, 138, 76, 0.1); color: #FF8A4C; }
.bg-green { background: rgba(5, 205, 153, 0.1); color: #05CD99; }
.bg-purple { background: rgba(112, 26, 255, 0.1); color: #701AFF; }

.stat-details h3 {
    font-size: 14px;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 6px;
}

.stat-number {
    font-size: 30px;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1;
}

/* ---------- 5. Data Table ---------- */
.table-section {
    background: var(--bg-card);
    border-radius: 24px;
    padding: 32px;
    box-shadow: var(--shadow-soft);
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.section-header h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-main);
}

.search-box {
    display: flex;
    align-items: center;
    background: var(--bg-body);
    padding: 12px 20px;
    border-radius: 99px;
    gap: 12px;
    width: 320px;
    border: 1px solid transparent;
    transition: var(--transition);
}

.search-box:focus-within {
    background: var(--bg-card);
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
}

.search-box input {
    border: none;
    background: transparent;
    outline: none;
    width: 100%;
    font-size: 14px;
    color: var(--text-main);
    font-family: inherit;
}

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

.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    min-width: 950px;
}

th {
    text-align: left;
    padding: 18px 16px;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 13px;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

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

td {
    padding: 20px 16px;
    font-size: 14.5px;
    font-weight: 500;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
    transition: var(--transition);
}

tbody tr:hover td {
    background-color: #FAFCFF;
}

tbody tr:last-child td {
    border-bottom: none;
}

.client-name {
    display: flex;
    align-items: center;
    gap: 14px;
    font-weight: 600;
    color: var(--text-main);
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #868CFF 0%, #4318FF 100%);
    color: #FFFFFF;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
}

.avatar.bg-gray {
    background: #E2E8F0;
    color: #64748B;
}

/* Status Badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: 99px;
    font-size: 12.5px;
    font-weight: 600;
}

.status-pending {
    background: var(--status-pending-bg);
    color: var(--status-pending-txt);
}

.status-calling {
    background: var(--status-calling-bg);
    color: var(--status-calling-txt);
    animation: bgBlink 1.5s infinite alternate ease-in-out;
}

@keyframes bgBlink {
    0% { opacity: 0.6; }
    100% { opacity: 1; }
}

.status-completed {
    background: var(--status-completed-bg);
    color: var(--status-completed-txt);
}

.time-counter {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    color: var(--text-main);
}

.needs-tag {
    background: var(--bg-body);
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 13px;
    color: #475569;
    font-weight: 500;
}

.needs-tag.none {
    display: none;
}

/* Priority Bar Matrix Layout Hack */
.priority-container {
    display: grid;
    grid-template-columns: 100px auto;
    align-items: center;
    gap: 12px;
}

/* Track background using pseudo-element */
.priority-container::before {
    content: '';
    grid-column: 1;
    grid-row: 1;
    height: 8px;
    background: #E9EDF7;
    border-radius: 4px;
    width: 100%;
}

.priority-bar {
    grid-column: 1;
    grid-row: 1;
    height: 8px;
    border-radius: 4px;
    z-index: 1;
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.priority-text {
    grid-column: 2;
    grid-row: 1;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-main);
}

.priority-bar.high {
    background: linear-gradient(90deg, #FF5B5B, #FF3131);
    box-shadow: 0 0 10px rgba(255, 49, 49, 0.3);
}

.priority-bar.medium {
    background: linear-gradient(90deg, #FFB547, #FF9500);
    box-shadow: 0 0 10px rgba(255, 149, 0, 0.3);
}

.priority-score {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
}

.priority-score.score-calc {
    color: var(--primary);
    animation: bgBlink 1s infinite alternate;
}

.badge-wasm {
    background: #CCFBF1;
    color: #0F766E;
    font-size: 10px;
    padding: 3px 8px;
    border-radius: 6px;
    margin-left: 6px;
    font-weight: 700;
    vertical-align: middle;
}

.schedule-date {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13.5px;
    color: #334155;
    background: #F8FAFC;
    padding: 6px 12px;
    border-radius: 8px;
    border: 1px solid #E2E8F0;
}

.action-btn {
    background: transparent;
    border: none;
    color: #94A3B8;
    font-size: 18px;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: var(--transition);
    display: block;
    margin: 0 auto;
}

.action-btn:hover {
    color: var(--text-main);
    background: #F1F5F9;
}

.action-btn:disabled {
    color: #CBD5E1;
    cursor: not-allowed;
    background: transparent;
}

.btn-filter-date {
    background: #ffffff;
    border: 1px solid #E2E8F0;
    color: #64748B;
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}
.btn-filter-date:hover {
    border-color: #FBBF24;
    color: #D97706;
}
.btn-filter-date.active {
    background: #FEF3C7;
    border-color: #F59E0B;
    color: #D97706;
    font-weight: 600;
}

/* Calendar Styles */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
}
.cal-day-header {
    text-align: center;
    font-weight: 600;
    font-size: 14px;
    color: var(--text-muted);
    padding: 10px 0;
}
.cal-day-cell {
    background: var(--bg-body);
    border-radius: 12px;
    min-height: 120px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: var(--transition);
    border: 1px solid var(--border-color);
}
.cal-day-cell.other-month {
    opacity: 0.5;
}
.cal-day-cell.today {
    border-color: var(--primary);
    background: #FAFCFF;
}
.cal-date-num {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-main);
    align-self: flex-end;
}
.cal-event {
    background: #E0E7FF;
    color: #4338CA;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border-left: 3px solid #4338CA;
    transition: all 0.2s;
}
.cal-event:hover {
    background: #C7D2FE;
    transform: translateX(2px);
}

.filter-date-input {
    padding: 6px 10px;
    border: 1px solid #E2E8F0;
    border-radius: 8px;
    font-size: 13px;
    color: var(--text-main);
    outline: none;
}
.filter-date-input:focus {
    border-color: #F59E0B;
}

/* Settings Tabs */
.settings-tabs {
    display: flex;
    gap: 12px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
    overflow-x: auto;
    white-space: nowrap;
}

.settings-tabs::-webkit-scrollbar {
    height: 4px;
}

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

.settings-tab {
    background: transparent;
    border: none;
    font-size: 14.5px;
    font-weight: 600;
    color: var(--text-muted);
    padding: 10px 20px;
    cursor: pointer;
    transition: var(--transition);
    border-radius: 12px;
    font-family: inherit;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    flex-shrink: 0;
}

.settings-tab:hover {
    background: rgba(79, 70, 229, 0.05);
    color: var(--primary);
}

.settings-tab.active {
    background: var(--primary);
    color: #FFFFFF;
    box-shadow: 0 4px 15px rgba(79, 70, 229, 0.2);
}

.settings-content .table-section {
    display: none;
}

.settings-content .table-section.active-tab {
    display: flex;
}

/* ---------- 7. Modal & Dialogs ---------- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(11, 20, 55, 0.4);
    backdrop-filter: blur(8px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-box {
    background: var(--bg-card);
    width: 100%;
    max-width: 420px;
    border-radius: 24px;
    box-shadow: 0 24px 50px rgba(112, 144, 176, 0.2);
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.modal-overlay.active .modal-box {
    transform: translateY(0) scale(1);
}

.modal-header {
    padding: 24px 32px 16px;
}

.modal-header h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-main);
}

.modal-body {
    padding: 0 32px 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.modal-text {
    font-size: 15px;
    color: var(--text-muted);
    line-height: 1.5;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
}

.modal-input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    font-size: 14px;
    color: var(--text-main);
    background: var(--bg-body);
    outline: none;
    transition: var(--transition);
}

.modal-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
    background: #FFFFFF;
}

.modal-footer {
    padding: 16px 32px 24px;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* AI Agent Chat Custom Styles */
.chat-section {
    height: calc(100vh - 200px);
    max-height: calc(100vh - 200px);
    min-height: 0;
}
.mic-btn.live-active {
    background: #FFE4E6 !important;
    color: #E11D48 !important;
    animation: pulse-red 1.5s infinite;
}
.tts-btn.inactive {
    background: var(--bg-body) !important;
    color: var(--text-muted) !important;
}
@keyframes pulse-red {
    0% { box-shadow: 0 0 0 0 rgba(225, 29, 72, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(225, 29, 72, 0); }
    100% { box-shadow: 0 0 0 0 rgba(225, 29, 72, 0); }
}

.message.user {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.hidden {
    display: none !important;
}

/* ---------- 6. Responsive Design ---------- */
@media (max-width: 1280px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 1024px) {
    .sidebar {
        width: 88px;
    }
    .sidebar-header .logo span {
        display: none;
    }
    .nav-item span {
        display: none;
    }
    .nav-item {
        justify-content: center;
        padding: 16px 0;
    }
    .user-info {
        display: none;
    }
    .user-profile {
        justify-content: center;
    }
    .main-content {
        padding: 24px;
        gap: 24px;
    }
}

@media (max-width: 768px) {
    #app-container {
        flex-direction: column;
    }
    /* 하단 앱바 (Bottom Navigation) 스타일로 변경 */
    .sidebar {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 72px;
        flex-direction: row;
        align-items: center;
        justify-content: center;
        padding: 0;
        z-index: 1000;
        border-top: 1px solid rgba(255, 255, 255, 0.05);
        box-shadow: 0 -4px 20px rgba(11, 20, 55, 0.15);
    }
    .sidebar-header {
        display: none; /* 모바일에서는 사이드바 로고 숨김 */
    }
    .sidebar-nav {
        flex-direction: row;
        padding: 0 8px;
        justify-content: flex-start;
        gap: 16px;
        width: 100%;
        flex: 1;
        overflow-x: auto;
        white-space: nowrap;
    }
    .sidebar-nav::-webkit-scrollbar {
        display: none;
    }
    .nav-item {
        flex-direction: column;
        gap: 6px;
        padding: 8px;
        border-radius: 12px;
        font-size: 11px;
        flex-shrink: 0;
        min-width: 64px;
    }
    .nav-item i {
        font-size: 20px;
        width: auto;
    }
    .nav-item span {
        display: block !important;
        font-size: 11px;
        font-weight: 500;
        white-space: nowrap;
    }
    .nav-item.active {
        background: transparent;
        color: #868CFF; /* 모바일 활성 컬러 포인트 */
        box-shadow: none;
    }
    .nav-item.active i {
        transform: scale(1.1);
        transition: var(--transition);
    }
    .sidebar-footer {
        display: none;
    }
    .main-content {
        padding: 20px 16px 92px 16px; /* 하단 네비게이션 공간(72px+20px) 확보 */
        gap: 20px;
    }
    .page-title h1 {
        font-size: 24px;
    }
    .page-title p {
        font-size: 13px;
    }
    /* 통계 카드 2열 그리드 및 크기 축소 */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    .stat-card {
        flex-direction: column;
        align-items: flex-start;
        padding: 16px;
        gap: 12px;
        border-radius: 16px;
    }
    .stat-icon {
        width: 44px;
        height: 44px;
        font-size: 18px;
    }
    .stat-details h3 {
        font-size: 12px;
    }
    .stat-number {
        font-size: 22px;
    }
    .topbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }
    .control-panel {
        width: 100%;
        flex-wrap: wrap; /* 버튼이 많을 경우 줄바꿈 */
    }
    .control-panel .btn {
        flex: 1 1 calc(50% - 8px); /* 2개씩 배치 */
        justify-content: center;
        padding: 10px 12px;
        font-size: 13px;
    }
    /* 3번째 버튼(오토콜 시작 등)을 100% 너비로 차지하게 할 경우 */
    .control-panel .btn:nth-child(3) {
        flex: 1 1 100%;
    }
    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    .search-box {
        width: 100%;
    }
    .search-box input, .modal-input {
        font-size: 16px; /* iOS Safari 폼 포커스 시 자동 확대 방지 */
    }
    .table-section {
        padding: 16px;
        border-radius: 16px;
        gap: 16px;
    }
    .chat-section {
        height: calc(100vh - 240px);
        max-height: calc(100vh - 240px);
    }
    th, td {
        padding: 12px 10px;
        font-size: 13px;
    }
    /* 모달 창 모바일 최적화 */
    .modal-box {
        max-width: calc(100% - 32px);
        margin: 16px;
    }
    .modal-header {
        padding: 20px 24px 12px;
    }
    .modal-body {
        padding: 0 24px 20px;
    }
    .modal-footer {
        padding: 12px 24px 20px;
    }
}
```