/* Premium SaaS CSS Design System - Real-time 9-Split Grid Monitor */

:root {
    /* Color Palette */
    --bg-primary: hsl(222, 47%, 8%);
    --bg-secondary: hsla(223, 47%, 14%, 0.4);
    --card-bg: hsla(223, 47%, 12%, 0.55);
    --card-border: hsla(0, 0%, 100%, 0.07);
    
    --text-primary: hsl(210, 40%, 98%);
    --text-secondary: hsl(215, 20%, 80%);
    --text-muted: hsl(215, 16%, 58%);
    
    --threads-color: hsl(270, 89%, 65%);
    --threads-glow: hsla(270, 89%, 65%, 0.15);
    
    --x-color: hsl(192, 90%, 55%);
    --x-glow: hsla(192, 90%, 55%, 0.15);
    
    --youtube-color: hsl(354, 84%, 57%);
    --youtube-glow: hsla(354, 84%, 57%, 0.15);

    --reddit-color: hsl(16, 90%, 58%);
    --reddit-glow: hsla(16, 90%, 58%, 0.15);
    
    --facebook-color: hsl(218, 86%, 62%);
    --facebook-glow: hsla(218, 86%, 62%, 0.15);
    
    --google-color: hsl(45, 92%, 58%);
    --google-glow: hsla(45, 92%, 58%, 0.15);
    
    --community-color: hsl(150, 70%, 48%);
    --community-glow: hsla(150, 70%, 48%, 0.15);
    
    --news-color: hsl(30, 84%, 56%);
    --news-glow: hsla(30, 84%, 56%, 0.15);
    
    --blog-color: hsl(330, 74%, 62%);
    --blog-glow: hsla(330, 74%, 62%, 0.15);
    
    --accent-teal: hsl(174, 84%, 45%);
    --accent-teal-glow: hsla(174, 84%, 45%, 0.15);
    --success-green: hsl(142, 72%, 50%);
    
    --border-radius: 14px;
    --transition-smooth: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    --glass-blur: blur(14px) saturate(180%);
}

/* Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* Background Ambient Glows */
.glow-bg {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(circle at 10% 15%, hsla(270, 89%, 65%, 0.05) 0%, transparent 35%),
        radial-gradient(circle at 85% 15%, hsla(192, 90%, 55%, 0.04) 0%, transparent 35%),
        radial-gradient(circle at 50% 85%, hsla(354, 84%, 57%, 0.04) 0%, transparent 35%);
    pointer-events: none;
    z-index: -1;
}

/* Header Styles */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 24px;
    border-bottom: 1px solid var(--card-border);
    background: hsla(222, 47%, 8%, 0.7);
    backdrop-filter: var(--glass-blur);
    z-index: 10;
    height: 64px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-icon {
    width: 24px;
    height: 24px;
    color: var(--accent-teal);
}

.pulsing {
    animation: pulse-glow 2.5s infinite ease-in-out;
}

@keyframes pulse-glow {
    0%, 100% { opacity: 0.6; transform: scale(1); filter: drop-shadow(0 0 1px var(--accent-teal)); }
    50% { opacity: 1; transform: scale(1.08); filter: drop-shadow(0 0 8px var(--accent-teal)); }
}

.brand h1 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.saas-badge {
    background: var(--accent-teal-glow);
    color: var(--accent-teal);
    font-size: 0.66rem;
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid var(--accent-teal);
    text-transform: uppercase;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 16px;
}

.system-status {
    display: flex;
    align-items: center;
    gap: 8px;
    background: hsla(0, 0%, 100%, 0.04);
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid var(--card-border);
    font-size: 0.8rem;
}

.status-indicator {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background-color: var(--text-muted);
}

.status-indicator.active {
    background-color: var(--success-green);
    box-shadow: 0 0 6px var(--success-green);
}

/* Sidebar Toggle Button */
.btn-sidebar-toggle {
    background: hsla(0, 0%, 100%, 0.05);
    border: 1px solid var(--card-border);
    color: var(--text-primary);
    padding: 7px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition-smooth);
}

.btn-sidebar-toggle:hover {
    background: var(--accent-teal);
    color: black;
    border-color: var(--accent-teal);
    box-shadow: 0 0 12px var(--accent-teal-glow);
}

