/* General Body & HTML Setup for Mobile App Look */
:root {
    --primary-color: #3f4994; /* Green */
    --primary-dark: #388E3C;
    --secondary-color: #2196F3; /* Blue */
    --accent-color: #FFC107; /* Amber */
    --background-light: #f4f7f6;
    --text-color: #333;
    --light-border: #ddd;
    --shadow-color: rgba(0,0,0,0.1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%; /* تأكد أن الارتفاع 100% */
    font-family: 'Arial', sans-serif;
    background-color: var(--background-light);
    color: var(--text-color);
    direction: rtl; /* Right-to-left for Arabic */
    text-align: right;
    overflow: hidden; /* تم الاحتفاظ به هنا إذا كنت تريد منع التمرير على مستوى الصفحة بالكامل */
}

/* App Container for Full Mobile Screen Feel */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh; /* Full viewport height */
    max-width: 500px; /* Max width for a phone screen */
    margin: 0 auto; /* Center on larger screens */
    box-shadow: var(--shadow-color) 0px 0px 15px;
    border-radius: 8px;
    overflow: hidden; /* تم الاحتفاظ به هنا */
    background-color: #fff; /* Main app background */
}

/* Header */
.app-header {
    background-color: var(--primary-color);
    color: white;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-color) 0px 2px 5px;
    z-index: 1000; /* Ensure header is on top */
}

.app-header .logo img {
    height: 40px; /* Adjust logo size */
    width: auto;
    border-radius: 50%; /* If your logo is circular */
}

.app-header .page-title {
    font-size: 1.2em;
    margin: 0;
    flex-grow: 1; /* Allows title to take available space */
    text-align: center;
}

.menu-button {
    background: none;
    border: none;
    color: white;
    font-size: 1.5em;
    cursor: pointer;
    padding: 5px;
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    right: -280px; /* Hidden by default (adjust width as needed) */
    width: 250px;
    height: 100%;
    background-color: #f8f8f8;
    box-shadow: var(--shadow-color) -2px 0px 10px;
    transition: right 0.3s ease-in-out;
    z-index: 1100; /* Above header */
    display: flex;
    flex-direction: column;
    padding-top: 20px;
}

.sidebar.active {
    right: 0;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 15px 15px;
    border-bottom: 1px solid var(--light-border);
}

.sidebar-header h3 {
    margin: 0;
    font-size: 1.1em;
    color: var(--primary-dark);
}

.close-sidebar-button {
    background: none;
    border: none;
    font-size: 1.8em;
    color: #888;
    cursor: pointer;
}

.sidebar-nav ul {
    list-style: none;
    padding: 0;
}

.sidebar-nav li a {
    display: block;
    padding: 15px 20px;
    color: var(--text-color);
    text-decoration: none;
    border-bottom: 1px solid #eee;
    transition: background-color 0.2s ease;
    display: flex;
    align-items: center;
}

.sidebar-nav li a i {
    margin-left: 10px; /* Space between icon and text */
    color: var(--primary-color);
}

.sidebar-nav li a:hover {
    background-color: #e9e9e9;
}

.sidebar-nav li:last-child a {
    border-bottom: none;
}

/* Overlay for when sidebar is active */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1050;
    display: none; /* Hidden by default */
}

.overlay.active {
    display: block;
}

/* Main Content Area */
.app-content {
    flex-grow: 1; /* Takes remaining space */
    padding: 15px;
    overflow-y: auto; /* Scrollable content */
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    /* إضافة min-height أو flex-basis إذا لم يعمل flex-grow بشكل متوقع */
    min-height: 0; /* مهم لـ flex items لكي يتمكن overflow-y من العمل بشكل صحيح */
}

/* Footer (Bottom Navigation) */
.app-footer {
    background-color: #fff;
    padding: 10px 0;
    box-shadow: var(--shadow-color) 0px -2px 5px;
    z-index: 999; /* Below header, above content */
}

.bottom-nav {
    display: flex;
    justify-content: space-around;
    align-items: center;
}

.bottom-nav .nav-item {
    flex: 1;
    text-align: center;
    color: #888;
    text-decoration: none;
    font-size: 0.8em;
    padding: 5px 0;
    transition: color 0.2s ease;
}

.bottom-nav .nav-item i {
    display: block;
    font-size: 1.5em;
    margin-bottom: 3px;
}

.bottom-nav .nav-item:hover,
.bottom-nav .nav-item.active {
    color: var(--primary-color);
}

/* Buttons */
.btn-primary, .btn-secondary, .btn-danger, .btn-info {
    display: inline-block;
    padding: 10px 15px;
    border-radius: 5px;
    font-size: 1em;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    border: none;
    transition: background-color 0.2s ease, transform 0.1s ease;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-dark);
}

.btn-secondary {
    background-color: #9E9E9E; /* Grey */
    color: white;
}

.btn-secondary:hover {
    background-color: #757575;
}

