:root {
    --bg-color: #0f172a;
    --surface: #1e293b;
    --surface-light: #334155;
    --text: #f8fafc;
    --text-muted: #94a3b8;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --success: #10b981;
    --danger: #ef4444;
    --border: #334155;
    --sidebar-width: 260px;
}

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

body {
    background-color: var(--bg-color);
    color: var(--text);
    height: 100vh;
    overflow: hidden;
}

.hidden { display: none !important; }

/* Login Screen */
.admin-login-screen {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--bg-color) 0%, #172554 100%);
}

.admin-login-box {
    background: var(--surface);
    padding: 2.5rem;
    border-radius: 16px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    border: 1px solid var(--border);
}

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

.admin-logo {
    width: 64px;
    height: 64px;
    background: var(--primary);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 800;
    margin: 0 auto 1rem;
    transform: rotate(-10deg);
}

.admin-login-header h1 { font-size: 1.5rem; }
.admin-login-header p { color: var(--text-muted); }

.form-group {
    margin-bottom: 1.25rem;
}

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

input {
    width: 100%;
    padding: 0.8rem;
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: white;
    font-size: 1rem;
}

input:focus {
    outline: none;
    border-color: var(--primary);
}

.btn {
    padding: 0.8rem 1rem;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-full { width: 100%; }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-light); color: white; }
.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.85rem; }
.btn-accent { background: #8b5cf6; color: white; }
.btn-danger { background: var(--danger); color: white; }

.error-msg {
    margin-top: 1rem;
    padding: 0.75rem;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--danger);
    color: #fca5a5;
    border-radius: 8px;
    text-align: center;
    font-size: 0.9rem;
}

.code-info {
    text-align: center;
    margin-bottom: 1.5rem;
}
.code-icon { font-size: 2.5rem; display: block; margin-bottom: 0.5rem; }
.code-input {
    font-size: 2rem;
    text-align: center;
    letter-spacing: 0.5rem;
    font-weight: 700;
}

/* Admin Panel Layout */
.admin-panel {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

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

.sidebar-logo {
    width: 40px;
    height: 40px;
    background: var(--primary);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

.sidebar-badge {
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
}

.sidebar-nav {
    flex: 1;
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.sidebar-btn {
    display: flex;
    align-items: center;
    gap: 1rem;
    width: 100%;
    padding: 0.8rem 1rem;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1rem;
    text-align: left;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.sidebar-btn:hover {
    background: var(--surface-light);
    color: white;
}

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

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

.logout { color: #fca5a5; }
.logout:hover { background: rgba(239, 68, 68, 0.1); color: var(--danger); }

/* Main Area */
.admin-main {
    flex: 1;
    overflow-y: auto;
    background: var(--bg-color);
}

.admin-section {
    display: none;
    padding: 2rem;
}

.admin-section.active {
    display: block;
}

.section-title {
    margin-bottom: 2rem;
    font-weight: 600;
}

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

.stat-card {
    background: var(--surface);
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid var(--border);
}

.stat-card-title {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.stat-card-value {
    font-size: 2rem;
    font-weight: 700;
}

/* Editor Layout */
.editor-layout {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 2rem;
    height: calc(100vh - 120px);
}

/* Phone Preview */
.editor-preview {
    display: flex;
    flex-direction: column;
}

.preview-header {
    margin-bottom: 1rem;
}

.preview-label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.phone-preview {
    flex: 1;
    display: flex;
    justify-content: center;
    background: var(--surface);
    border-radius: 24px;
    padding: 1.5rem;
    border: 1px solid var(--border);
}

.phone-frame {
    width: 300px;
    height: 600px;
    background: black;
    border-radius: 36px;
    padding: 12px;
    border: 4px solid #334155;
    position: relative;
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.5);
}

.phone-screen {
    width: 100%;
    height: 100%;
    background: #0f172a;
    border-radius: 24px;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
}

.preview-empty {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    text-align: center;
    padding: 2rem;
}

.preview-empty span {
    font-size: 3rem;
    margin-bottom: 1rem;
}

/* Post Content Preview styling (inside phone screen) */
.prev-img { width: 100%; max-height: 250px; object-fit: contain; background: var(--surface-light); }
.prev-content { padding: 1rem; line-height: 1.6; }
.prev-content h2 { color: #6366f1; margin: 1rem 0; font-size: 1.2rem; }
.prev-content ul { padding-left: 1.5rem; }

/* Editor Panel */
.editor-panel {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    overflow-y: auto;
    padding-right: 1rem;
}

.editor-top {
    background: var(--surface);
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid var(--border);
}

.form-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}
.flex-1 { flex: 1; }
.flex-2 { flex: 2; }

select {
    width: 100%;
    padding: 0.8rem;
    background: #0f172a;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: white;
}
select option {
    background: #1e293b;
    color: white;
}

/* Pages Editor */
.pages-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 1.5rem 0 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.pages-nav {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#page-indicator {
    padding: 0 0.5rem;
    font-weight: 600;
}

.image-upload-zone {
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 2rem;
    text-align: center;
    margin-bottom: 1.5rem;
    transition: all 0.2s;
    background: rgba(0,0,0,0.2);
}

.image-upload-zone.dragover {
    border-color: var(--primary);
    background: rgba(59, 130, 246, 0.1);
}

.drop-icon {
    font-size: 2.5rem;
    display: block;
    margin-bottom: 1rem;
}

.image-preview-container {
    position: relative;
    max-width: 300px;
    margin: 0 auto;
}

.image-preview-img {
    width: 100%;
    border-radius: 8px;
}

.btn-remove-image {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--danger);
    color: white;
    border: none;
    cursor: pointer;
}

.text-editor {
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.editor-toolbar {
    background: var(--surface-light);
    padding: 0.5rem;
    display: flex;
    gap: 0.5rem;
}

.toolbar-btn {
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    color: white;
    border-radius: 4px;
    cursor: pointer;
}
.toolbar-btn:hover { background: rgba(255,255,255,0.1); }

textarea {
    width: 100%;
    padding: 1rem;
    background: rgba(0,0,0,0.2);
    border: none;
    color: white;
    resize: vertical;
    font-family: monospace;
    font-size: 0.95rem;
}

textarea:focus { outline: none; }

/* Test Editor */
.test-editor {
    background: var(--surface);
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid var(--border);
}

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

.test-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.test-item {
    background: rgba(0,0,0,0.2);
    padding: 1rem;
    border-radius: 8px;
    border-left: 4px solid var(--primary);
}

.test-form {
    background: rgba(0,0,0,0.3);
    padding: 1.5rem;
    border-radius: 8px;
    margin-top: 1rem;
}

.test-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.test-option label { font-weight: bold; width: 20px; }
.test-form-actions {
    margin-top: 1rem;
    display: flex;
    gap: 1rem;
}

/* Tables */
.admin-table-container {
    background: var(--surface);
    border-radius: 12px;
    border: 1px solid var(--border);
    overflow: hidden;
}

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

th, td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    background: var(--surface-light);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
}

tr:hover {
    background: rgba(255,255,255,0.02);
}

.action-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.1rem;
    margin-right: 0.5rem;
}
.action-btn:hover { color: white; }
.action-btn.del:hover { color: var(--danger); }

/* Toasts */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.toast {
    background: var(--surface-light);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.3);
    border-left: 4px solid var(--primary);
}
.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--danger); }