/* 3x3 Grid Layout */
.app-container {
    display: flex;
    flex-grow: 1;
    position: relative;
    overflow: hidden;
    height: calc(100vh - 64px);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 14px;
    padding: 14px;
    flex-grow: 1;
    overflow-y: auto;
    transition: var(--transition-smooth);
}

@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: auto;
    }
}
@media (max-width: 680px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

/* Card General Styling */
.card {
    background-color: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius);
    backdrop-filter: var(--glass-blur);
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: var(--transition-smooth);
    position: relative;
    overflow: hidden;
}

.card:hover {
    transform: translateY(-2px);
    border-color: hsla(0, 0%, 100%, 0.12);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

/* Glow Borders based on Platform */
.threads-card:hover { box-shadow: 0 4px 20px var(--threads-glow); border-color: hsla(270, 89%, 65%, 0.25); }
.x-platform-card:hover { box-shadow: 0 4px 20px var(--x-glow); border-color: hsla(192, 90%, 55%, 0.25); }
.youtube-card:hover { box-shadow: 0 4px 20px var(--youtube-glow); border-color: hsla(354, 84%, 57%, 0.25); }
.reddit-card:hover { box-shadow: 0 4px 20px var(--reddit-glow); border-color: hsla(16, 90%, 58%, 0.25); }
.facebook-card:hover { box-shadow: 0 4px 20px var(--facebook-glow); border-color: hsla(218, 86%, 62%, 0.25); }
.google-card:hover { box-shadow: 0 4px 20px var(--google-glow); border-color: hsla(45, 92%, 58%, 0.25); }
.community-card:hover { box-shadow: 0 4px 20px var(--community-glow); border-color: hsla(150, 70%, 48%, 0.25); }
.news-card:hover { box-shadow: 0 4px 20px var(--news-glow); border-color: hsla(30, 84%, 56%, 0.25); }
.blog-card:hover { box-shadow: 0 4px 20px var(--blog-glow); border-color: hsla(330, 74%, 62%, 0.25); }

/* Card Header */
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    padding-bottom: 8px;
}

.platform-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    padding: 3px 8px;
    border-radius: 10px;
}

.platform-badge i {
    width: 12px;
    height: 12px;
}

.platform-badge.threads { background: hsla(270, 89%, 65%, 0.12); color: var(--threads-color); }
.platform-badge.x-platform { background: hsla(192, 90%, 55%, 0.12); color: var(--x-color); }
.platform-badge.youtube { background: hsla(354, 84%, 57%, 0.12); color: var(--youtube-color); }
.platform-badge.reddit { background: hsla(16, 90%, 58%, 0.12); color: var(--reddit-color); }
.platform-badge.facebook { background: hsla(218, 86%, 62%, 0.12); color: var(--facebook-color); }
.platform-badge.google { background: hsla(45, 92%, 58%, 0.12); color: var(--google-color); }
.platform-badge.community { background: hsla(150, 70%, 48%, 0.12); color: var(--community-color); }
.platform-badge.news { background: hsla(30, 84%, 56%, 0.12); color: var(--news-color); }
.platform-badge.blog { background: hsla(330, 74%, 62%, 0.12); color: var(--blog-color); }

.card-time {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* Card Body */
.card-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-grow: 1;
    justify-content: flex-start;
}

/* Premium Dynamic Card Layouts (SaaS specific) */
.native-post-layout {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex-grow: 1;
}

/* Author block */
.post-author-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
}

.post-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}

.post-author-info {
    display: flex;
    flex-direction: column;
}

.post-author-name {
    font-size: 0.84rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 4px;
}

