/* Scoped styles for Katiline Plugin */
.katiline-plugin-wrapper {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    
    /* Default Theme Variables */
    --katiline-primary: #1F2937; /* Gray 800 (Text) */
    --katiline-accent: #3b82f6;  /* Blue 500 (Primary/Brand) */
    --katiline-success: #10b981; /* Green 500 */
    --katiline-border: #e5e7eb;
    --katiline-bg: #ffffff;
    
    /* Derived/Fallback colors */
    color: var(--katiline-primary);
}

.katiline-plugin-wrapper .katiline-widget-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.katiline-plugin-wrapper .katiline-card {
    background: var(--katiline-bg);
    border: 1px solid var(--katiline-border);
    border-radius: 0.75rem;
    padding: 1.5rem;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
}

.katiline-plugin-wrapper .katiline-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.katiline-plugin-wrapper .katiline-card-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--katiline-primary);
    margin: 0;
    width: 100%; /* Ensure text-align works */
}

/* Gauge specific styles */
.katiline-gauge-container {
    position: relative;
    height: 200px; /* Adjust as needed */
    width: 100%;
}

.katiline-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 200px;
    color: #6b7280;
}

.katiline-data-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--katiline-border);
}

.katiline-data-item:last-child {
    border-bottom: none;
}

.katiline-label {
    opacity: 0.8;
    font-size: 0.875rem;
}

.katiline-value {
    font-weight: 600;
    color: var(--katiline-accent); /* Use accent color for values */
}

/* --- DASHBOARD VARIANT STYLES --- */
.katiline-dashboard .katiline-dashboard-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    color: #1F2937;
}

/* Header Card */
.katiline-db-header-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fff;
    border-radius: 1rem;
    padding: 1.25rem 2rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    border: 1px solid #f3f4f6;
}

.katiline-db-status-section {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.katiline-status-icon-wrapper {
    width: 48px;
    height: 48px;
    background: #ecfdf5; /* Green-50 */
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.katiline-status-dot {
    width: 16px;
    height: 16px;
    background: #10b981; /* Green-500 */
    border-radius: 50%;
    box-shadow: 0 0 0 4px #d1fae5; /* Green-100 */
    animation: pulse 2s infinite;
}

@keyframes pulse {
	0% {
		transform: scale(0.95);
		box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
	}
	70% {
		transform: scale(1);
		box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
	}
	100% {
		transform: scale(0.95);
		box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
	}
}

.katiline-status-text h2 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.2;
}

.katiline-system-status {
    color: #6b7280;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.katiline-system-status::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    background-color: #10b981;
    border-radius: 50%;
}

.katiline-db-meta-section {
    display: flex;
    gap: 2rem;
    text-align: right;
}

.katiline-operator-info, .katiline-time-info {
    display: flex;
    flex-direction: column;
}

.katiline-db-meta-section .k-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #9ca3af;
    font-weight: 600;
}

.katiline-db-meta-section .k-value {
    font-weight: 600;
    font-size: 1rem;
}

.katiline-time-info .k-time {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1;
}

.katiline-time-info .k-date {
    font-size: 0.875rem;
    color: #6b7280;
}

/* Gauges Grid */
.katiline-db-gauges-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.katiline-db-card {
    background: #fff;
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    border: 1px solid #f3f4f6;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.k-card-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    position: relative;
    margin-bottom: 1rem;
}

.k-card-top h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.k-title-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.k-info-tooltip {
    color: #9ca3af;
    cursor: help;
    display: flex;
    align-items: center;
    position: relative;
    transition: color 0.2s;
}

.k-info-tooltip:hover {
    color: #6b7280;
}

.k-info-tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    background: #1f2937;
    color: #fff;
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: pre-wrap;
    width: max-content;
    max-width: 200px;
    z-index: 50;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    pointer-events: none;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    line-height: 1.4;
    text-align: center;
}

.k-info-tooltip::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-4px);
    border: 4px solid transparent;
    border-top-color: #1f2937;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
}

.k-info-tooltip:hover::after,
.k-info-tooltip:hover::before {
    opacity: 1;
    visibility: visible;
}

