:root {
    --primary: #8B5CF6;
    --secondary: #10B981;
    --accent: #F59E0B;
    --bg-dark: #0F0F0F;
    --bg-card: #1A1A2E;
    --bg-sidebar: #12121F;
    --text-main: #FFFFFF;
    --text-muted: #A0A0B0;
    --success: #10B981;
    --warning: #F59E0B;
    --error: #EF4444;
    --info: #3B82F6;
    --font-heading: 'Orbitron', sans-serif;
    --font-body: 'Inter', sans-serif;
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-body);
    min-height: 100vh;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
}

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

/* Glassmorphism */
.glass-panel {
    background: rgba(26, 26, 46, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
}

/* Form Styles */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.form-control, .form-group input:not([type="radio"]):not([type="checkbox"]), .form-group textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    background-color: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: var(--text-main);
    font-family: var(--font-body);
    transition: all 0.3s ease;
}

.form-control:focus, .form-group input:focus, .form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}

/* Buttons */
button {
    cursor: pointer;
    font-family: var(--font-body);
    font-weight: 500;
    border: none;
    border-radius: 8px;
    padding: 0.75rem 1.5rem;
    transition: all 0.2s ease;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
}
.btn-primary:hover { background-color: #059669; }

.btn-secondary {
    background-color: transparent;
    color: var(--text-main);
    border: 1px solid rgba(255,255,255,0.2);
}
.btn-secondary:hover { background-color: rgba(255,255,255,0.05); }

.btn-danger { background-color: var(--error); color: white; }
.btn-warning { background-color: var(--warning); color: #000; }
.btn-success { background-color: var(--success); color: white; }

.btn-block {
    display: block;
    width: 100%;
}

/* --- LOGIN PAGE --- */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    background-image: radial-gradient(circle at center, #1a1a2e 0%, #0f0f0f 100%);
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 1rem;
}

.login-card {
    padding: 2.5rem;
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.logo-text {
    font-size: 2rem;
    letter-spacing: 2px;
}

.logo-text span {
    color: var(--primary);
    text-shadow: 0 0 10px rgba(16, 185, 129, 0.5);
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

.password-input-wrapper {
    position: relative;
}

.toggle-password {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    padding: 0;
    color: var(--text-muted);
}

.hidden {
    display: none !important;
}

.error-message {
    background-color: rgba(239, 68, 68, 0.1);
    color: var(--error);
    padding: 0.75rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    text-align: center;
    font-size: 0.9rem;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.shake {
    animation: shake 0.5s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes shake {
    10%, 90% { transform: translate3d(-1px, 0, 0); }
    20%, 80% { transform: translate3d(2px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
    40%, 60% { transform: translate3d(4px, 0, 0); }
}

.login-footer {
    margin-top: 2rem;
    text-align: center;
}

.back-link {
    color: var(--text-muted);
    font-size: 0.85rem;
    transition: color 0.2s;
}

.back-link:hover {
    color: var(--primary);
}

/* Spinner */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
    vertical-align: middle;
}

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

/* --- DASHBOARD PAGE --- */
.admin-body {
    display: flex;
    overflow-x: hidden;
}

/* Sidebar */
.sidebar {
    width: 260px;
    height: 100vh;
    background-color: var(--bg-sidebar);
    position: fixed;
    left: 0;
    top: 0;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    z-index: 100;
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.sidebar-header h2 {
    font-size: 1.5rem;
}

.mobile-close-btn {
    display: none;
    background: none;
    color: white;
    font-size: 1.2rem;
    padding: 0.5rem;
}

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

.nav-item {
    display: flex;
    align-items: center;
    padding: 0.8rem 1.5rem;
    color: var(--text-muted);
    transition: all 0.2s;
    position: relative;
}

.nav-item:hover, .nav-item.active {
    color: var(--text-main);
    background-color: rgba(255,255,255,0.03);
}

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

.nav-item .icon {
    margin-right: 12px;
    font-size: 1.2rem;
}

.nav-divider {
    height: 1px;
    background-color: rgba(255,255,255,0.05);
    margin: 1rem 0;
}

.text-danger { color: var(--error) !important; }

.badge {
    background-color: var(--primary);
    color: white;
    font-size: 0.75rem;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: auto;
    font-weight: bold;
}

/* Main Content area */
.main-content {
    flex: 1;
    margin-left: 260px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Top Header */
.top-header {
    height: 60px;
    background-color: rgba(18, 18, 31, 0.8);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255,255,255,0.05);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 90;
}

.mobile-menu-btn {
    display: none;
    background: none;
    color: white;
    font-size: 1.5rem;
    padding: 0.5rem;
}

.section-title {
    font-size: 1.2rem;
    margin: 0;
}

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

.avatar {
    width: 35px;
    height: 35px;
    background: rgba(16, 185, 129, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    border: 1px solid var(--primary);
}

/* Content Sections */
.content-wrapper {
    padding: 2rem;
    flex: 1;
}

.content-section {
    display: none;
}
.content-section.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

/* Dashboard Grid */
.welcome-banner {
    margin-bottom: 2rem;
}

.welcome-banner h2 {
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    padding: 1.5rem;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: var(--card-color, var(--primary));
}

.stat-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.stat-title {
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
}

.stat-icon {
    font-size: 1.5rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    font-family: var(--font-heading);
    margin-bottom: 0.5rem;
}

.stat-trend {
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 5px;
}
.trend-up { color: var(--success); }
.trend-down { color: var(--error); }

.chart-container {
    padding: 1.5rem;
    margin-bottom: 2rem;
    height: 400px;
}

.chart-container h3 {
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

/* Tables */
.links-table-container {
    overflow-x: auto;
    padding: 1rem;
}

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

.admin-table th, .admin-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.admin-table th {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.9rem;
}

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

.action-buttons {
    display: flex;
    gap: 0.5rem;
}
.action-buttons button {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 20px;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(255,255,255,0.2);
    transition: .4s;
    border-radius: 20px;
}
.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}
input:checked + .slider { background-color: var(--primary); }
input:checked + .slider:before { transform: translateX(20px); }

/* Messages */
.message-card {
    background: rgba(255,255,255,0.02);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    cursor: pointer;
    transition: background 0.2s;
}

.message-card.unread {
    border-left: 3px solid var(--primary);
    background: rgba(16, 185, 129, 0.05);
}

.message-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.message-sender { font-weight: 600; }
.message-date { color: var(--text-muted); font-size: 0.85rem; }
.message-preview { color: var(--text-muted); font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.message-full { display: none; margin-top: 1rem; color: var(--text-main); font-size: 0.95rem; line-height: 1.5; }
.message-card.expanded .message-preview { display: none; }
.message-card.expanded .message-full { display: block; }
.message-actions { display: none; margin-top: 1rem; gap: 1rem; }
.message-card.expanded .message-actions { display: flex; }

.message-filters {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.filter-btn {
    background: none;
    border: 1px solid rgba(255,255,255,0.2);
    color: var(--text-muted);
}
.filter-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

/* Config Grid */
.config-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 2rem;
}
.config-card { padding: 1.5rem; }
.config-card h3 { margin-bottom: 1.5rem; border-bottom: 1px solid rgba(255,255,255,0.1); padding-bottom: 0.5rem; }
.radio-group { display: flex; gap: 1rem; margin-top: 0.5rem; }
.radio-group label { display: flex; align-items: center; gap: 0.5rem; color: var(--text-main); }

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(5px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal-card {
    width: 100%;
    max-width: 500px;
    padding: 2rem;
}
.modal-card h3 { margin-bottom: 1.5rem; }
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 2rem;
}

/* Toasts */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.toast {
    padding: 1rem 1.5rem;
    border-radius: 8px;
    color: white;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    animation: slideInRight 0.3s ease forwards;
    background: var(--bg-card);
    border-left: 4px solid var(--primary);
}
.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--error); }
@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
@keyframes fadeOut {
    to { opacity: 0; }
}

/* Responsiveness */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .mobile-menu-btn, .mobile-close-btn { display: block; }
    .main-content { margin-left: 0; }
    .top-header { padding: 0 1rem; }
    .content-wrapper { padding: 1rem; }
    .stats-grid { grid-template-columns: 1fr; }
}

/* Stats Details Grid */
.stats-detailed-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}
.stat-detail-card {
    padding: 1.5rem;
}
.stat-detail-card h3 {
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.stat-row {
    display: flex;
    justify-content: space-between;
    padding: 1rem 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.stat-row:last-child { border-bottom: none; }
.stat-label { color: var(--text-muted); }
.stat-val { font-weight: 600; }
@media (max-width: 1024px) {
    .stats-detailed-grid { grid-template-columns: 1fr; }
}
