/* 
    REDCRYSTAL Design System v2.5
    A premium, high-fidelity UI for social media automation.
    Inspired by Linear, Meta Business Suite, and modern SaaS.
*/

:root {
    /* Color Palette - Premium Dark Mode (Default) */
    --bg-main: #0d1117;
    --bg-sidebar: #161b22;
    --bg-card: #161b22;
    --bg-hover: #21262d;
    
    --primary: #3B82F6;
    --primary-hover: #2563EB;
    --primary-glow: rgba(59, 130, 246, 0.15);
    
    --text-primary: #f0f6fc;
    --text-secondary: #c9d1d9;
    --text-muted: #8b949e;
    
    --border: #30363d;
    --border-bright: #484f58;
    
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #0ea5e9;
    
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.4);
    --shadow-lg: 0 12px 24px -6px rgba(0,0,0,0.5);
    
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

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

/* Layout */
.app-container {
    display: grid;
    grid-template-columns: 260px 1fr;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 24px 0;
    z-index: 100;
}

.logo-section {
    padding: 0 24px 32px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 20px rgba(0, 102, 255, 0.2);
}

.logo-section h1 {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--text-primary);
}

.nav-group {
    flex: 1;
    padding: 0 12px;
}

.nav-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 0 12px 8px;
    letter-spacing: 0.05em;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    margin-bottom: 2px;
}

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

.nav-item.active {
    background-color: var(--bg-card);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    color: var(--primary);
    font-weight: 600;
}

.sidebar-footer {
    padding: 24px;
    border-top: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-muted);
}

/* Main Content Area */
.main-wrapper {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Top Navigation Bar */
.top-nav {
    height: 64px;
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
}

.client-switcher {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    border: 1px solid transparent;
}

.client-switcher:hover {
    background-color: var(--bg-hover);
    border-color: var(--border-bright);
}

.client-avatar {
    width: 28px;
    height: 28px;
    background-color: var(--primary);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: white;
    overflow: hidden;
    flex-shrink: 0;
}

.client-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.client-logo-md {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background-color: var(--bg-hover);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    overflow: hidden;
    flex-shrink: 0;
}

.client-logo-md img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.client-name {
    font-size: 14px;
    font-weight: 600;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.btn-icon {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 18px;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    color: var(--text-primary);
}

/* Content Area */
.content-body {
    flex: 1;
    overflow-y: auto;
    padding: 32px;
}

/* Calendar Grid */
.calendar-container {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

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

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    border-bottom: 1px solid var(--border);
}

.day-name {
    padding: 12px;
    text-align: center;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    border-right: 1px solid var(--border);
    background-color: var(--bg-sidebar);
}

.calendar-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
}

.day-cell {
    min-height: 140px;
    padding: 8px;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    transition: var(--transition);
    position: relative;
    background-color: var(--bg-card);
}

.day-cell:hover {
    background-color: var(--bg-main);
}

.day-number {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.day-cell.today {
    background-color: rgba(0, 102, 255, 0.02);
}

.day-cell.today .day-number {
    color: var(--primary);
    font-weight: 800;
}

/* Post Preview in Calendar */
.post-preview {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 4px;
    margin-bottom: 4px;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    box-shadow: var(--shadow-sm);
}

.post-preview:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.post-thumb {
    width: 100%;
    height: 60px;
    object-fit: cover;
    border-radius: 4px;
    background-color: #f0f0f0;
}

.client-label-badge {
    display: inline-block;
    padding: 2px 6px;
    background: var(--bg-hover);
    border-radius: 4px;
    font-size: 9px;
    letter-spacing: 0.05em;
    border: 1px solid var(--border);
}

.post-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 4px;
    font-size: 10px;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.status-dot.pending { background-color: var(--warning); }
.status-dot.approved { background-color: var(--warning); }
.status-dot.posted { background-color: var(--success); }
.status-dot.failed { background-color: var(--danger); }

/* Components */
.btn-primary {
    background-color: var(--primary);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    box-shadow: 0 4px 12px rgba(0, 102, 255, 0.2);
}

.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 24px;
    box-shadow: var(--shadow-sm);
}

.badge {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
}

/* Modal / Drawer */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: 450px;
    height: 100%;
    background-color: var(--bg-card);
    border-left: 1px solid var(--border);
    z-index: 1100;
    box-shadow: var(--shadow-lg);
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

.drawer.open {
    transform: translateX(0);
}

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

.drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.drawer-footer {
    padding: 24px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 12px;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.form-input {
    width: 100%;
    background-color: var(--bg-main);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    color: var(--text-primary);
    font-family: inherit;
    transition: var(--transition);
}

input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(1);
    cursor: pointer;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-glow);
}

textarea.form-input {
    min-height: 120px;
    resize: vertical;
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 24px;
}

.stat-card {
    background: var(--bg-card);
    padding: 20px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.stat-card h3 {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.stat-value {
    font-size: 28px;
    font-weight: 800;
}

/* Drop Zone */
.drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 48px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
}

.drop-zone:hover {
    border-color: var(--primary);
    background-color: rgba(0, 102, 255, 0.02);
}

/* Mode Selectors */
body.view-mode-client [data-view-all-only] { display: none !important; }
body.view-mode-all [data-view-client-only] { display: none !important; }

/* Utilities */
.hidden { display: none !important; }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }

