:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --bg-dark: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-main: #f8fafc;
    --text-dim: #94a3b8;
    --success: #22c55e;
    --error: #ef4444;
    --sidebar-width: 260px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', 'Outfit', sans-serif;
}

body {
    background: var(--bg-dark);
    color: var(--text-main);
    overflow-x: hidden;
    direction: rtl; /* Arabic support */
    min-height: 100vh;
}

/* App Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: rgba(15, 23, 42, 0.95);
    border-left: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    padding: 2rem 1.5rem;
    position: fixed;
    height: 100vh;
    transition: var(--transition);
    z-index: 1000;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 3rem;
}

.logo-img {
    width: 40px;
    height: 40px;
    object-fit: contain;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.nav-logo {
    display: none; /* Hide the old text-based logo */
}

.logo-text {
    font-size: 1.25rem;
    font-weight: 700;
    background: linear-gradient(to right, #fff, var(--primary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-menu {
    flex: 1;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.85rem 1rem;
    color: var(--text-dim);
    text-decoration: none;
    border-radius: 12px;
    margin-bottom: 0.5rem;
    transition: var(--transition);
}

.nav-link:hover, .nav-link.active {
    background: rgba(99, 102, 241, 0.1);
    color: var(--text-main);
}

.nav-link.active {
    border-right: 3px solid var(--primary);
}

.badge {
    background: var(--error);
    font-size: 0.75rem;
    padding: 2px 6px;
    border-radius: 20px;
    margin-right: auto;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding-top: 2rem;
    border-top: 1px solid var(--glass-border);
}

.avatar {
    width: 45px;
    height: 45px;
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.username {
    font-weight: 600;
    font-size: 0.95rem;
}

.status-online {
    font-size: 0.75rem;
    color: var(--success);
}

/* Main Content Area */
.main-content {
    flex: 1;
    margin-right: var(--sidebar-width);
    padding: 2.5rem;
    transition: var(--transition);
}

.mobile-header {
    display: none;
}

/* Premium Card Style - Upgraded Glassmorphism */
.premium-card {
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(25px) saturate(180%);
    -webkit-backdrop-filter: blur(25px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.4s ease;
}

.premium-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 48px 0 rgba(0, 0, 0, 0.5);
    border-color: var(--primary-glow);
}

.card-header {
    margin-bottom: 2rem;
}

.card-header h2 {
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
}

.card-header p {
    color: var(--text-dim);
}

/* Tabs & Animations */
.tab-content {
    display: none;
    animation: slideUp 0.6s cubic-bezier(0.23, 1, 0.32, 1) forwards;
    opacity: 0;
}

@keyframes slideUp {
    from { transform: translateY(30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.tab-content.active {
    display: block;
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 2rem;
}

/* Content Type Selector */
.content-type-selector {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}

.type-btn {
    padding: 1rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    color: var(--text-dim);
    cursor: pointer;
    transition: var(--transition);
}

.type-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 10px 20px rgba(99, 102, 241, 0.3);
}

/* Upload Area */
.upload-area {
    border: 2px dashed var(--glass-border);
    border-radius: 20px;
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    margin-bottom: 2rem;
    transition: var(--transition);
}

.upload-area:hover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
}

.upload-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.preview-container {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
}

.media-preview {
    max-width: 100%;
    max-height: 400px;
    border-radius: 12px;
}

/* Forms */
.input-group {
    margin-bottom: 1.5rem;
}

.input-group label {
    display: block;
    margin-bottom: 0.75rem;
    color: var(--text-dim);
    font-size: 0.9rem;
}

textarea, input[type="text"], input[type="url"], select {
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    padding: 1rem 1.25rem;
    border-radius: 14px;
    color: white;
    font-size: 1rem;
}

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

/* Account Chips */
.platform-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 1rem;
}

.account-chip {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    cursor: pointer;
    transition: var(--transition);
}

.account-chip.selected {
    background: var(--primary);
    border-color: var(--primary);
}

.account-chip input {
    display: none;
}

/* Buttons */
.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    border: 1px solid var(--glass-border);
    padding: 1rem 2rem;
    border-radius: 14px;
    cursor: pointer;
}

.full-width {
    width: 100%;
}

/* History List */
.history-item {
    padding: 1.25rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 16px;
    margin-bottom: 1rem;
    border: 1px solid transparent;
    transition: var(--transition);
    cursor: pointer;
}

.history-item:hover {
    border-color: var(--glass-border);
    background: rgba(255, 255, 255, 0.03);
}

.history-item-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    font-size: 0.8rem;
    color: var(--text-dim);
}

/* Inbox Styles */
.inbox-layout {
    display: grid;
    grid-template-columns: 350px 1fr;
    height: 600px;
    border: 1px solid var(--glass-border);
    border-radius: 18px;
    overflow: hidden;
}

.inbox-list {
    border-left: 1px solid var(--glass-border);
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.1);
}

.interaction-item {
    padding: 1.5rem;
    border-bottom: 1px solid var(--glass-border);
    cursor: pointer;
    transition: var(--transition);
}

