/* ===================================================
   SocialPlanner — Stylesheet v2
   Direction : Sophistication & Trust + Utility
   Fondation froide, bordures 0.5px, densité maîtrisée
   =================================================== */

:root {
    /* Cool foundation */
    --bg: #f8fafb;
    --bg-card: #ffffff;
    --bg-elevated: #ffffff;

    /* Brand accent */
    --primary: #3B82F6;
    --primary-hover: #2563EB;
    --primary-light: #eff6ff;

    /* Contrast hierarchy — 4 niveaux */
    --text: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --text-faint: #cbd5e1;

    /* Borders — subtiles, 0.5px */
    --border: rgba(15, 23, 42, 0.08);
    --border-subtle: rgba(15, 23, 42, 0.05);

    /* Status — désaturés */
    --success: #10b981;
    --success-bg: #d1fae5;
    --success-text: #065f46;
    --warning: #f59e0b;
    --warning-bg: #fef3c7;
    --warning-text: #92400e;
    --danger: #ef4444;
    --danger-bg: #fee2e2;
    --danger-text: #991b1b;

    /* Plateformes */
    --linkedin: #0A66C2;
    --linkedin-bg: #dbeafe;
    --instagram: #E1306C;
    --instagram-bg: #fce7f3;

    /* Typography */
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: 'SF Mono', Monaco, 'Cascadia Code', monospace;

    /* Radius — sharp system */
    --radius: 6px;
    --radius-lg: 8px;

    /* Transitions */
    --ease: 150ms cubic-bezier(0.25, 1, 0.5, 1);
}

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

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img, video { max-width: 100%; border-radius: var(--radius); }

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

/* ---- SIDEBAR ---- */
.sidebar {
    width: 240px;
    background: var(--bg-card);
    border-right: 0.5px solid var(--border);
    position: fixed;
    top: 0; left: 0; bottom: 0;
    display: flex;
    flex-direction: column;
    z-index: 100;
    overflow-y: auto;
}

.sidebar-logo {
    padding: 16px;
    border-bottom: 0.5px solid var(--border-subtle);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-logo-icon {
    width: 32px;
    height: 32px;
    background: var(--primary);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 600;
    font-size: 13px;
    letter-spacing: -0.02em;
}

.sidebar-logo-text {
    font-weight: 600;
    font-size: 15px;
    letter-spacing: -0.01em;
    color: var(--text);
}

.sidebar-logo-text span {
    color: var(--primary);
}

.sidebar-nav {
    flex: 1;
    padding: 8px;
    overflow-y: auto;
}

.sidebar-section {
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: 16px 12px 6px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    transition: all var(--ease);
    text-decoration: none;
}

.sidebar-nav a:hover {
    background: var(--bg);
    color: var(--text);
}

.sidebar-nav a.active {
    background: var(--primary-light);
    color: var(--primary);
}

.sidebar-nav .nav-icon {
    width: 16px;
    text-align: center;
    font-size: 14px;
    opacity: 0.6;
}

.sidebar-nav a.active .nav-icon {
    opacity: 1;
}

.sidebar-footer {
    padding: 12px;
    border-top: 0.5px solid var(--border-subtle);
}

.sidebar-footer a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    transition: all var(--ease);
}

.sidebar-footer a:hover {
    background: var(--bg);
    color: var(--text);
}

/* ---- MAIN CONTENT ---- */
.main {
    flex: 1;
    margin-left: 240px;
    padding: 32px;
    max-width: 1200px;
}

/* ---- PAGE HEADER ---- */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.page-header h1 {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--text);
}

/* ---- BUTTONS ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    border: 0.5px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--ease);
    font-family: inherit;
    text-decoration: none;
    white-space: nowrap;
}

.btn:hover {
    background: var(--bg);
    color: var(--text);
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-success {
    background: var(--success);
    color: #fff;
    border-color: var(--success);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
}

.btn-sm {
    padding: 4px 8px;
    font-size: 12px;
}

.btn-linkedin {
    background: var(--linkedin);
    color: #fff;
    border-color: var(--linkedin);
}

.btn-instagram {
    background: var(--instagram);
    color: #fff;
    border-color: var(--instagram);
}

/* ---- CARDS ---- */
.card {
    background: var(--bg-elevated);
    border: 0.5px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 0.5px solid var(--border-subtle);
}

.card-header h2 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.01em;
}

/* ---- STATS ---- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-elevated);
    border: 0.5px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
}

.stat-card .stat-value {
    font-size: 24px;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--text);
    font-family: var(--font-mono);
    font-feature-settings: 'tnum';
    line-height: 1;
    margin-bottom: 4px;
}

.stat-card .stat-label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}

/* ---- FORMS ---- */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 8px 12px;
    border: 0.5px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    font-family: inherit;
    color: var(--text);
    background: var(--bg-card);
    transition: border-color var(--ease);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.08);
}

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

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

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

/* ---- POST FORM GRID ---- */
.post-form-grid {
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: 24px;
    align-items: start;
}

/* ---- PREVIEW ---- */
.preview-card {
    position: sticky;
    top: 32px;
}

.preview-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 12px;
}

.preview-tab {
    padding: 6px 12px;
    border-radius: var(--radius);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    border: 0.5px solid var(--border);
    background: var(--bg-card);
    color: var(--text-secondary);
    transition: all var(--ease);
}

.preview-tab.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.preview-frame {
    background: var(--bg);
    border: 0.5px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    min-height: 200px;
    font-size: 13px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
    color: var(--text);
}

/* ---- MEDIA ---- */
.media-dropzone {
    border: 1px dashed var(--text-faint);
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    cursor: pointer;
    transition: all var(--ease);
}

