/* Component Debugger Styles */

/* Tabs */
.component-debug-tabs {
    display: flex;
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: 16px;
}

.component-debug-tab-button {
    padding: 8px 16px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-size: 14px;
    color: #6b7280;
    transition: all 0.2s;
}

.component-debug-tab-button:hover {
    color: #4f46e5;
}

.component-debug-tab-button.active {
    color: #4f46e5;
    border-bottom-color: #4f46e5;
    font-weight: 500;
}

.component-debug-tab-content {
    padding: 0;
    display: flex;
    flex-direction: column;
    flex: 1 1 auto; /* flex-grow, flex-shrink, flex-basis */
    overflow: hidden; /* Prevent scrollbar on tab content */
    height: 100%; /* Fill available height */
    box-sizing: border-box; /* Include padding in height calculation */
}

/* Log View */
.component-debug-log-controls {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 12px;
}

.component-debug-log-clear {
    padding: 6px 12px;
    background-color: #f3f4f6;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.component-debug-log-clear:hover {
    background-color: #e5e7eb;
}

.component-debug-log-container {
    flex: 1 1 auto; /* flex-grow, flex-shrink, flex-basis */
    overflow-y: auto; /* Keep scrollbar on log container */
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    font-family: monospace;
    font-size: 12px;
    line-height: 1.5;
    min-height: 100px; /* Reduced minimum height */
    max-height: 100%; /* Ensure it doesn't overflow its parent */
    box-sizing: border-box; /* Include border in height calculation */
    margin-bottom: 60px;
}

.component-debug-no-logs {
    padding: 16px;
    color: #666;
    font-style: italic;
    text-align: center;
}

.component-debug-log-entry {
    padding: 8px 10px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: flex-start;
    margin-bottom: 1px;
}

.component-debug-log-entry:last-child {
    border-bottom: none;
}

.component-debug-log-time {
    color: inherit;
    opacity: 0.7;
    margin-right: 8px;
    flex-shrink: 0;
}

.component-debug-log-type {
    font-weight: bold;
    margin-right: 8px;
    flex-shrink: 0;
    width: 50px;
}

.component-debug-log-message {
    word-break: break-all;
    white-space: pre-wrap;
    color: inherit;
}

/* Log types */
.component-debug-log-log {
    color: #333333;
    background-color: #ffffff;
}

.component-debug-log-info {
    color: #0a3622;
    background-color: #ecfdf5;
}

.component-debug-log-warn {
    color: #723b13;
    background-color: #fffbeb;
}

.component-debug-log-error {
    color: #991b1b;
    background-color: #fef2f2;
}

.component-debug-log-debug {
    color: #5b21b6;
    background-color: #f5f3ff;
}

/* Highlighted keywords in log messages */
.highlight-init {
    color: #ef4444; /* Red */
    font-weight: bold;
}

.highlight-init-async {
    color: #f59e0b; /* Orange */
    font-weight: bold;
}

.component-debug-log-log .component-debug-log-type {
    color: #3b82f6;
}

.component-debug-log-info .component-debug-log-type {
    color: #10b981;
}

.component-debug-log-warn .component-debug-log-type {
    color: #f59e0b;
}

.component-debug-log-error .component-debug-log-type {
    color: #ef4444;
}

.component-debug-log-debug .component-debug-log-type {
    color: #8b5cf6;
}

/* Debug Button */
.component-debug-button {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: white;
    font-size: 16px;
    border: none;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.4);
    cursor: grab;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    touch-action: none;
    padding: 0;
}

.component-debug-button:hover {
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.5);
}

.component-debug-button:active {
    cursor: grabbing;
    box-shadow: 0 2px 6px rgba(99, 102, 241, 0.4);
}

.component-debug-button svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

/* Debug Dialog */
.component-debug-dialog {
    position: fixed;
    bottom: 60px;
    right: 20px;
    width: 400px;
    max-width: 90vw;
    height: 90vh;
    background-color: white;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    z-index: 10000;
    display: none;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 14px;
    color: #333;
    border: 1px solid rgba(99, 102, 241, 0.1);
    resize: horizontal;
    min-width: 300px;
    min-height: 200px;
    overflow: scroll;
}

/* Dialog Header */
.component-debug-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: white;
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
    cursor: pointer;
    user-select: none;
    touch-action: none;
}

/* Header buttons container */
.component-debug-header-buttons {
    display: flex;
    align-items: center;
    gap: 8px;
}

.component-debug-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 300px;
}

