/* 
 * LinkedIn Content Hub — Global Styles
 * Design: Dark Mode, Glassmorphism, Premium UI
 */

/* ============================================================
   FONTS & RESET
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    /* Brand Colors */
    --linkedin-blue: #0077b5;
    --linkedin-dark: #004471;
    --linkedin-light: #38bdf8;

    /* Dark UI */
    --bg-primary:    #0a0e1a;
    --bg-secondary:  #0f172a;
    --bg-surface:    #1e293b;
    --bg-elevated:   #263147;
    --bg-hover:      #2d3a52;

    /* Text */
    --text-primary:  #f1f5f9;
    --text-secondary:#94a3b8;
    --text-muted:    #64748b;
    --text-accent:   #38bdf8;

    /* Borders */
    --border:        rgba(148,163,184,0.12);
    --border-hover:  rgba(148,163,184,0.25);

    /* Accent */
    --accent-purple: #6366f1;
    --accent-cyan:   #06b6d4;
    --accent-green:  #22c55e;
    --accent-orange: #f97316;
    --accent-red:    #ef4444;
    --accent-yellow: #eab308;

    /* Gradients */
    --grad-linkedin: linear-gradient(135deg, #0077b5, #005885);
    --grad-ai:       linear-gradient(135deg, #6366f1, #8b5cf6);
    --grad-success:  linear-gradient(135deg, #22c55e, #16a34a);

    /* Effects */
    --glass: rgba(255,255,255,0.03);
    --glass-border: rgba(255,255,255,0.08);
    --shadow-lg: 0 25px 60px rgba(0,0,0,0.5);
    --shadow-md: 0 8px 30px rgba(0,0,0,0.3);
    --shadow-blue: 0 8px 30px rgba(0,119,181,0.3);

    /* Spacing */
    --sidebar-w: 260px;
    --topbar-h: 64px;
    --radius: 0.75rem;
    --radius-lg: 1.25rem;
}

html { scroll-behavior: smooth; }

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* ============================================================
   LAYOUT
   ============================================================ */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
    width: var(--sidebar-w);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-logo {
    padding: 1.5rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-logo-icon {
    width: 38px; height: 38px;
    background: var(--grad-linkedin);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}

.sidebar-logo-text { font-weight: 800; font-size: 1rem; color: var(--text-primary); }
.sidebar-logo-sub  { font-size: 0.7rem; color: var(--text-muted); }

.sidebar-nav {
    flex: 1;
    padding: 1rem 0.75rem;
    overflow-y: auto;
}

.sidebar-section-label {
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 0.5rem 0.5rem 0.3rem;
    margin-top: 0.5rem;
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0.75rem;
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 0.15rem;
}

.sidebar-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.sidebar-item.active {
    background: rgba(0,119,181,0.15);
    color: var(--linkedin-light);
    border: 1px solid rgba(0,119,181,0.2);
}

.sidebar-item-icon { font-size: 1.1rem; flex-shrink: 0; }

.sidebar-item-badge {
    margin-left: auto;
    background: rgba(0,119,181,0.2);
    color: var(--linkedin-light);
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.15rem 0.5rem;
    border-radius: 2rem;
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--border);
}

.sidebar-user {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.5rem;
    border-radius: var(--radius);
    transition: background 0.2s;
}

.sidebar-user:hover { background: var(--bg-hover); }

.sidebar-user-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--grad-linkedin);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.85rem; color: white;
    flex-shrink: 0;
    overflow: hidden;
}

.sidebar-user-avatar img { width: 100%; height: 100%; object-fit: cover; }
.sidebar-user-name { font-size: 0.85rem; font-weight: 600; }
.sidebar-user-role { font-size: 0.72rem; color: var(--text-muted); }

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar {
    height: var(--topbar-h);
    background: rgba(15,23,42,0.9);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(20px);
    position: sticky; top: 0; z-index: 50;
    display: flex; align-items: center;
    padding: 0 1.5rem;
    gap: 1rem;
}

.topbar-title { font-size: 1.1rem; font-weight: 700; flex: 1; }

.topbar-actions { display: flex; align-items: center; gap: 0.75rem; }

