/* ============================================================
   Lina(CM) Keyword Report Dashboard - Premium Glassmorphism Theme
   ============================================================ */

:root {
    --bg-dark: #08070d;
    --card-bg: rgba(18, 16, 28, 0.75);
    --card-border: rgba(255, 255, 255, 0.08);
    --card-border-hover: rgba(245, 158, 11, 0.4);
    
    --primary-gradient: linear-gradient(135deg, #f59e0b 0%, #d97706 50%, #b45309 100%);
    --accent-glow: rgba(245, 158, 11, 0.25);
    
    --text-primary: #ffffff;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --slicer-bg: #0d0c15;
    --slicer-item-hover: rgba(245, 158, 11, 0.15);
    --slicer-item-active: #f59e0b;
    --slicer-item-active-bg: rgba(245, 158, 11, 0.25);
    
    --subtotal-bg: #f59e0b;
    --subtotal-text: #000000;
    --table-header-bg: #1e293b;
    --table-stripe-bg: rgba(255, 255, 255, 0.02);
    --table-hover-bg: rgba(245, 158, 11, 0.08);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', 'Noto Sans KR', sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
    padding-bottom: 3rem;
}

/* Background Animated Blobs */
.background-decorations {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.25;
    animation: pulse 12s infinite alternate ease-in-out;
}

.blob-1 {
    top: -10%;
    left: -5%;
    width: 550px;
    height: 550px;
    background: #d97706;
}

.blob-2 {
    bottom: -15%;
    right: -5%;
    width: 650px;
    height: 650px;
    background: #f59e0b;
    animation-delay: -4s;
}

.blob-3 {
    top: 40%;
    left: 50%;
    width: 500px;
    height: 500px;
    background: #b45309;
    animation-delay: -8s;
}

@keyframes pulse {
    0% { transform: scale(0.9) translate(0, 0); }
    100% { transform: scale(1.1) translate(40px, -40px); }
}

/* Container */
.app-container {
    max-width: 1820px;
    margin: 0 auto;
    padding: 1.5rem 2rem;
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--card-border);
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.back-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.8rem;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--card-border);
    transition: all 0.2s;
}

.back-link:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.1);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    font-size: 1.6rem;
    color: #f59e0b;
    filter: drop-shadow(0 0 10px rgba(245, 158, 11, 0.5));
}

.logo-text {
    font-family: 'Outfit', sans-serif;
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.logo-text .highlight {
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.header-right-tools {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    flex-wrap: wrap;
}

/* Buttons */
.btn {
    padding: 0.55rem 1.05rem;
    border-radius: 10px;
    font-size: 0.86rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    transition: all 0.25s ease;
    border: none;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary-gradient);
    color: #ffffff;
    box-shadow: 0 4px 15px rgba(245, 158, 11, 0.35);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(245, 158, 11, 0.5);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border: 1px solid var(--card-border);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

.btn-sync {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #ffffff;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}

.btn-sync:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.5);
}

.btn-sync.syncing i {
    animation: spin 1s infinite linear;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Sync Status Tag */
.sync-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.78rem;
    font-weight: 600;
    background: rgba(16, 185, 129, 0.1);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.25);
}

.sync-status-badge.offline {
    background: rgba(148, 163, 184, 0.1);
    color: #94a3b8;
    border-color: rgba(148, 163, 184, 0.2);
}

.sync-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 8px #10b981;
}

.sync-status-badge.offline .sync-dot {
    background: #94a3b8;
    box-shadow: none;
}

/* Page Title Banner */
.page-title-banner {
    background: linear-gradient(90deg, #0f172a 0%, #1e1b4b 50%, #0f172a 100%);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 12px;
    padding: 0.75rem 1.25rem;
    margin-bottom: 1.15rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    flex-wrap: wrap;
    gap: 0.75rem;
}

.page-title-banner h1 {
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: -0.3px;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.data-summary-badges {
    display: flex;
    gap: 0.65rem;
    align-items: center;
    flex-wrap: wrap;
}

.badge-item {
    font-size: 0.78rem;
    color: #cbd5e1;
    background: rgba(0, 0, 0, 0.4);
    padding: 0.25rem 0.65rem;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.badge-item strong {
    color: #f59e0b;
}

/* ============================================================
   8 Multidimensional Slicers Section (첨부 이미지 규격 정밀 재현)
   ============================================================ */
.slicers-container {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 0.6rem;
    margin-bottom: 1.15rem;
}

@media (max-width: 1400px) {
    .slicers-container {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 768px) {
    .slicers-container {
        grid-template-columns: repeat(2, 1fr);
    }
}

.slicer-card {
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    height: 195px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    transition: border-color 0.2s;
}

.slicer-card:hover {
    border-color: rgba(245, 158, 11, 0.4);
}

.slicer-header {
    background: #1e293b;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding: 0.4rem 0.6rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.slicer-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: #ffffff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.slicer-tools {
    display: flex;
    gap: 0.3rem;
}

.slicer-tool-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.72rem;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
    transition: color 0.15s;
}

.slicer-tool-btn:hover {
    color: #f59e0b;
    background: rgba(255, 255, 255, 0.05);
}

.slicer-search-input {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    color: #ffffff;
    padding: 0.3rem 0.55rem;
    font-size: 0.74rem;
    outline: none;
}

.slicer-search-input:focus {
    border-bottom-color: #f59e0b;
}

.slicer-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.35rem 0.45rem;
    display: flex;
    flex-direction: column;
    gap: 0.22rem;
}

.slicer-list::-webkit-scrollbar {
    width: 4px;
}
.slicer-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.18);
    border-radius: 4px;
}