.component-debug-close,
.component-debug-collapse,
.component-debug-minimize,
.component-debug-expand {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.component-debug-close {
    font-size: 20px;
}

.component-debug-collapse svg {
    fill: currentColor;
}

.component-debug-close:hover,
.component-debug-collapse:hover,
.component-debug-minimize:hover,
.component-debug-expand:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

/* Collapsed state */
.component-debug-dialog[data-collapsed="true"] {
    resize: none;
    min-height: unset;
    height: auto !important;
}

/* Expand button for minimized state */
.component-debug-expand {
    margin-left: 8px;
}

/* Minimized state */
.component-debug-dialog[data-minimized="true"] {
    width: auto !important;
    height: auto !important;
    min-width: unset;
    min-height: unset;
    border-radius: 12px;
}

.component-debug-dialog[data-minimized="true"] .component-debug-header {
    padding: 8px 12px;
    border-radius: 12px;
}

.component-debug-dialog[data-minimized="true"] h3 {
    font-size: 14px;
    margin-right: 8px;
}

.component-debug-dialog[data-collapsed="true"] .component-debug-content {
    display: none;
}

/* Dialog Content */
.component-debug-content {
    padding: 16px;
    overflow-y: hidden; /* Changed from auto to hidden */
    height: calc(100% - 50px); /* Use 100% height instead of max-height to follow resize */
    display: flex;
    flex-direction: column;
    box-sizing: border-box; /* Include padding in height calculation */
}

/* Component List */
.component-debug-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
}

.component-debug-list-item {
    padding: 10px 12px;
    background-color: #f5f7ff;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s;
    border-left: 3px solid #6366f1;
}

.component-debug-list-item:hover {
    background-color: #e0e7ff;
}

.component-debug-list-item-name {
    font-weight: 500;
    margin-bottom: 4px;
}

.component-debug-page-indicator {
    background: #dbeafe;
    color: #1e40af;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 12px;
    font-weight: 500;
    margin-bottom: 4px;
    display: inline-block;
}

.component-debug-name-property {
    font-size: 11px;
    color: #6b7280;
    font-family: monospace;
}

.component-debug-list-item-id {
    font-size: 11px;
    color: #6b7280;
    font-family: monospace;
    word-break: break-all;
}

.component-debug-no-components {
    padding: 16px;
    color: #666;
    font-style: italic;
    text-align: center;
}

/* Back Button */
.component-debug-back-button {
    background: none;
    border: none;
    color: #6366f1;
    cursor: pointer;
    padding: 8px 0;
    font-size: 14px;
    display: flex;
    align-items: center;
    margin-bottom: 0;
    margin-top: 0;
}

.component-debug-back-button:hover {
    text-decoration: underline;
}

.component-debug-selected-header {
    margin-top: 0;
    margin-bottom: 0;
    padding-bottom: 8px;
    border-bottom: 1px solid #eee;
}

.component-debug-selected-name {
    margin: 0 0 4px 0;
    font-size: 18px;
}

.component-debug-selected-id {
    font-size: 12px;
    color: #6b7280;
    font-family: monospace;
    word-break: break-all;
}

.component-debug-component-content {
    margin-top: 0;
    overflow: scroll;
}

/* State Tree */
.state-tree {
    font-family: monospace;
    line-height: 1.5;
}

.state-item {
    margin-bottom: 4px;
}

.state-key {
    color: #881280; /* purple for keys */
    font-weight: bold;
}

.state-value {
    font-weight: normal;
}

.state-string {
    color: #a31515; /* red for strings */
}

.state-number {
    color: #098658; /* green for numbers */
}

.state-boolean {
    color: #0000ff; /* blue for booleans */
}

.state-null, .state-undefined {
    color: #808080; /* gray for null/undefined */
    font-style: italic;
}

/* Section headers */
.component-debug-content h3 {
    margin-top: 16px;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 600;
    color: #333;
    border-bottom: 1px solid #eee;
    padding-bottom: 4px;
}

/* Private fields styling */
.component-debug-content div[id^="debug-content-"] > .state-tree > .state-item:nth-child(3) .state-key,
.component-debug-content div[id^="debug-content-"] > .state-tree > .state-item:nth-child(4) .state-key {
    color: #7c3aed; /* different color for private fields */
}

.state-expand {
    display: inline-block;
    width: 16px;
    height: 16px;
    text-align: center;
    cursor: pointer;
    color: #666;
    margin-right: 4px;
}

.state-preview {
    color: #666;
    font-style: italic;
}

.state-children {
    margin-left: 20px;
    border-left: 1px dotted #ccc;
    padding-left: 10px;
}