/* ============================================================
   PAGE CONTENT
   ============================================================ */
.page-content { padding: 1.75rem; flex: 1; }

/* ============================================================
   CARDS
   ============================================================ */
.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.card:hover { border-color: var(--border-hover); }

.card-glass {
    background: rgba(30,41,59,0.5);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
}

.card-header {
    display: flex; align-items: center; gap: 0.75rem;
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.card-title { font-size: 1rem; font-weight: 700; color: var(--text-primary); }
.card-subtitle { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.2rem; }

/* ============================================================
   STAT CARDS
   ============================================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.75rem;
}

.stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    display: flex; align-items: flex-start; gap: 1rem;
    transition: all 0.3s ease;
    position: relative; overflow: hidden;
}

.stat-card::before {
    content: ''; position: absolute; inset: 0;
    background: linear-gradient(135deg, transparent 60%, rgba(255,255,255,0.02));
    pointer-events: none;
}

.stat-card:hover { border-color: var(--border-hover); transform: translateY(-2px); box-shadow: var(--shadow-md); }

.stat-icon {
    width: 46px; height: 46px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem; flex-shrink: 0;
}

.stat-icon.blue   { background: rgba(0,119,181,0.15); }
.stat-icon.purple { background: rgba(99,102,241,0.15); }
.stat-icon.green  { background: rgba(34,197,94,0.15); }
.stat-icon.orange { background: rgba(249,115,22,0.15); }
.stat-icon.cyan   { background: rgba(6,182,212,0.15); }

.stat-value { font-size: 1.8rem; font-weight: 800; line-height: 1; }
.stat-label { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.3rem; }
.stat-change { font-size: 0.75rem; margin-top: 0.4rem; }
.stat-change.up   { color: var(--accent-green); }
.stat-change.down { color: var(--accent-red); }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    display: inline-flex; align-items: center; gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 600;
    border: none; cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    text-decoration: none;
    white-space: nowrap;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
    background: var(--grad-linkedin);
    color: white;
    box-shadow: var(--shadow-blue);
}
.btn-primary:hover:not(:disabled) { opacity: 0.9; transform: translateY(-1px); }

.btn-ai {
    background: var(--grad-ai);
    color: white;
    box-shadow: 0 4px 20px rgba(99,102,241,0.3);
}
.btn-ai:hover:not(:disabled) { opacity: 0.9; transform: translateY(-1px); }

.btn-success {
    background: var(--grad-success);
    color: white;
}
.btn-success:hover:not(:disabled) { opacity: 0.9; }

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
}
.btn-outline:hover:not(:disabled) { border-color: var(--border-hover); color: var(--text-primary); background: var(--glass); }

.btn-danger {
    background: rgba(239,68,68,0.15);
    border: 1px solid rgba(239,68,68,0.3);
    color: #f87171;
}
.btn-danger:hover:not(:disabled) { background: rgba(239,68,68,0.25); }

.btn-sm { padding: 0.4rem 0.85rem; font-size: 0.8rem; }
.btn-lg { padding: 0.85rem 1.75rem; font-size: 1rem; }
.btn-full { width: 100%; justify-content: center; }

/* ============================================================
   FORMS
   ============================================================ */
.form-group { margin-bottom: 1.25rem; }
.form-label {
    display: block;
    font-size: 0.8rem; font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
    text-transform: uppercase; letter-spacing: 0.04em;
}

.form-control {
    width: 100%;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.65rem 0.9rem;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
}

.form-control:focus {
    border-color: var(--linkedin-blue);
    box-shadow: 0 0 0 3px rgba(0,119,181,0.15);
}

.form-control::placeholder { color: var(--text-muted); }

textarea.form-control {
    resize: vertical;
    min-height: 140px;
    line-height: 1.6;
}

select.form-control { cursor: pointer; }

.form-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.35rem;
}

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* ============================================================
   BADGE
   ============================================================ */