.media-dropzone:hover,
.media-dropzone.dragover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 8px;
    margin-top: 12px;
}

.media-thumb {
    position: relative;
    border-radius: var(--radius);
    overflow: hidden;
    aspect-ratio: 1;
    border: 0.5px solid var(--border);
}

.media-thumb img,
.media-thumb video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.media-thumb .media-delete {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 11px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity var(--ease);
}

.media-thumb:hover .media-delete {
    opacity: 1;
}

/* ---- CALENDAR ---- */
.calendar-nav {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
}

.calendar-nav h2 {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.01em;
    min-width: 180px;
    text-align: center;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    border: 0.5px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--bg-card);
}

.calendar-header {
    background: var(--bg);
    padding: 8px;
    text-align: center;
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.calendar-day {
    min-height: 96px;
    padding: 8px;
    border-top: 0.5px solid var(--border);
    border-right: 0.5px solid var(--border-subtle);
    position: relative;
}

.calendar-day:nth-child(7n) { border-right: none; }
.calendar-day.other-month { background: var(--bg); }
.calendar-day.today { background: var(--primary-light); }

.calendar-day .day-number {
    font-size: 12px;
    font-weight: 500;
    font-family: var(--font-mono);
    color: var(--text-muted);
    margin-bottom: 4px;
}

.calendar-day.today .day-number {
    background: var(--primary);
    color: #fff;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
}

.calendar-event {
    display: block;
    padding: 2px 6px;
    margin-bottom: 2px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    color: #fff;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.calendar-event:hover { opacity: 0.85; text-decoration: none; }

.week-indicator {
    background: var(--bg-elevated);
    border: 0.5px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
}

.week-bar {
    flex: 1;
    height: 6px;
    background: var(--bg);
    border-radius: 3px;
    overflow: hidden;
}

.week-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s ease;
}

/* ---- TABLE ---- */
.table-wrapper { overflow-x: auto; }

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

th {
    text-align: left;
    padding: 12px 16px;
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 0.5px solid var(--border);
}

td {
    padding: 12px 16px;
    border-bottom: 0.5px solid var(--border-subtle);
    font-size: 13px;
    vertical-align: middle;
}

tr:hover { background: var(--bg); }

/* ---- BADGES ---- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.badge-draft {
    background: var(--bg);
    color: var(--text-muted);
    border: 0.5px solid var(--border);
}

.badge-scheduled {
    background: var(--primary-light);
    color: var(--primary);
}

.badge-published {
    background: var(--success-bg);
    color: var(--success-text);
}

.badge-linkedin {
    background: var(--linkedin-bg);
    color: var(--linkedin);
}

.badge-instagram {
    background: var(--instagram-bg);
    color: var(--instagram);
}

.badge-both {
    background: #f3e8ff;
    color: #7c3aed;
}

/* ---- NOTIFICATIONS ---- */
.notif-badge {
    background: var(--danger);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 4px;
    margin-left: 8px;
    font-family: var(--font-mono);
}

.notif-list { list-style: none; }

.notif-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 0.5px solid var(--border-subtle);
    font-size: 13px;
}

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

.notif-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--primary);
    flex-shrink: 0;
}

/* ---- PUBLISH PAGE ---- */
.publish-content {
    background: var(--bg);
    border: 0.5px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-size: 13px;
    line-height: 1.7;
    margin-bottom: 16px;
    color: var(--text);
}

.copy-feedback {
    display: none;
    color: var(--success);
    font-weight: 500;
    font-size: 12px;
    margin-left: 8px;
}

/* ---- FILTERS ---- */
.filters-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 24px;
    padding: 12px 16px;
    background: var(--bg-elevated);
    border: 0.5px solid var(--border);
    border-radius: var(--radius-lg);
}

.filters-bar .form-control {
    width: auto;
    min-width: 140px;
}

/* ---- PAGINATION ---- */
.pagination {
    display: flex;
    gap: 4px;
    margin-top: 16px;
    justify-content: center;
}

.pagination a,
.pagination span {
    padding: 6px 12px;
    border: 0.5px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    font-family: var(--font-mono);
    color: var(--text-secondary);
    text-decoration: none;
}

.pagination a:hover { background: var(--bg); }

.pagination .active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* ---- FLASH MESSAGES ---- */
.flash {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 13px;
    font-weight: 500;
}

.flash-success {
    background: var(--success-bg);
    color: var(--success-text);
    border: 0.5px solid rgba(16, 185, 129, 0.2);
}

.flash-error {
    background: var(--danger-bg);
    color: var(--danger-text);
    border: 0.5px solid rgba(239, 68, 68, 0.2);
}

/* ---- COLOR PICKER ---- */
input[type="color"] {
    width: 36px;
    height: 32px;
    border: 0.5px solid var(--border);
    border-radius: var(--radius);
    padding: 2px;
    cursor: pointer;
}

/* ---- LOGIN PAGE ---- */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
}

.login-card {
    background: var(--bg-elevated);
    border: 0.5px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 32px;
    width: 100%;
    max-width: 360px;
}

.login-card h1 {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.02em;
    margin-bottom: 24px;
    text-align: center;
    color: var(--text);
}

/* ---- RESPONSIVE ---- */
@media (max-width: 1024px) {
    .post-form-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        position: relative;
        border-right: none;
        border-bottom: 0.5px solid var(--border);
    }
    .sidebar-nav {
        display: flex;
        overflow-x: auto;
        padding: 8px;
    }
    .sidebar-nav a {
        white-space: nowrap;
        padding: 8px 16px;
    }
    .sidebar-section { display: none; }
    .sidebar-footer { display: none; }
    .app { flex-direction: column; }
    .main { margin-left: 0; padding: 16px; }
    .content-area { padding: 16px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