.pulse { animation: pulse 2s infinite; }
@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

.avatar {
    width: 32px;
    height: 32px;
    background-color: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: white;
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 8px;
}

.status-indicator.online {
    background-color: var(--success);
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.3);
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

.content-body > div {
    animation: fadeIn 0.3s ease-out forwards;
}

/* Authentication Pages (Login/Signup) Premium UI */
.auth-page {
    background: radial-gradient(circle at 15% 50%, rgba(59, 130, 246, 0.15), transparent 25%),
                radial-gradient(circle at 85% 30%, rgba(139, 92, 246, 0.15), transparent 25%);
    background-color: var(--bg-main);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    font-family: 'Inter', sans-serif;
    color: var(--text-primary);
    overflow: hidden;
    position: relative;
}

.auth-page::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: url('data:image/svg+xml;utf8,<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg"><filter id="noiseFilter"><feTurbulence type="fractalNoise" baseFrequency="0.65" numOctaves="3" stitchTiles="stitch"/></filter><rect width="100%" height="100%" filter="url(%23noiseFilter)" opacity="0.05"/></svg>');
    pointer-events: none;
    z-index: 1;
}

.auth-container {
    width: 100%;
    max-width: 420px;
    padding: 20px;
    z-index: 10;
    position: relative;
    animation: fadeIn 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.auth-card {
    background: rgba(22, 27, 34, 0.6);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 24px;
    padding: 48px 40px;
    box-shadow: 0 30px 60px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.1);
}

.auth-card .logo-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    margin-bottom: 32px;
    padding: 0;
}

.auth-card .meta-logo {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 30px rgba(59, 130, 246, 0.3);
    position: relative;
}

.auth-card .meta-logo::after {
    content: '';
    position: absolute;
    inset: 1px;
    border-radius: 15px;
    background: linear-gradient(to bottom right, rgba(255,255,255,0.2), transparent);
    pointer-events: none;
}

.auth-card .meta-logo svg {
    width: 28px;
    height: 28px;
    fill: white;
}

.auth-card h1 {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: white;
    margin: 0;
}

.auth-card h2 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 8px;
    text-align: center;
    color: var(--text-primary);
}

.auth-subtitle {
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 32px;
}

.auth-card .form-group {
    margin-bottom: 24px;
}

.auth-card .form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.auth-card .form-input,
.auth-card input[type="text"],
.auth-card input[type="password"] {
    width: 100%;
    background-color: rgba(13, 17, 23, 0.7);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px 16px;
    color: var(--text-primary);
    font-size: 15px;
    transition: all 0.3s ease;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
}

.auth-card .form-input:focus,
.auth-card input[type="text"]:focus,
.auth-card input[type="password"]:focus {
    outline: none;
    border-color: var(--primary);
    background-color: rgba(13, 17, 23, 0.9);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15), inset 0 2px 4px rgba(0,0,0,0.2);
}

.auth-card input::placeholder {
    color: #4b5563;
}

.auth-btn {
    width: 100%;
    background: linear-gradient(135deg, var(--primary), #2563EB);
    color: white;
    border: none;
    padding: 14px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3), inset 0 1px 0 rgba(255,255,255,0.2);
    margin-top: 8px;
}

.auth-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(37, 99, 235, 0.4), inset 0 1px 0 rgba(255,255,255,0.2);
    background: linear-gradient(135deg, #4f8df7, #3b76f0);
}

.auth-btn:active {
    transform: translateY(0);
}

.auth-footer {
    margin-top: 32px;
    text-align: center;
    font-size: 14px;
    color: var(--text-muted);
}

.auth-footer a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.auth-footer a:hover {
    color: #60a5fa;
    text-decoration: underline;
}

.auth-message {
    margin-top: 20px;
    padding: 12px;
    border-radius: 8px;
    font-size: 13px;
    text-align: center;
    background: rgba(239, 68, 68, 0.1);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.auth-message.hidden {
    display: none;
}
/* Custom Visual Calendar Styles */
.calendar-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    box-shadow: var(--shadow-lg);
}

.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

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

.day-name {
    background: var(--bg-sidebar);
    color: var(--text-muted);
    padding: 12px;
    text-align: center;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.05em;
}

.calendar-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background: var(--border);
}

.calendar-day {
    background: var(--bg-card);
    min-height: 120px;
    padding: 8px;
    transition: all 0.2s ease;
}

.calendar-day.empty {
    background: rgba(13, 17, 23, 0.4);
}

.calendar-day.drag-over {
    background: rgba(59, 130, 246, 0.1);
    box-shadow: inset 0 0 0 2px var(--primary);
}

.day-num {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.post-preview {
    font-size: 11px;
    padding: 6px 8px;
    border-radius: 6px;
    margin-bottom: 4px;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: transform 0.1s;
    color: white;
}

.post-preview:hover {
    transform: scale(1.02);
}

.post-preview.pending { background: #3b82f6; }
.post-preview.approved { background: #8b5cf6; }
.post-preview.posted { background: #10b981; }
.post-preview.failed { background: #ef4444; }