.slicer-item {
    background: #1e293b;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 5px;
    padding: 0.3rem 0.5rem;
    font-size: 0.74rem;
    color: #cbd5e1;
    cursor: pointer;
    user-select: none;
    transition: all 0.15s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.slicer-item:hover {
    background: #334155;
    color: #ffffff;
}

.slicer-item.active {
    background: #f59e0b;
    color: #000000;
    font-weight: 700;
    border-color: #d97706;
    box-shadow: 0 1px 6px rgba(245, 158, 11, 0.4);
}

.slicer-item-count {
    font-size: 0.66rem;
    opacity: 0.7;
    margin-left: 0.3rem;
}

/* ============================================================
   Pivot Summary Section (주차별 & 월별 요약 테이블)
   ============================================================ */
.pivots-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.15rem;
}

@media (max-width: 1024px) {
    .pivots-grid {
        grid-template-columns: 1fr;
    }
}

.pivot-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
}

.pivot-header {
    background: #0f172a;
    padding: 0.55rem 0.9rem;
    border-bottom: 1px solid var(--card-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.pivot-header h3 {
    font-size: 0.88rem;
    font-weight: 700;
    color: #f59e0b;
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.pivot-table-wrapper {
    overflow-x: auto;
    max-height: 220px;
}

.pivot-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.78rem;
    text-align: right;
    white-space: nowrap;
}

.pivot-table th {
    background: #1e293b;
    color: #ffffff;
    font-weight: 700;
    padding: 0.45rem 0.6rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    position: sticky;
    top: 0;
    z-index: 1;
}

.pivot-table th:first-child,
.pivot-table td:first-child {
    text-align: left;
    padding-left: 0.85rem;
}

.pivot-table td {
    padding: 0.38rem 0.6rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    color: #e2e8f0;
}

.pivot-table tr:nth-child(even) td {
    background: var(--table-stripe-bg);
}

.pivot-table tr:hover td {
    background: var(--table-hover-bg);
}

.pivot-table tr.total-row td {
    background: #000000;
    color: #ffffff;
    font-weight: 800;
    border-top: 1px solid #f59e0b;
    border-bottom: 1px solid #f59e0b;
}

/* ============================================================
   Interactive Analytics & Charts Section
   ============================================================ */
.analytics-section {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 14px;
    padding: 1.15rem 1.35rem;
    margin-bottom: 1.15rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
}

.analytics-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 0.85rem;
}

.analytics-tabs {
    display: inline-flex;
    background: rgba(0, 0, 0, 0.35);
    padding: 3px;
    border-radius: 8px;
    border: 1px solid var(--card-border);
    gap: 3px;
}

.analytics-tab-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 0.4rem 0.85rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    transition: all 0.2s;
}

.analytics-tab-btn:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.05);
}

.analytics-tab-btn.active {
    background: var(--primary-gradient);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
}

.chart-container {
    height: 270px;
    position: relative;
    width: 100%;
}

/* ============================================================
   Keyword Detail Matrix Section (첨부 이미지 규격 철저 일치)
   ============================================================ */
.keyword-detail-section {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 4px 25px rgba(0, 0, 0, 0.3);
}

.keyword-detail-header {
    background: #0f172a;
    padding: 0.65rem 1.15rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    border-bottom: 1px solid var(--card-border);
}

.keyword-detail-header h3 {
    font-size: 0.95rem;
    font-weight: 700;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.table-controls {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    flex-wrap: wrap;
}

.search-box-wrapper {
    position: relative;
}

.search-box-wrapper i {
    position: absolute;
    left: 0.7rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.78rem;
}

.search-box-wrapper input {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--card-border);
    border-radius: 8px;
    padding: 0.4rem 0.7rem 0.4rem 2rem;
    color: #ffffff;
    font-size: 0.8rem;
    outline: none;
    width: 200px;
}

