/* ============================================================================
   Digital Signage Admin Panel - Main Stylesheet (Arabic RTL)
   ============================================================================ */

:root {
    --brand-start: #667eea;
    --brand-end: #764ba2;
    --sidebar-bg: #1e1e2d;
    --sidebar-text: #c9c9d8;
    --sidebar-active: rgba(255, 255, 255, 0.08);
    --body-bg: #f5f6fa;
    --card-bg: #ffffff;
    --text-main: #2b2b3a;
    --text-muted: #7a7a8c;
    --border: #e6e6ef;
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Tajawal', 'Segoe UI', sans-serif;
    background: var(--body-bg);
    color: var(--text-main);
    margin: 0;
    direction: rtl;
}

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

.main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.content {
    flex: 1;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar .brand {
    padding: 22px 20px;
    font-weight: 700;
    font-size: 18px;
    color: #fff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar .brand i {
    background: linear-gradient(135deg, var(--brand-start), var(--brand-end));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    font-size: 24px;
}

.sidebar nav {
    padding: 14px 0;
    flex: 1;
}

.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 22px;
    color: var(--sidebar-text);
    text-decoration: none;
    transition: 0.15s;
    border-right: 3px solid transparent;
}

.sidebar nav a:hover {
    background: var(--sidebar-active);
    color: #fff;
}

.sidebar nav a.active {
    background: var(--sidebar-active);
    color: #fff;
    border-right-color: var(--brand-start);
}

.sidebar nav a i {
    width: 20px;
    text-align: center;
}

/* Topbar */
.topbar {
    height: 64px;
    background: linear-gradient(135deg, var(--brand-start), var(--brand-end));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 10;
}

.topbar .page-title {
    font-weight: 700;
    font-size: 18px;
}

.topbar .user-box {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar .avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Cards */
.card {
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
    background: var(--card-bg);
}

.stat-card {
    border-radius: 14px;
    color: #fff;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-card .icon {
    width: 54px;
    height: 54px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.stat-card .value {
    font-size: 26px;
    font-weight: 700;
}

.stat-card .label {
    font-size: 14px;
    opacity: 0.9;
}

.bg-grad-1 { background: linear-gradient(135deg, #667eea, #764ba2); }
.bg-grad-2 { background: linear-gradient(135deg, #43e97b, #38f9d7); color: #12402b; }
.bg-grad-3 { background: linear-gradient(135deg, #fa709a, #fee140); color: #5c3a00; }
.bg-grad-4 { background: linear-gradient(135deg, #30cfd0, #330867); }

/* Tables */
.table thead th {
    background: #f8f9fb;
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.table td {
    vertical-align: middle;
}

.badge-active { background: #dcfce7; color: #15803d; }
.badge-inactive { background: #fee2e2; color: #b91c1c; }
.badge-maintenance { background: #fef3c7; color: #b45309; }
.badge-brand { background: linear-gradient(135deg, var(--brand-start), var(--brand-end)); color: #fff; }

/* SweetAlert2 RTL + font polish */
.swal2-popup { font-family: 'Tajawal', sans-serif; direction: rtl; text-align: right; }

/* Buttons */
.btn-brand {
    background: linear-gradient(135deg, var(--brand-start), var(--brand-end));
    color: #fff;
    border: none;
}

.btn-brand:hover {
    color: #fff;
    filter: brightness(0.95);
}

/* Forms */
.form-label { font-weight: 500; }

/* Image gallery */
.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
}

.image-grid .tile {
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
}

.image-grid .tile img {
    width: 100%;
    height: 140px;
    object-fit: cover;
    display: block;
}

.image-grid .tile .meta {
    padding: 10px;
}

/* Login */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea, #764ba2);
    padding: 20px;
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: #fff;
    border-radius: 18px;
    padding: 32px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}

/* Toast */
#toastContainer {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast-item {
    min-width: 260px;
    padding: 12px 16px;
    border-radius: 10px;
    color: #fff;
    font-weight: 500;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
    animation: slideIn 0.25s ease;
}

.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-info { background: var(--brand-start); }

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

/* Misc */
.text-muted-2 { color: var(--text-muted); }
.cursor-pointer { cursor: pointer; }
.section-title { font-weight: 700; margin-bottom: 16px; }

@media (max-width: 768px) {
    .sidebar { width: 72px; }
    .sidebar .brand span, .sidebar nav a span { display: none; }
    .sidebar nav a { justify-content: center; }
}

/* Searchable image dropdown */
.image-search-list {
    position: absolute;
    top: 100%;
    right: 0;
    left: 0;
    max-height: 320px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #e6e6ef;
    border-radius: 8px;
    z-index: 1050;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
    margin-top: 4px;
}

.image-search-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f5;
}

.image-search-item:last-child { border-bottom: none; }
.image-search-item:hover { background: #f5f6fa; }

.image-search-item img {
    width: 44px;
    height: 44px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
    background: #eee;
}

.image-search-item .img-name {
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