.btn-danger {
    background-color: #F44336; /* Red */
    color: white;
}

.btn-danger:hover {
    background-color: #D32F2F;
}

.btn-info {
    background-color: var(--secondary-color); /* Blue */
    color: white;
}

.btn-info:hover {
    background-color: #1976D2;
}

/* Forms */
.app-form {
    background-color: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: var(--shadow-color) 0px 2px 8px;
    margin-bottom: 20px;
}

.input-group {
    margin-bottom: 15px;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: #555;
}

.input-group input[type="text"],
.input-group input[type="password"],
.input-group input[type="email"],
.input-group input[type="date"],
.input-group input[type="number"],
.input-group select,
.input-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--light-border);
    border-radius: 5px;
    font-size: 1em;
    -webkit-appearance: none; /* Remove default browser styling */
    -moz-appearance: none;
    appearance: none;
}

.input-group input:focus,
.input-group select:focus,
.input-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.2);
}

/* Messages */
.error-message {
    background-color: #ffe0b2; /* Light orange */
    color: #D32F2F; /* Dark red */
    padding: 10px;
    border-radius: 5px;
    margin-bottom: 15px;
    border: 1px solid #FFAB91;
    text-align: center;
}

.success-message {
    background-color: #e8f5e9; /* Light green */
    color: var(--primary-dark);
    padding: 10px;
    border-radius: 5px;
    margin-bottom: 15px;
    border: 1px solid #A5D6A7;
    text-align: center;
}

.no-data-message {
    text-align: center;
    color: #777;
    padding: 20px;
    background-color: #f0f0f0;
    border-radius: 8px;
    margin-top: 20px;
}

/* Tables */
.table-responsive {
    overflow-x: auto; /* Allows horizontal scrolling on small screens */
    margin-top: 20px;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: var(--shadow-color) 0px 2px 8px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px; /* Ensure table doesn't get too squished */
}

.data-table th, .data-table td {
    padding: 12px 15px;
    border-bottom: 1px solid var(--light-border);
    text-align: right; /* RTL alignment */
}

.data-table th {
    background-color: var(--primary-color);
    color: white;
    font-weight: bold;
    text-transform: uppercase;
    font-size: 0.9em;
}

.data-table tbody tr:nth-child(even) {
    background-color: #f9f9f9;
}

.data-table tbody tr:hover {
    background-color: #f1f1f1;
}

.data-table .actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end; /* Align buttons to the right */
}

.data-table .actions .btn-danger,
.data-table .actions .btn-info {
    padding: 8px 12px;
    font-size: 0.85em;
    border-radius: 4px;
}

/* Dashboard Cards */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    padding: 15px 0;
}

.dashboard-card {
    background-color: #fff;
    border-radius: 10px;
    box-shadow: var(--shadow-color) 0px 4px 10px;
    text-align: center;
    padding: 20px;
    text-decoration: none;
    color: var(--text-color);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 120px; /* Ensure cards have a minimum height */
}

.dashboard-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-color) 0px 8px 20px;
}

.dashboard-card .card-icon {
    font-size: 2.5em;
    color: var(--primary-color);
    margin-bottom: 10px;
}

.dashboard-card .card-title {
    font-size: 1.1em;
    font-weight: bold;
}

.dashboard-card.logout-card .card-icon {
    color: #F44336; /* Red for logout */
}

/* Disabled cards for permissions */
.dashboard-card.disabled {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none; /* Prevent clicks */
    background-color: #f0f0f0;
}

.dashboard-card.disabled .card-icon {
    color: #999 !important; /* Grey out icon */
}


/* Separator for forms/sections */
.separator {
    border: none;
    border-top: 1px solid var(--light-border);
    margin: 30px 0;
}

/* Specific for broadcaster form */
.form-section {
    padding: 15px;
    margin-bottom: 20px;
    border: 1px solid #eee;
    border-radius: 8px;
    background-color: #fdfdfd;
}

.form-section h3 {
    margin-top: 0;
    margin-bottom: 15px;
    color: var(--primary-dark);
}

.hidden {
    display: none;
}

.permission-denied {
    background-color: #ffe0b2;
    color: #D32F2F;
    padding: 20px;
    border-radius: 8px;
    text-align: center;
    margin: 20px auto;
    max-width: 400px;
    border: 1px solid #FFAB91;
    font-size: 1.1em;
    font-weight: bold;
}

/* Media Queries for larger screens (if you want to make it look good on desktop too) */
@media (min-width: 600px) {
    .app-container {
        border-radius: 12px;
    }

    .app-header {
        padding: 20px;
    }

    .app-header .page-title {
        font-size: 1.5em;
    }

    .sidebar {
        width: 300px; /* Slightly wider sidebar on tablets/desktops */
    }

    .app-content {
        padding: 20px;
    }

    .dashboard-grid {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
        gap: 20px;
    }

    .dashboard-card {
        padding: 25px;
    }
}