/* ===== Admin Panel – Mobile First, Production Grade ===== */
:root {
    --sidebar-width: 240px;
    --primary: #1a73e8;
    --primary-dark: #1558b0;
    --bg: #f5f6fa;
    --card: #fff;
    --text: #333;
    --text-light: #666;
    --border: #e0e0e0;
    --danger: #dc3545;
    --success: #28a745;
    --warning: #ffc107;
}

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

body {
    font-family: 'Tajawal', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    direction: rtl;
    line-height: 1.6;
}

/* ---------- Login page ---------- */
.admin-login {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: #f0f2f5;
}
.login-wrapper {
    background: #fff;
    padding: 2.5rem;
    border-radius: 12px;
    box-shadow: 0 2px 15px rgba(0,0,0,0.08);
    width: 380px;
    max-width: 90%;
    text-align: center;
    margin: 1rem;
}
.login-header { margin-bottom: 2rem; }
.login-logo { height: 45px; margin-bottom: 1rem; }
.login-header h2 {
    font-size: 1.4rem;
    color: #333;
    font-family: 'Tajawal', sans-serif;
}
.login-form .form-group {
    margin-bottom: 1rem;
    text-align: right;
}
.login-form label {
    display: block;
    margin-bottom: 0.4rem;
    font-weight: 500;
    font-size: 0.95rem;
}
.login-form input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-family: inherit;
    font-size: 1rem;
    transition: border 0.2s;
}
.login-form input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26,115,232,0.15);
}
.login-error {
    background: #f8d7da;
    color: #721c24;
    padding: 0.7rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

/* ---------- Layout (mobile first) ---------- */
.admin-container {
    display: flex;
    min-height: 100vh;
    position: relative;
}

/* Sidebar */
.admin-sidebar {
    width: var(--sidebar-width);
    background: #1e293b;
    color: #e2e8f0;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 100;
    transform: translateX(110%); /* avoid edge bleed */
    transition: transform 0.3s ease;
    box-shadow: 0 0 20px rgba(0,0,0,0.1);
}
.admin-sidebar.open {
    transform: translateX(0);
}
.sidebar-brand {
    padding: 1.5rem;
    border-bottom: 1px solid #334155;
    text-align: center;
}
.sidebar-logo { height: 35px; }
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0;
}
.sidebar-nav ul { list-style: none; }
.sidebar-link {
    display: block;
    color: #cbd5e1;
    padding: 0.7rem 1.5rem;
    text-decoration: none;
    font-weight: 500;
    transition: background 0.2s, color 0.2s;
    min-height: 44px; /* touch target */
}
.sidebar-link:hover {
    background: #334155;
    color: #fff;
    text-decoration: none;
}
.sidebar-logout {
    border-top: 1px solid #334155;
    margin-top: auto;
    color: #f87171;
}

/* Main area */
.admin-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
}

.admin-topbar {
    background: #fff;
    border-bottom: 1px solid var(--border);
    padding: 0.8rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
}
.topbar-info {
    font-weight: 500;
    color: #555;
    font-size: 0.9rem;
}
.sidebar-toggle {
    display: inline-block;
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 0.5rem 0.8rem;
    border-radius: 4px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9rem;
    min-height: 44px;
    min-width: 44px;
}
.admin-content {
    padding: 1.5rem;
    flex: 1;
}

/* Backdrop */
.sidebar-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.4);
    z-index: 99;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s;
    touch-action: none;
}
.sidebar-backdrop.show {
    opacity: 1;
    visibility: visible;
}