.k-badge {
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.k-badge-success {
    background-color: #ecfdf5;
    color: #059669;
}

.k-icon-bg {
    position: absolute;
    width: 60px;
    height: 60px;
    opacity: 0.1;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.k-icon-bg svg {
    width: 40px;
    height: 40px;
}

.k-icon-power { color: #f59e0b; }
.k-icon-pressure { color: #3b82f6; }
.k-icon-temp { color: #ef4444; }

.k-gauge-wrapper {
    position: relative;
    height: 180px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0.5rem 0;
}

.k-gauge-value-display {
    position: absolute;
    top: 60%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.k-main-val {
    display: block;
    font-size: 1.5rem;
    font-weight: 800;
    color: #10b981; /* Match gauge color */
}

.k-unit {
    font-size: 1rem;
    color: #6b7280;
    font-weight: 600;
}

.k-min-label, .k-max-label {
    position: absolute;
    bottom: 30px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #ef4444; /* Red for limits */
}
.k-min-label { left: 15%; }
.k-max-label { right: 15%; }

.k-card-footer {
    display: flex;
    justify-content: space-between;
    margin-top: 0.5rem;
    padding-top: 1rem;
    border-top: 1px solid #f3f4f6;
}

.k-card-footer.centered {
    justify-content: center;
}

.k-footer-item {
    display: flex;
    flex-direction: column;
}

.k-footer-item.text-right {
    text-align: right;
}

.k-foot-label {
    font-size: 0.75rem;
    color: #6b7280;
}

.k-foot-val {
    font-size: 0.875rem;
    font-weight: 600;
}

.k-trend-val {
    color: #ef4444; /* Down trend red */
}

/* Info Grid */
.katiline-db-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
}

.katiline-db-mini-card {
    background: #fff;
    border-radius: 1rem;
    padding: 1.25rem;
    border: 1px solid #f3f4f6;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

.k-mini-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    /* Placeholder */
}

.k-icon-production { background-color: #ecfdf5; color: #10b981; }
.k-icon-weather { background-color: #eff6ff; color: #3b82f6; }
.k-icon-avg { background-color: #f5f3ff; color: #8b5cf6; }
.k-icon-power { background-color: #fef3c7; color: #f59e0b; }
.k-icon-time { background-color: #f9fafb; color: #6b7280; }

.k-mini-content {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.k-mini-label {
    font-size: 0.75rem;
    color: #6b7280;
    margin-bottom: 0.25rem;
}

.k-mini-val {
    font-size: 1.25rem;
    font-weight: 700;
    color: #111827;
}

.k-mini-unit {
    font-size: 0.875rem;
    color: #6b7280;
    font-weight: 500;
    margin-left: 0.25rem;
}

.k-mini-val-lg {
    display: block;
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1;
}
.k-mini-val-sm {
    font-size: 0.75rem;
    color: #9ca3af;
}


/* Power Statistics Three-Column Layout */
.k-power-stats-columns {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    justify-content: space-around;
    gap: 1rem;
    margin-top: 0.5rem;
    flex: 1;
    width: 100%;
}

.k-power-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
}

.k-power-col-label {
    font-size: 0.625rem;
    color: #9ca3af;
    font-weight: 500;
    margin-bottom: 0.25rem;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.k-power-col-value {
    font-size: 1.125rem;
    font-weight: 700;
    color: #111827;
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

.k-power-col-unit {
    font-size: 0.625rem;
    color: #9ca3af;
    font-weight: 500;
    margin-top: 0.25rem;
}

.k-power-divider {
    width: 1px;
    background-color: #e5e7eb;
    align-self: stretch;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .katiline-db-header-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 1.5rem;
    }
    .katiline-db-meta-section {
        width: 100%;
        justify-content: space-between;
        text-align: left;
    }
}

/* Loading State Overlay */
.katiline-chart-loading {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10;
    border-radius: 0.75rem;
    transition: opacity 0.3s ease;
}

.katiline-chart-loading.hidden {
    opacity: 0;
    pointer-events: none;
}

.katiline-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(59, 130, 246, 0.2);
    border-radius: 50%;
    border-top-color: #3b82f6;
    animation: k-spin 1s ease-in-out infinite;
    margin-bottom: 0.75rem;
}

.katiline-loading-text {
    color: #6b7280;
    font-size: 0.875rem;
    font-weight: 500;
}

@keyframes k-spin {
    to { transform: rotate(360deg); }
}

/* Chart Statistics */
.katiline-chart-stats {
    display: flex;
    gap: 1.5rem;
    padding: 0 1.5rem 1rem 1.5rem;
    color: var(--katiline-primary, #1F2937);
    font-size: 0.9rem;
    align-items: center;
}

.k-stat-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.k-stat-label {
    font-weight: 600;
    color: #6b7280;
}

.k-stat-value {
    font-weight: 700;
    color: var(--katiline-primary);
}
