/* ============================================
   Category Detail Panel - Slideout Drill-Down
   ============================================ */

/* Overlay */
.category-detail-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.category-detail-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Panel */
.category-detail-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 85vh;
    background: var(--card-bg);
    border-radius: 20px 20px 0 0;
    z-index: 1001;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.category-detail-overlay.active .category-detail-panel {
    transform: translateY(0);
}

/* Handle bar */
.cd-handle {
    display: flex;
    justify-content: center;
    padding: 12px 0 4px;
    flex-shrink: 0;
}

.cd-handle-bar {
    width: 40px;
    height: 4px;
    background: var(--gray-300);
    border-radius: 2px;
}

/* Header */
.cd-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 20px 16px;
    flex-shrink: 0;
}

.cd-header-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.cd-header-icon i {
    width: 22px;
    height: 22px;
    color: white;
}

.cd-header-info {
    flex: 1;
}

.cd-header-name {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-primary);
}

.cd-header-count {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.cd-close {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--bg-secondary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-secondary);
    transition: background 0.2s ease;
}

.cd-close:hover {
    background: var(--hover-bg);
}

.cd-close i {
    width: 18px;
    height: 18px;
}

/* Body - scrollable */
.cd-body {
    flex: 1;
    overflow-y: auto;
    padding: 0 20px 20px;
    -webkit-overflow-scrolling: touch;
}

/* Summary card */
.cd-summary {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: 12px;
    margin-bottom: 16px;
}

.cd-summary-total {
    flex: 1;
}

.cd-summary-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.cd-summary-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.cd-summary-variation {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.cd-summary-variation i {
    width: 14px;
    height: 14px;
}

.cd-summary-variation.up {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

.cd-summary-variation.down {
    background: rgba(34, 197, 94, 0.1);
    color: var(--success);
}

.cd-summary-variation.neutral {
    background: rgba(107, 114, 128, 0.1);
    color: var(--text-tertiary);
}

/* Section titles */
.cd-section-title {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-tertiary);
    margin: 16px 0 8px;
}

/* Trend chart */
.cd-trend {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 16px;
    height: 160px;
}

/* Subcategories */
.cd-subcategories {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.cd-subcat-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.cd-subcat-icon {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.cd-subcat-icon i {
    width: 14px;
    height: 14px;
    color: white;
}

.cd-subcat-info {
    flex: 1;
    min-width: 0;
}

.cd-subcat-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
}

.cd-subcat-bar-track {
    height: 4px;
    background: var(--border-color);
    border-radius: 2px;
    margin-top: 4px;
    overflow: hidden;
}

.cd-subcat-bar-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.5s ease;
}

.cd-subcat-value {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    flex-shrink: 0;
}

/* Transactions list */
.cd-transactions {
    display: flex;
    flex-direction: column;
}

.cd-trans-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
}

.cd-trans-item:last-child {
    border-bottom: none;
}

.cd-trans-info {
    flex: 1;
    min-width: 0;
}

.cd-trans-desc {
    font-size: 0.875rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cd-trans-date {
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

.cd-trans-subcat {
    font-size: 0.7rem;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    padding: 1px 6px;
    border-radius: 4px;
    display: inline-block;
    margin-top: 2px;
}

.cd-trans-value {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--danger);
    flex-shrink: 0;
}

/* Loading state */
.cd-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    gap: 12px;
    color: var(--text-tertiary);
}

.cd-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: cd-spin 0.8s linear infinite;
}

@keyframes cd-spin {
    to { transform: rotate(360deg); }
}

/* Desktop layout */
@media (min-width: 768px) {
    .category-detail-panel {
        max-width: 480px;
        left: auto;
        right: 0;
        top: 0;
        bottom: 0;
        max-height: 100vh;
        border-radius: 0;
        transform: translateX(100%);
    }

    .category-detail-overlay.active .category-detail-panel {
        transform: translateX(0);
    }

    .cd-handle {
        display: none;
    }

    .cd-header {
        padding-top: 20px;
    }
}