.badge {
    display: inline-flex; align-items: center; gap: 0.3rem;
    padding: 0.2rem 0.6rem;
    border-radius: 2rem; font-size: 0.72rem; font-weight: 600;
}
.badge-gray   { background: rgba(148,163,184,0.1); color: #94a3b8; }
.badge-blue   { background: rgba(56,189,248,0.1);  color: #38bdf8; }
.badge-green  { background: rgba(34,197,94,0.1);   color: #4ade80; }
.badge-red    { background: rgba(239,68,68,0.1);   color: #f87171; }
.badge-orange { background: rgba(249,115,22,0.1);  color: #fb923c; }
.badge-purple { background: rgba(99,102,241,0.1);  color: #a5b4fc; }

/* ============================================================
   TABLE
   ============================================================ */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    background: var(--bg-surface);
    padding: 0.85rem 1rem;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-bottom: 1px solid var(--border);
}

td {
    padding: 1rem 1rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.875rem;
    vertical-align: middle;
}

tr:last-child td { border-bottom: none; }

tbody tr { transition: background 0.15s; }
tbody tr:hover { background: rgba(255,255,255,0.02); }

/* ============================================================
   ALERTS & FLASH
   ============================================================ */
.alert {
    padding: 0.9rem 1.2rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    margin-bottom: 1.25rem;
    display: flex; align-items: flex-start; gap: 0.6rem;
    line-height: 1.5;
}

.alert-success { background: rgba(34,197,94,0.1);  border: 1px solid rgba(34,197,94,0.3);  color: #4ade80; }
.alert-error   { background: rgba(239,68,68,0.1);  border: 1px solid rgba(239,68,68,0.3);  color: #f87171; }
.alert-info    { background: rgba(56,189,248,0.1); border: 1px solid rgba(56,189,248,0.3); color: #38bdf8; }
.alert-warning { background: rgba(234,179,8,0.1);  border: 1px solid rgba(234,179,8,0.3);  color: #fbbf24; }

/* ============================================================
   PAGE HEADER
   ============================================================ */
.page-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 1.75rem;
    flex-wrap: wrap; gap: 1rem;
}

.page-header-left h1 { font-size: 1.5rem; font-weight: 800; }
.page-header-left p  { color: var(--text-secondary); font-size: 0.875rem; margin-top: 0.2rem; }

/* ============================================================
   AI CONTENT BOX
   ============================================================ */
.ai-panel {
    background: linear-gradient(135deg, rgba(99,102,241,0.08), rgba(139,92,246,0.08));
    border: 1px solid rgba(99,102,241,0.2);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
}

.ai-panel-header {
    display: flex; align-items: center; gap: 0.5rem;
    margin-bottom: 1rem;
    color: #a5b4fc; font-weight: 600; font-size: 0.9rem;
}

.ai-loading {
    display: flex; align-items: center; gap: 0.75rem;
    color: var(--text-secondary); font-size: 0.875rem;
}

.spinner {
    width: 20px; height: 20px;
    border: 2px solid rgba(99,102,241,0.3);
    border-top-color: #6366f1;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ============================================================
   CALENDAR
   ============================================================ */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.4rem;
}

.calendar-day-header {
    text-align: center;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    padding: 0.5rem;
}

.calendar-day {
    min-height: 80px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 0.4rem;
    position: relative;
    cursor: pointer;
    transition: all 0.2s;
}

.calendar-day:hover { border-color: var(--border-hover); background: var(--bg-elevated); }
.calendar-day.today { border-color: var(--linkedin-blue); background: rgba(0,119,181,0.07); }
.calendar-day.other-month { opacity: 0.4; }

.calendar-day-num {
    font-size: 0.8rem; font-weight: 600;
    color: var(--text-secondary);
}

.calendar-day.today .calendar-day-num {
    background: var(--linkedin-blue);
    color: white;
    width: 22px; height: 22px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
}

.calendar-post-dot {
    font-size: 0.65rem;
    padding: 0.1rem 0.35rem;
    border-radius: 3px;
    margin-top: 0.25rem;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.dot-scheduled { background: rgba(56,189,248,0.2); color: #38bdf8; }
.dot-published  { background: rgba(34,197,94,0.2);  color: #4ade80; }
.dot-draft      { background: rgba(148,163,184,0.15);color: #94a3b8; }

/* ============================================================
   LINKEDIN PREVIEW
   ============================================================ */
.linkedin-preview {
    background: #1b1f23;
    border: 1px solid #2d3139;
    border-radius: 0.75rem;
    padding: 1.25rem;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.preview-header {
    display: flex; align-items: center; gap: 0.75rem;
    margin-bottom: 1rem;
}

.preview-avatar {
    width: 48px; height: 48px;
    border-radius: 50%;
    background: var(--grad-linkedin);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; color: white; font-size: 1.1rem;
}

.preview-name  { font-weight: 600; color: #e7e9ec; font-size: 0.9rem; }
.preview-meta  { font-size: 0.75rem; color: #8a909e; }

.preview-content {
    color: #e7e9ec; font-size: 0.9rem; line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}

.preview-hashtags { color: #70b5f9; }

.preview-actions {
    display: flex; gap: 1rem;
    margin-top: 1rem; padding-top: 0.75rem;
    border-top: 1px solid #2d3139;
}

.preview-action {
    font-size: 0.8rem; color: #8a909e;
    display: flex; align-items: center; gap: 0.3rem;
    cursor: pointer;
}

/* ============================================================
   TABS
   ============================================================ */
.tabs {
    display: flex; gap: 0.25rem;
    background: var(--bg-surface);
    padding: 0.3rem;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    width: fit-content;
}

.tab-item {
    padding: 0.5rem 1.1rem;
    border-radius: calc(var(--radius) - 0.2rem);
    font-size: 0.85rem; font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    border: none; background: none; font-family: inherit;
}

.tab-item:hover { color: var(--text-primary); }
.tab-item.active { background: var(--bg-elevated); color: var(--text-primary); font-weight: 600; }

/* ============================================================
   TOGGLE SWITCH
   ============================================================ */
.toggle-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}

.toggle-row:last-child { border-bottom: none; }

.toggle-switch {
    position: relative; display: inline-block;
    width: 44px; height: 24px;
}

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

.toggle-slider {
    position: absolute; inset: 0;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 24px;
    cursor: pointer;
    transition: 0.3s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    height: 16px; width: 16px;
    left: 3px; bottom: 3px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: 0.3s;
}

input:checked + .toggle-slider { background: var(--linkedin-blue); border-color: var(--linkedin-blue); }
input:checked + .toggle-slider::before { transform: translateX(20px); background: white; }

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-elevated); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-hover); }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1024px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .form-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .page-content { padding: 1rem; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .calendar-grid { grid-template-columns: repeat(7, 1fr); }
    .calendar-day { min-height: 50px; }
}

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

.animate-in { animation: fadeInUp 0.4s ease both; }

.delay-1 { animation-delay: 0.1s; }
.delay-2 { animation-delay: 0.2s; }
.delay-3 { animation-delay: 0.3s; }
.delay-4 { animation-delay: 0.4s; }

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--text-muted);
}

.empty-state-icon { font-size: 3rem; margin-bottom: 1rem; }
.empty-state h3   { font-size: 1.1rem; color: var(--text-secondary); margin-bottom: 0.5rem; }
.empty-state p    { font-size: 0.875rem; margin-bottom: 1.5rem; }

/* ============================================================
   TOOLTIP
   ============================================================ */
[data-tooltip] { position: relative; cursor: help; }
[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute; bottom: calc(100% + 6px); left: 50%;
    transform: translateX(-50%);
    background: #1e293b; color: var(--text-primary);
    font-size: 0.75rem; padding: 0.4rem 0.7rem;
    border-radius: 0.4rem; white-space: nowrap;
    border: 1px solid var(--border);
    opacity: 0; pointer-events: none;
    transition: opacity 0.2s;
    z-index: 999;
}
[data-tooltip]:hover::after { opacity: 1; }

/* ============================================================
   CHAR COUNTER
   ============================================================ */
.char-counter {
    font-size: 0.75rem; text-align: right;
    margin-top: 0.3rem;
    transition: color 0.2s;
}
.char-counter.ok      { color: var(--text-muted); }
.char-counter.warning { color: var(--accent-yellow); }
.char-counter.danger  { color: var(--accent-red); }
