/* ==========================================
   PLUGIN UI SCOPED VARIABLES & RESET
   ========================================== */
#pt-app-container, .pt-app {
    --bg: #f8fafc; 
    --surface: #ffffff; 
    --surface-2: #f1f5f9;
    --text: #1e293b; 
    --muted: #64748b; 
    --border: #e2e8f0;
    --accent: #3b82f6; 
    --accent-hover: #2563eb;
    --danger: #dc2626; 
    --success: #10b981;
    --spk-1: #3b82f6; 
    --spk-2: #10b981;
}

@media (prefers-color-scheme: dark) {
    #pt-app-container, .pt-app {
        --bg: #0f1115; 
        --surface: #1a1d24; 
        --surface-2: #22262e;
        --text: #e4e6eb; 
        --muted: #8b8f99; 
        --border: #2c303a;
        --accent: #4f46e5; 
        --accent-hover: #4338ca;
        --spk-1: #60a5fa; 
        --spk-2: #34d399;
    }
}

/* Contained box-sizing reset */
#pt-app-container, #pt-app-container *, .pt-article-wrap, .pt-article-wrap * {
    box-sizing: border-box; 
    
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ==========================================
   PLUGIN UI STYLES (Scoped to #pt-app-container)
   ========================================== */
#pt-app-container {
    background: var(--bg);
    color: var(--text) !important; 
    border: 1px solid var(--border); 
     
    overflow: hidden; 
    height: 80vh; 
    max-height: 900px;
    display: flex;
}

.pt-app { display: flex; width: 100%; height: 100%; }

/* Sidebar */
.pt-sidebar { width: 220px; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 16px 0; flex-shrink: 0; }
.pt-logo { padding: 0 20px 24px; font-size: 1.1rem; font-weight: 700; color: var(--accent); }
.pt-nav-btn { background: none; border: none; color: var(--muted) !important; padding: 12px 20px; text-align: left; cursor: pointer; font-size: 0.95rem; transition: 0.2s; width: 100%; }
.pt-nav-btn:hover { background: var(--surface-2); color: var(--text) !important; }
.pt-nav-btn.active { background: var(--surface-2); color: var(--accent) !important; border-left: 3px solid var(--accent); padding-left: 17px; }