.post-author-handle {
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* Verified Check Badge */
.verified-check {
    color: var(--x-color);
    width: 13px !important;
    height: 13px !important;
    display: inline-block;
}

/* Rendered Content */
.post-title {
    font-family: 'Outfit', sans-serif;
    font-size: 0.92rem;
    font-weight: 600;
    line-height: 1.3;
    color: var(--text-primary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.post-text {
    font-size: 0.84rem;
    line-height: 1.45;
    color: var(--text-secondary);
    white-space: pre-wrap;
    user-select: text; /* 100% Copyable! */
    display: -webkit-box;
    -webkit-line-clamp: 5; /* Compact snippet */
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* YouTube Thumbnail Frame (Only loads image from standard CDN link) */
.youtube-thumbnail-frame {
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    aspect-ratio: 16 / 9;
    background-color: black;
    border: 1px solid var(--card-border);
}

.youtube-thumbnail-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.play-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(230, 33, 23, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 0 12px rgba(230,33,23,0.4);
    transition: var(--transition-smooth);
}

.youtube-thumbnail-frame:hover .play-overlay {
    background: rgba(230, 33, 23, 1);
    transform: translate(-50%, -50%) scale(1.08);
    box-shadow: 0 0 18px rgba(230,33,23,0.6);
}

/* Mock Social Engagement Footer */
.post-engagement-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid rgba(255, 255, 255, 0.03);
    padding-top: 8px;
    margin-top: auto;
    font-size: 0.72rem;
    color: var(--text-muted);
}

.engagement-actions {
    display: flex;
    gap: 12px;
}

.action-item {
    display: flex;
    align-items: center;
    gap: 3px;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.action-item:hover {
    color: var(--text-primary);
}

.action-item i {
    width: 13px;
    height: 13px;
}

.external-action-link {
    color: var(--accent-teal);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 3px;
}

.external-action-link:hover {
    text-decoration: underline;
}

.external-action-link i {
    width: 12px;
    height: 12px;
}

.source-status {
    align-self: flex-start;
    border: 1px solid var(--card-border);
    border-radius: 6px;
    color: var(--text-muted);
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.4px;
    padding: 3px 6px;
    margin-top: auto;
}

/* Collapsible Settings & Logs Sidebar */
.settings-sidebar {
    width: 400px;
    height: 100%;
    background: hsla(222, 47%, 6%, 0.85);
    backdrop-filter: var(--glass-blur);
    border-left: 1px solid var(--card-border);
    display: flex;
    flex-direction: column;
    transition: var(--transition-smooth);
    position: relative;
    z-index: 100;
    box-shadow: -10px 0 30px rgba(0,0,0,0.5);
    flex-shrink: 0;
}

.settings-sidebar.collapsed {
    transform: translateX(100%);
    width: 0;
    margin-left: 0;
    border-left: none;
    box-shadow: none;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--card-border);
}

.sidebar-header h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-header h2 i {
    width: 18px;
    height: 18px;
    color: var(--accent-teal);
}

.close-sidebar {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: var(--transition-smooth);
}

.close-sidebar:hover {
    color: white;
    background: rgba(255, 255, 255, 0.05);
}

.sidebar-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 16px 20px;
    overflow-y: auto;
    flex-grow: 1;
}

/* Sidebar Cards */
.sidebar-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius);
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sidebar-card-header {
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    font-size: 0.88rem;
    border-bottom: 1px solid var(--card-border);
    padding-bottom: 8px;
    margin-bottom: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
}

.sidebar-card-header i {
    width: 14px;
    height: 14px;
}

/* Collapsible */
.sidebar-card {
    transition: padding var(--transition-smooth), gap var(--transition-smooth);
}

.sidebar-card .control-body,
.sidebar-card .stats-body,
.sidebar-card .terminal-body {
    transition: max-height 0.35s cubic-bezier(0.25, 0.8, 0.25, 1), opacity 0.25s ease;
    max-height: 1000px;
    opacity: 1;
    overflow: hidden;
}

.sidebar-card.collapsed {
    padding-bottom: 8px;
    gap: 0;
}

.sidebar-card.collapsed .control-body,
.sidebar-card.collapsed .stats-body,
.sidebar-card.collapsed .terminal-body {
    max-height: 0;
    opacity: 0;
    pointer-events: none;
}

.sidebar-card.collapsed .sidebar-card-header {
    border-bottom-color: transparent;
    padding-bottom: 0;
    margin-bottom: 0;
}

.collapse-chevron {
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    color: var(--text-muted);
}

.sidebar-card.collapsed .collapse-chevron {
    transform: rotate(-180deg);
}

.control-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.control-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    font-size: 0.84rem;
}

.control-row-col {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.slider-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Switch styling */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 22px;
}