.search-box-wrapper input:focus {
    border-color: #f59e0b;
}

.table-scroll-container {
    overflow-x: auto;
    max-height: 580px;
    position: relative;
}

.keyword-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.78rem;
    text-align: right;
    white-space: nowrap;
}

/* Sticky Header */
.keyword-table thead th {
    background: #1e3a8a; /* Deep Blue Header as in image */
    color: #ffffff;
    font-weight: 700;
    padding: 0.5rem 0.65rem;
    border: 1px solid rgba(255, 255, 255, 0.12);
    position: sticky;
    top: 0;
    z-index: 10;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s;
}

.keyword-table thead th:hover {
    background: #1d4ed8;
}

.keyword-table thead th i {
    font-size: 0.68rem;
    margin-left: 0.2rem;
    opacity: 0.6;
}

.keyword-table thead th.sorted i {
    opacity: 1;
    color: #f59e0b;
}

.keyword-table th:first-child,
.keyword-table td:first-child {
    text-align: left;
    padding-left: 0.9rem;
    position: sticky;
    left: 0;
    z-index: 5;
    background: inherit;
}

.keyword-table thead th:first-child {
    z-index: 15;
    background: #1e3a8a;
}

/* SUB_TOTAL Row (Top Yellow Banner as in image) */
.keyword-table tr.subtotal-row {
    background: #f59e0b !important;
    color: #000000 !important;
    font-weight: 800 !important;
    position: sticky;
    top: 31px;
    z-index: 9;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.keyword-table tr.subtotal-row td {
    background: #f59e0b !important;
    color: #000000 !important;
    font-weight: 800 !important;
    border-top: 1px solid #d97706;
    border-bottom: 2px solid #b45309;
    padding: 0.45rem 0.65rem;
}

.keyword-table tr.subtotal-row td:first-child {
    background: #f59e0b !important;
    z-index: 14;
}

/* Data Rows */
.keyword-table tbody tr td {
    padding: 0.4rem 0.65rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
    color: #f1f5f9;
}

.keyword-table tbody tr:nth-child(even) td {
    background: rgba(255, 255, 255, 0.015);
}

.keyword-table tbody tr:hover td {
    background: rgba(245, 158, 11, 0.12);
}

.keyword-table tbody tr:hover td:first-child {
    background: #1e293b;
}

/* Pagination Footer */
.table-pagination {
    background: #0f172a;
    padding: 0.55rem 1.15rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--card-border);
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.page-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--card-border);
    color: #ffffff;
    padding: 0.22rem 0.55rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.76rem;
}

.page-btn:hover:not(:disabled) {
    background: #f59e0b;
    color: #000000;
}

.page-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

/* ============================================================
   Modals & Toast Notifications
   ============================================================ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.modal-card {
    background: #0f172a;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 18px;
    max-width: 650px;
    width: 100%;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
    overflow: hidden;
    animation: modalScale 0.25s ease-out;
}

@keyframes modalScale {
    0% { transform: scale(0.95); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.modal-header {
    padding: 1.1rem 1.4rem;
    background: #1e293b;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 1.1rem;
    font-weight: 700;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 0.55rem;
}

.modal-close-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
}

.modal-close-btn:hover {
    color: #ffffff;
}

.modal-body {
    padding: 1.35rem;
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
}

.modal-input-group label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: #e2e8f0;
    margin-bottom: 0.35rem;
}

.modal-input-group input,
.modal-input-group select {
    width: 100%;
    background: #000000;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    padding: 0.6rem 0.8rem;
    color: #ffffff;
    font-size: 0.86rem;
    outline: none;
}

.modal-input-group input:focus {
    border-color: #f59e0b;
}

.modal-hint {
    font-size: 0.76rem;
    color: var(--text-muted);
    margin-top: 0.3rem;
    line-height: 1.4;
}

.code-box {
    background: #000000;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 0.75rem;
    font-family: 'Fira Code', monospace;
    font-size: 0.75rem;
    color: #a5b4fc;
    max-height: 120px;
    overflow-y: auto;
    white-space: pre;
}

.modal-footer {
    padding: 0.9rem 1.4rem;
    background: #1e293b;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    justify-content: flex-end;
    gap: 0.65rem;
}

/* Toast */
.toast-notification {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid #f59e0b;
    color: #ffffff;
    padding: 0.8rem 1.25rem;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    gap: 0.6rem;
    z-index: 2000;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    font-size: 0.85rem;
    font-weight: 500;
}

.toast-notification.show {
    transform: translateY(0);
    opacity: 1;
}