.interaction-item:hover, .interaction-item.active {
    background: rgba(99, 102, 241, 0.05);
}

.interaction-item .sender {
    font-weight: 700;
    display: block;
    margin-bottom: 0.25rem;
}

.interaction-item .snippet {
    font-size: 0.9rem;
    color: var(--text-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-view {
    display: flex;
    flex-direction: column;
    background: rgba(0, 0, 0, 0.2);
}

.chat-placeholder {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-dim);
}

.chat-placeholder span {
    font-size: 4rem;
    margin-bottom: 1rem;
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal.visible {
    display: flex;
}

.modal-content {
    background: var(--bg-dark);
    border: 1px solid var(--glass-border);
    border-radius: 28px;
    padding: 2.5rem;
    width: 90%;
    max-width: 500px;
    position: relative;
    animation: modalIn 0.3s ease;
}

.large-modal {
    max-width: 1000px;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.close-modal {
    position: absolute;
    top: 1.5rem;
    left: 1.5rem;
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 1.5rem;
    cursor: pointer;
}

/* Mobile Responsiveness */
@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    .history-sidebar {
        order: 2;
    }
}

@media (max-width: 768px) {
    .sidebar {
        right: -100%; /* Off-screen toggle */
        width: 80%;
    }

    .sidebar.open {
        right: 0;
    }

    .main-content {
        margin-right: 0;
        padding: 1.5rem;
    }

    .mobile-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 2rem;
    }

    .menu-toggle {
        background: none;
        border: none;
        color: white;
        font-size: 1.5rem;
        cursor: pointer;
    }

    .content-type-selector {
        grid-template-columns: 1fr;
    }

    .inbox-layout {
        grid-template-columns: 1fr;
    }
    
    .chat-view {
        position: fixed;
        inset: 0;
        z-index: 1100;
        display: none; /* Only show when chat selected */
    }
}

/* Stats Grid & Overview */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.stat-card {
    padding: 2rem;
    border-radius: 28px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, var(--primary) 0%, transparent 70%);
    opacity: 0.03;
    pointer-events: none;
}

.stat-label { font-size: 0.85rem; color: var(--text-dim); font-weight: 600; letter-spacing: 0.5px; }
.stat-value { font-size: 2.25rem; font-weight: 800; color: var(--text-main); font-family: 'Outfit', sans-serif; }

.quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
}

.action-item {
    padding: 1.5rem;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--glass-border);
    cursor: pointer;
    text-align: center;
    transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.action-item:hover {
    background: rgba(255, 255, 255, 0.05);
    transform: translateY(-3px);
    border-color: var(--primary);
}

/* Media Library */
.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.media-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    overflow: hidden;
    cursor: pointer;
    transition: 0.3s;
    position: relative;
}

.media-item:hover {
    transform: scale(1.02);
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.06);
}

.media-item img, .media-item video {
    width: 100%;
    height: 150px;
    object-fit: cover;
    display: block;
}

.media-item .item-info {
    padding: 0.75rem;
    font-size: 0.8rem;
    color: var(--text-dim);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.media-item.selected {
    border: 2px solid var(--primary);
    box-shadow: 0 0 15px rgba(0, 163, 255, 0.4);
}

/* Toast Notifications */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: rgba(20, 20, 25, 0.95);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    padding: 1rem 2rem;
    border-radius: 50px;
    z-index: 9999;
    color: white;
    font-weight: 600;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    transition: 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}

.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--error); }
.toast.info { border-left: 4px solid var(--primary); }

/* Admin Dashboard */
.admin-table-wrapper {
    overflow-x: auto;
    margin-top: 1.5rem;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 12px;
    overflow: hidden;
}

.admin-table th, .admin-table td {
    padding: 1rem;
    text-align: right;
    border-bottom: 1px solid var(--glass-border);
}

.admin-table th {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-dim);
    font-weight: 600;
}

.admin-table tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

.admin-actions {
    display: flex;
    gap: 0.5rem;
}

.admin-btn {
    padding: 0.4rem 0.8rem;
    border-radius: 8px;
    font-size: 0.85rem;
    cursor: pointer;
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.05);
    color: white;
    transition: 0.2s;
}

.admin-btn.delete:hover {
    background: var(--error);
    border-color: var(--error);
}

.admin-btn.reset:hover {
    background: var(--primary);
    border-color: var(--primary);
}

.admin-only {
    display: none; /* Shown via JS if admin */
}

.action-item span { font-size: 1.5rem; display: block; margin-bottom: 0.5rem; }

/* Filter Tabs */
.filter-bar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    padding: 0.3rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    width: fit-content;
}

.filter-btn {
    padding: 0.4rem 1rem;
    border-radius: 10px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: 0.3s;
    background: transparent;
    color: var(--text-dim);
    border: none;
}

.filter-btn.active {
    background: var(--primary);
    color: white;
}

/* Utils */
.hidden { display: none !important; }
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    padding: 1rem 2rem;
    border-radius: 16px;
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 3000;
    pointer-events: none;
}
.toast.visible { opacity: 1; }