/* ---------- Buttons (touch friendly) ---------- */
.btn {
    display: inline-block;
    padding: 0.6rem 1.3rem;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    font-size: 0.95rem;
    transition: background 0.2s;
    min-height: 44px;
    min-width: 44px;
}
.btn:hover { background: var(--primary-dark); text-decoration: none; }
.btn-full { width: 100%; }
.btn-secondary { background: #e2e8f0; color: #333; }
.btn-secondary:hover { background: #cbd5e1; }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #c82333; }

/* ---------- Forms ---------- */
.admin-form label {
    display: block;
    margin: 1rem 0 0.3rem;
    font-weight: 500;
}
.admin-form input[type="text"],
.admin-form input[type="number"],
.admin-form input[type="email"],
.admin-form input[type="password"],
.admin-form input[type="file"],
.admin-form textarea,
.admin-form select {
    width: 100%;
    padding: 0.7rem 1rem;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-family: inherit;
    font-size: 1rem;
    transition: border 0.2s;
    min-height: 44px;
}
.admin-form input:focus,
.admin-form textarea:focus,
.admin-form select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(26,115,232,0.15);
}
.admin-form button[type="submit"] {
    margin-top: 1.5rem;
}

/* ---------- Tables (responsive card mode on mobile) ---------- */
.table-wrapper {
    overflow-x: auto;
}
table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
    margin-top: 1rem;
}
th {
    background: #f8fafc;
    font-weight: 600;
    color: #555;
    padding: 0.8rem;
    text-align: right;
    font-size: 0.9rem;
}
td {
    padding: 0.7rem 0.8rem;
    border-top: 1px solid #eee;
    font-size: 0.95rem;
}
tr:hover td {
    background: #f8fafc;
}

/* Mobile card-style tables */
@media (max-width: 768px) {
    table {
        min-width: unset;
        display: block;
    }
    thead {
        display: none;
    }
    tr {
        display: block;
        margin-bottom: 1rem;
        background: #fff;
        border-radius: 8px;
        box-shadow: 0 1px 4px rgba(0,0,0,0.04);
        padding: 0.5rem;
    }
    td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        border: none;
        padding: 0.5rem;
        text-align: right;
    }
    td::before {
        content: attr(data-label);
        font-weight: bold;
        color: #666;
        margin-left: 0.5rem;
        white-space: nowrap;
    }
}

/* ---------- Alerts ---------- */
.alert {
    padding: 0.8rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
}
.alert.warning { background: #fff3cd; color: #856404; border: 1px solid #ffeeba; }
.success { background: #d4edda; color: #155724; padding: 0.5rem 1rem; border-radius: 6px; margin-bottom: 1rem; }
.error   { background: #f8d7da; color: #721c24; padding: 0.5rem 1rem; border-radius: 6px; margin-bottom: 1rem; }

/* ---------- Stats ---------- */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
    margin: 1.5rem 0;
}
.stat-box {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.2rem;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.stat-number { font-size: 1.8rem; font-weight: 700; color: var(--primary); }
.stat-label  { font-size: 0.9rem; color: #666; margin-top: 0.3rem; }

/* Status badges */
.status-badge {
    display: inline-block;
    padding: 0.2rem 0.7rem;
    border-radius: 12px;
    font-size: 0.85rem;
    color: #fff;
}
.status-badge.pending  { background: #ffc107; color: #333; }
.status-badge.approved { background: #28a745; }
.status-badge.rejected { background: #dc3545; }
.status-badge.active   { background: #28a745; }
.status-badge.inactive { background: #6c757d; }

/* ---------- Desktop (≥768px) ---------- */
@media (min-width: 768px) {
    .admin-sidebar {
        transform: translateX(0);
        position: fixed;
        box-shadow: none;
    }
    .admin-main {
        margin-right: var(--sidebar-width);
    }
    .sidebar-toggle {
        display: none;
    }
    .sidebar-backdrop {
        display: none;
    }
    .admin-content {
        padding: 2rem;
    }
    /* tables back to normal */
    table {
        display: table;
    }
    thead {
        display: table-header-group;
    }
    tr {
        display: table-row;
        margin-bottom: 0;
        box-shadow: none;
        padding: 0;
    }
    td {
        display: table-cell;
        padding: 0.7rem 0.8rem;
    }
    td::before {
        content: none;
    }
}
