/* ═══════════════════════════════════════════════════════════════
   Zoftly AI Admin Panel — Design System
   Matching Android app: #131315 bg, Poppins font, white accents
   ═══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap');

/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg-primary:    #131315;
    --bg-secondary:  #1a1a1e;
    --bg-card:       #1e1e22;
    --bg-input:      #252528;
    --bg-hover:      #2a2a2f;
    --text-primary:  #ffffff;
    --text-secondary:#c0c0c0;
    --text-muted:    #808080;
    --accent:        #ffffff;
    --accent-text:   #000000;
    --border:        rgba(255,255,255,0.12);
    --border-light:  rgba(255,255,255,0.2);
    --success:       #4ade80;
    --warning:       #fbbf24;
    --danger:        #f87171;
    --info:          #60a5fa;
    --radius-sm:     8px;
    --radius-md:     12px;
    --radius-lg:     20px;
    --radius-pill:   50px;
    --shadow:        0 4px 24px rgba(0,0,0,0.4);
    --shadow-lg:     0 8px 40px rgba(0,0,0,0.6);
    --transition:    all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

html { font-size: 16px; }

body {
    font-family: 'Poppins', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; transition: var(--transition); }
a:hover { opacity: 0.8; }

/* ── Layout ───────────────────────────────────────────────── */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    padding: 32px 0;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
}

.sidebar-brand {
    padding: 0 24px 32px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 24px;
}

.sidebar-brand h1 {
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.sidebar-brand h1 span {
    font-weight: 400;
    color: var(--text-secondary);
    font-size: 12px;
    display: block;
    margin-top: 2px;
}

.sidebar-nav { flex: 1; padding: 0 16px; }

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
    margin-bottom: 4px;
}

.sidebar-nav a:hover { background: var(--bg-hover); color: var(--text-primary); }
.sidebar-nav a.active { background: var(--accent); color: var(--accent-text); }
.sidebar-nav a .nav-icon { font-size: 18px; width: 24px; text-align: center; }

.sidebar-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
}

.sidebar-footer a {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--danger);
    font-size: 14px;
    font-weight: 500;
}

.main-content {
    margin-left: 260px;
    flex: 1;
    padding: 32px 40px;
    min-height: 100vh;
}

/* ── Page Header ──────────────────────────────────────────── */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
}

.page-header h2 {
    font-size: 28px;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.page-header p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 4px;
}

/* ── Cards ────────────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    transition: var(--transition);
}

.card:hover { border-color: var(--border-light); }

/* ── Stat Cards ───────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    transition: var(--transition);
}

.stat-card:hover { border-color: var(--border-light); transform: translateY(-2px); box-shadow: var(--shadow); }

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    margin-bottom: 16px;
}

.stat-card .stat-icon.blue    { background: rgba(96,165,250,0.15); }
.stat-card .stat-icon.green   { background: rgba(74,222,128,0.15); }
.stat-card .stat-icon.purple  { background: rgba(192,132,252,0.15); }
.stat-card .stat-icon.orange  { background: rgba(251,191,36,0.15); }

.stat-card .stat-value {
    font-size: 32px;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 4px;
}

.stat-card .stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 24px;
    border-radius: var(--radius-pill);
    font-family: 'Poppins', sans-serif;
    font-size: 14px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    line-height: 1.4;
}

.btn-primary {
    background: var(--accent);
    color: var(--accent-text);
}
.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); box-shadow: var(--shadow); }

.btn-secondary {
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg-hover); border-color: var(--border-light); }

.btn-danger {
    background: rgba(248,113,113,0.15);
    color: var(--danger);
    border: 1px solid rgba(248,113,113,0.3);
}
.btn-danger:hover { background: rgba(248,113,113,0.25); }

.btn-sm { padding: 6px 16px; font-size: 12px; }

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: var(--radius-sm);
    font-size: 16px;
}

/* ── Forms ─────────────────────────────────────────────────── */
.form-group { margin-bottom: 20px; }

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.form-group label .required { color: var(--danger); }

.form-control {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: 'Poppins', sans-serif;
    font-size: 14px;
    transition: var(--transition);
    outline: none;
}

.form-control:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255,255,255,0.08); }
.form-control::placeholder { color: var(--text-muted); }

textarea.form-control { min-height: 120px; resize: vertical; }

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23c0c0c0' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 40px;
}