.switch input { 
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #243342;
    transition: .3s;
    border: 1px solid var(--card-border);
}

.slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
}

input:checked + .slider {
    background-color: var(--accent-teal);
}

input:checked + .slider:before {
    transform: translateX(22px);
}

.slider.round {
    border-radius: 22px;
}

.slider.round:before {
    border-radius: 50%;
}

input[type="text"],
input[type="password"] {
    background-color: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--card-border);
    border-radius: 6px;
    padding: 6px 10px;
    color: white;
    font-family: inherit;
    font-size: 0.8rem;
    flex-grow: 1;
    transition: var(--transition-smooth);
}

input[type="text"]:focus,
input[type="password"]:focus,
.select-premium:focus {
    outline: none;
    border-color: var(--accent-teal);
    box-shadow: 0 0 6px var(--accent-teal-glow);
}

.select-premium {
    background-color: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--card-border);
    border-radius: 6px;
    padding: 6px 10px;
    color: white;
    font-family: inherit;
    font-size: 0.8rem;
    transition: var(--transition-smooth);
    cursor: pointer;
    outline: none;
    width: 65%;
}

.select-premium option {
    background-color: var(--bg-primary);
    color: white;
}

.password-container {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.btn-eye-toggle {
    position: absolute;
    right: 8px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
}

.btn-eye-toggle i {
    width: 14px;
    height: 14px;
}

.btn-primary {
    background: var(--accent-teal);
    color: black;
    border: none;
    border-radius: 6px;
    padding: 8px 14px;
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: var(--transition-smooth);
}

.btn-primary:hover {
    background: white;
    box-shadow: 0 0 14px rgba(255,255,255,0.25);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--card-border);
    color: var(--text-secondary);
    border-radius: 6px;
    padding: 8px 14px;
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: var(--transition-smooth);
}

.btn-outline:hover {
    border-color: white;
    color: white;
}

.input-with-btn {
    display: flex;
    gap: 6px;
    width: 100%;
}

.manual-triggers {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 6px;
}

.manual-triggers .btn-primary,
.manual-triggers .btn-outline {
    width: 100%;
}

/* Real-Time Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.stat-box {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--card-border);
    border-radius: 8px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.stat-label {
    font-size: 0.64rem;
    color: var(--text-muted);
}

.stat-value {
    font-family: 'Outfit', sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent-teal);
}

/* Sentiment Bar */
.sentiment-container {
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: rgba(0, 0, 0, 0.15);
    border: 1px solid var(--card-border);
    border-radius: 8px;
    padding: 10px;
}

.sentiment-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.74rem;
    color: var(--text-secondary);
}

.sentiment-bar-bg {
    width: 100%;
    height: 6px;
    background-color: #222;
    border-radius: 3px;
    overflow: hidden;
}

.sentiment-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #ff453a 0%, #ffd60a 50%, var(--success-green) 100%);
    border-radius: 3px;
    transition: width 0.5s ease-in-out;
}

.sentiment-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.62rem;
    color: var(--text-muted);
}

/* AI Insights */
.quick-insight {
    background: hsla(174, 84%, 45%, 0.03);
    border: 1px dashed hsla(174, 84%, 45%, 0.2);
    border-radius: 8px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.insight-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent-teal);
    display: flex;
    align-items: center;
    gap: 4px;
}

.insight-text {
    font-size: 0.76rem;
    line-height: 1.45;
    color: var(--text-secondary);
}

/* System Logs */
.log-sidebar-card {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-height: 200px;
    max-height: 350px;
}

.btn-icon-small {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    padding: 2px;
}

.btn-icon-small:hover {
    color: var(--youtube-color);
}

.btn-icon-small i {
    width: 12px;
    height: 12px;
}

.terminal-body {
    flex-grow: 1;
    background: rgba(0, 0, 0, 0.45);
    border: 1px solid var(--card-border);
    border-radius: 8px;
    padding: 10px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.72rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.log-line {
    word-break: break-all;
    line-height: 1.35;
}

.log-line.info { color: var(--text-secondary); }
.log-line.success { color: var(--success-green); }
.log-line.warning { color: var(--google-color); }
.log-line.error { color: var(--youtube-color); font-weight: 600; }