/* Main Area */
.pt-main { flex: 1; display: flex; flex-direction: column; overflow: hidden; background: var(--bg); }
.pt-view { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.hidden { display: none !important; }

/* Header */
.pt-header { padding: 16px 24px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; background: var(--surface); flex-shrink: 0; gap: 16px; }
.pt-title-input { background: transparent; border: none; color: var(--text) !important; font-size: 1.2rem; font-weight: 600; outline: none; width: 100%; }
.pt-title-input::placeholder { color: var(--muted); }
.pt-badge { padding: 6px 12px; border-radius: 20px; font-size: 0.75rem; font-weight: 600; white-space: nowrap; }
.pt-badge.local { background: rgba(16, 185, 129, 0.1); color: var(--success) !important; }

/* Controls */
.pt-controls { padding: 12px 24px; background: var(--surface); border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; flex-shrink: 0; }
.pt-status-grid { display: flex; gap: 24px; flex-wrap: wrap; }
.pt-status { display: flex; flex-direction: column; }
.pt-status span { font-size: 0.7rem; color: var(--muted) !important; text-transform: uppercase; }
.pt-status strong { font-size: 0.95rem; font-variant-numeric: tabular-nums; color: var(--text) !important; }

.pt-btn-group { display: flex; gap: 8px; }
.pt-btn { padding: 8px 16px; border: none; border-radius: 6px; font-weight: 600; cursor: pointer; font-size: 0.9rem; }
.pt-btn-primary { background: var(--accent); color: #ffffff !important; }
.pt-btn-primary:hover { background: var(--accent-hover); }
.pt-btn-primary:disabled { background: var(--muted); cursor: not-allowed; }
.pt-btn-secondary { background: var(--surface-2); color: var(--text) !important; border: 1px solid var(--border); }
.pt-btn-danger { background: var(--danger); color: #ffffff !important; }

/* Workspace */
.pt-workspace { display: flex; flex: 1; overflow: hidden; }
.pt-transcript-area { flex: 1; padding: 16px 24px; overflow-y: auto; background: var(--bg); }
.pt-side-panel { width: 250px; background: var(--surface); border-left: 1px solid var(--border); padding: 16px; overflow-y: auto; flex-shrink: 0; }
.pt-side-panel h3 { font-size: 0.9rem; text-transform: uppercase; color: var(--muted) !important; margin-bottom: 12px; }

/* Transcript Segments */
.pt-segment { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 12px; margin-bottom: 12px; content-visibility: auto; }
.pt-seg-header { display: flex; justify-content: space-between; margin-bottom: 6px; }
.pt-speaker { font-weight: 700; font-size: 0.9rem; }
.pt-speaker.spk-1 { color: var(--spk-1) !important; }
.pt-speaker.spk-2 { color: var(--spk-2) !important; }
.pt-time { color: var(--muted) !important; font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.pt-seg-text { line-height: 1.5; font-size: 0.95rem; color: var(--text) !important; }
.pt-placeholder { color: var(--muted) !important; text-align: center; padding: 40px; font-style: italic; }

/* Meetings List */
.pt-meetings-list { padding: 24px; overflow-y: auto; }
.pt-meeting-card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 16px; margin-bottom: 12px; }
.pt-meeting-card h4 { margin-bottom: 8px; color: var(--accent) !important; }
.pt-meeting-card p { font-size: 0.9rem; color: var(--muted) !important; margin-bottom: 8px; }
.pt-meeting-card span { font-size: 0.8rem; background: var(--surface-2); padding: 4px 8px; border-radius: 4px; color: var(--text) !important; }

/* Loading Screen UI */
#pt-loading-screen { color: var(--text) !important; display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; padding: 40px; text-align: center; }
.pt-loader-icon { font-size: 3rem; margin-bottom: 16px; animation: pt-spin 2s linear infinite; }
@keyframes pt-spin { 100% { transform: rotate(360deg); } }
#pt-loading-screen h3 { color: var(--text) !important; margin-bottom: 24px; }
.pt-progress-bar-container { width: 100%; max-width: 500px; height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; margin-bottom: 16px; }
.pt-progress-bar { height: 100%; background: var(--accent); border-radius: 4px; transition: width 0.3s ease; }
.pt-progress-stats { display: flex; flex-wrap: wrap; justify-content: center; gap: 24px; font-size: 0.85rem; color: var(--muted) !important; margin-bottom: 16px; }
.pt-progress-stats strong { color: var(--text) !important; }
.pt-progress-info { font-size: 0.8rem; color: var(--muted) !important; max-width: 400px; line-height: 1.4; }

/* Plugin Responsive / Mobile */
@media (max-width: 768px) {
    #pt-app-container { flex-direction: column; height: auto; min-height: 90vh; }
    .pt-sidebar { width: 100%; display: flex; flex-direction: row; padding: 8px; overflow-x: auto; }
    .pt-logo { display: none; }
    .pt-nav-btn { padding: 8px 12px; white-space: nowrap; border-left: none; border-bottom: 3px solid transparent; }
    .pt-nav-btn.active { border-left: none; border-bottom: 3px solid var(--accent); padding-left: 12px; }
    .pt-header { flex-direction: column; align-items: flex-start; }
    .pt-controls { flex-direction: column; align-items: stretch; }
    .pt-status-grid { justify-content: space-between; }
    .pt-workspace { flex-direction: column; }
    .pt-side-panel { width: 100%; border-left: none; border-top: 1px solid var(--border); max-height: 200px; }
}

/* ==========================================
   ARTICLE SHORTCODE STYLES (Always Dark, Full Width/Height)
   ========================================== */
.pt-article-wrap {
    background-color: #0f1115 !important; /* Deep dark background spanning full width */
    color: #cbd5e1 !important; 
    line-height: 1.8;
    padding: 60px 26% !important; /* Large padding so background is huge but text stays readable */
    margin: 0 !important; /* Remove margins to span full width of the container */
    width: 100% !important;
    max-width: 100% !important; /* Override inline PHP max-width */
    min-height: 80vh !important; /* Ensure it has significant height */
    box-sizing: border-box !important;
    display: block;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

.pt-article-wrap h1, 
.pt-article-wrap h2, 
.pt-article-wrap h3, 
.pt-article-wrap h4 {
    color: #f8fafc !important; 
    font-weight: 700;
    line-height: 1.3;
    margin-top: 2.5em;
    margin-bottom: 0.8em;
}

.pt-article-wrap h1 {
    font-size: clamp(1.8rem, 5vw, 2.5rem);
    border-bottom: 1px solid #334155;
    padding-bottom: 0.5em;
    margin-bottom: 1em;
    margin-top: 0; 
}

.pt-article-wrap h2 {
    font-size: clamp(1.5rem, 4vw, 1.8rem);
    color: #60a5fa !important; 
    border-bottom: 1px solid #1e293b;
    padding-bottom: 0.3em;
}

.pt-article-wrap h3 {
    font-size: clamp(1.2rem, 3vw, 1.4rem);
    color: #e2e8f0 !important;
}

.pt-article-wrap p {
    margin-bottom: 1.5em;
    font-size: 1.05rem;
}

.pt-article-wrap a {
    color: #60a5fa;
    text-decoration: none;
    transition: color 0.2s ease;
}

.pt-article-wrap a:hover {
    color: #93c5fd;
    text-decoration: underline;
}

.pt-article-wrap strong {
    color: #ffffff; 
    font-weight: 700;
}

.pt-article-wrap code {
    background-color: #1a1d24; 
    color: #f472b6; 
    padding: 0.2em 0.4em;
    border-radius: 4px;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 0.9em;
    border: 1px solid #2c303a;
}

/* Dark Alert Box */
.pt-article-wrap div[style*="border-left"] {
    background: #1a1d24 !important; 
    border-left: 4px solid #3b82f6 !important;
    border-radius: 6px !important;
    padding: 20px !important;
    margin-top: 40px !important;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
}

.pt-article-wrap div[style*="border-left"] p,
.pt-article-wrap div[style*="border-left"] strong {
    color: #cbd5e1 !important;
    margin: 0 !important;
    font-size: 0.95rem !important;
}

/* Article Responsive */
@media (max-width: 768px) {
    .pt-article-wrap {
        padding: 40px 20px !important; /* Reduce padding on mobile so text fits */
    }
    .pt-article-wrap p {
        font-size: 1rem;
    }
}