select.form-control option { background: var(--bg-secondary); color: var(--text-primary); }

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

/* ── File Upload ──────────────────────────────────────────── */
.file-upload {
    position: relative;
    border: 2px dashed var(--border);
    border-radius: var(--radius-md);
    padding: 32px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
}

.file-upload:hover { border-color: var(--border-light); background: var(--bg-hover); }

.file-upload input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.file-upload .upload-icon { font-size: 32px; margin-bottom: 8px; }
.file-upload .upload-text { font-size: 13px; color: var(--text-secondary); }
.file-upload .upload-hint { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

.thumbnail-preview {
    width: 80px;
    height: 80px;
    border-radius: var(--radius-md);
    object-fit: cover;
    border: 1px solid var(--border);
    margin-top: 12px;
}

/* ── Table ─────────────────────────────────────────────────── */
.table-wrapper {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    text-align: left;
    padding: 16px 20px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
}

tbody td {
    padding: 16px 20px;
    font-size: 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

tbody tr { transition: var(--transition); }
tbody tr:hover { background: var(--bg-hover); }
tbody tr:last-child td { border-bottom: none; }

/* ── Badges ───────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: var(--radius-pill);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge-image   { background: rgba(96,165,250,0.15); color: var(--info); }
.badge-video   { background: rgba(192,132,252,0.15); color: #c084fc; }
.badge-active  { background: rgba(74,222,128,0.15);  color: var(--success); }
.badge-inactive{ background: rgba(248,113,113,0.15); color: var(--danger); }

/* ── Template Thumbnail in Table ──────────────────────────── */
.template-thumb {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    border: 1px solid var(--border);
}

.template-thumb-placeholder {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: var(--text-muted);
}

/* ── Actions Cell ─────────────────────────────────────────── */
.actions { display: flex; gap: 8px; }

/* ── Flash Messages ───────────────────────────────────────── */
.flash {
    padding: 14px 20px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideDown 0.3s ease;
}

.flash-success { background: rgba(74,222,128,0.12); color: var(--success); border: 1px solid rgba(74,222,128,0.25); }
.flash-error   { background: rgba(248,113,113,0.12); color: var(--danger);  border: 1px solid rgba(248,113,113,0.25); }
.flash-info    { background: rgba(96,165,250,0.12);  color: var(--info);    border: 1px solid rgba(96,165,250,0.25); }

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Login Page ───────────────────────────────────────────── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    padding: 20px;
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px;
    box-shadow: var(--shadow-lg);
}

.login-card .login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-card .login-header h1 {
    font-size: 28px;
    font-weight: 600;
    margin-bottom: 4px;
}

.login-card .login-header p {
    color: var(--text-secondary);
    font-size: 14px;
}

.login-card .btn-primary {
    width: 100%;
    padding: 14px;
    font-size: 16px;
    margin-top: 8px;
}

/* ── Filter Tabs ──────────────────────────────────────────── */
.filter-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
}

.filter-tab {
    padding: 8px 20px;
    border-radius: var(--radius-pill);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--bg-input);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.filter-tab:hover { background: var(--bg-hover); color: var(--text-primary); }
.filter-tab.active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }

/* ── Empty State ──────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 60px 20px;
}

.empty-state .empty-icon { font-size: 48px; margin-bottom: 16px; }
.empty-state h3 { font-size: 18px; font-weight: 600; margin-bottom: 8px; }
.empty-state p { color: var(--text-secondary); font-size: 14px; margin-bottom: 24px; }

/* ── Template Info in Table ───────────────────────────────── */
.template-info {
    display: flex;
    align-items: center;
    gap: 14px;
}

.template-name {
    font-weight: 500;
}

.template-model {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 1024px) {
    .sidebar { width: 220px; }
    .main-content { margin-left: 220px; padding: 24px; }
}

@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        position: relative;
        padding: 16px 0;
    }
    .sidebar-nav { display: flex; gap: 4px; padding: 0 16px; overflow-x: auto; }
    .sidebar-nav a { white-space: nowrap; }
    .main-content { margin-left: 0; padding: 20px; }
    .page-header { flex-direction: column; align-items: flex-start; gap: 12px; }
    .form-row { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .app-layout { flex-direction: column; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .login-card { padding: 24px; }
    .actions { flex-wrap: wrap; }
}
