@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;600;700&family=Tajawal:wght@400;500;700&display=swap');

:root {
    --primary-color: #074b33; /* Dark green from logo */
    --secondary-color: #f7bc19; /* Yellow from logo */
    --accent-green: #2c7c50;
    --bg-color: #f8faf8;
    --text-dark: #333333;
    --text-light: #ffffff;
    --card-bg: #ffffff;
    --border-color: #e0e9e2;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

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

body {
    font-family: 'Tajawal', 'Cairo', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-dark);
    direction: rtl; /* Arabic right-to-left */
    line-height: 1.6;
}

/* App Container (Mobile Feel) */
.app-container {
    max-width: 1200px;
    margin: 0 auto;
    background-color: var(--bg-color);
    min-height: 100vh;
    box-shadow: 0 0 20px rgba(0,0,0,0.1);
    position: relative;
    overflow-x: hidden;
}

/* Header */
.header {
    background-color: #fff;
    padding: 20px;
    text-align: center;
    border-bottom: 2px solid var(--secondary-color);
    border-bottom-left-radius: 20px;
    border-bottom-right-radius: 20px;
    position: relative;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.header img.logo {
    max-width: 200px;
    height: auto;
    margin-bottom: 10px;
}

.header h1 {
    color: var(--primary-color);
    font-size: 1.5rem;
    font-weight: 700;
}

.header::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 60px;
    height: 60px;
    background-color: var(--primary-color);
    border-bottom-left-radius: 100%;
}

.header::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 40px;
    height: 40px;
    background-color: var(--secondary-color);
    border-bottom-right-radius: 100%;
}

/* Main Content Area */
.content {
    padding: 20px;
}

/* Section Container */
.section {
    margin-top: 40px; /* Space for absolute header */
    margin-bottom: 30px;
    border: 2px solid var(--primary-color);
    border-radius: 15px;
    padding: 35px 15px 20px; /* Top padding to clear the overlapping badge */
    position: relative;
    background-color: transparent;
}

/* Section Header (Badge on Border) */
.section-header {
    background-color: var(--primary-color);
    color: var(--text-light);
    padding: 6px 20px;
    border-radius: 25px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    box-shadow: var(--shadow);
    
    /* Position exactly on the top border, centered */
    position: absolute;
    top: -20px; /* Half of its height approximately */
    right: 50%;
    transform: translateX(50%); /* Center in RTL */
    white-space: nowrap;
}

.section-header i, .section-header img {
    font-size: 1.2rem;
    width: 24px;
    height: 24px;
    object-fit: contain;
}

/* Items Grid */
.items-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px;
}

/* Item Card */
.item-card {
    flex: 1 1 100px;
    max-width: 140px; 
    background-color: transparent;
    border: none;
    border-radius: 12px;
    padding: 0;
    text-align: center;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.item-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0,0,0,0.15);
}

.item-card img.item-icon {
    width: 100%;
    height: 100%;
    object-fit: cover;
    margin: 0;
    display: block;
}

.item-card .item-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--primary-color);
    line-height: 1.3;
}


/* Modal / Popup */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background-color: var(--card-bg);
    border-radius: 20px;
    width: 90%;
    max-width: 400px;
    overflow: hidden;
    transform: scale(0.9);
    transition: transform 0.3s;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    position: relative;
}

.modal-overlay.active .modal-content {
    transform: scale(1);
}

.modal-close {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(0,0,0,0.5);
    color: white;
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    z-index: 10;
}

.modal-image-container {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: transparent;
    padding: 10px;
}

.modal-image {
    max-width: 100%;
    max-height: 75vh;
    object-fit: contain;
    border-radius: 10px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    padding: 15px;
    background-color: white;
    border-top: 1px solid var(--border-color);
}

.btn {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 10px;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background-color 0.2s;
}

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

.btn-primary:hover {
    background-color: var(--accent-green);
}

.btn-secondary {
    background-color: var(--secondary-color);
    color: var(--text-dark);
}

.btn-secondary:hover {
    background-color: #e5ac17;
}

/* --- Admin Styles --- */
.admin-container {
    max-width: 800px;
    margin: 40px auto;
    background: white;
    padding: 30px;
    border-radius: 20px;
    box-shadow: var(--shadow);
    direction: rtl;
}

.admin-header {
    text-align: center;
    margin-bottom: 30px;
    color: var(--primary-color);
    border-bottom: 2px solid var(--secondary-color);
    padding-bottom: 10px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--primary-color);
}

.form-control {
    width: 100%;
    padding: 12px;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-family: inherit;
    font-size: 1rem;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(7, 75, 51, 0.2);
}

.admin-panels {
    display: flex;
    gap: 30px;
}

.admin-panel {
    flex: 1;
    background: #fcfcfc;
    padding: 20px;
    border-radius: 15px;
    border: 1px solid var(--border-color);
}

.panel-title {
    margin-bottom: 20px;
    font-size: 1.2rem;
    color: var(--accent-green);
}

.data-preview {
    margin-top: 30px;
    border-top: 1px solid #eee;
    padding-top: 20px;
}

.item-list-preview {
    list-style: none;
    margin-top: 10px;
}

.item-list-preview li {
    background: #f0f5f2;
    margin-bottom: 5px;
    padding: 8px 12px;
    border-radius: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.delete-btn {
    color: #e74c3c;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background-color: var(--primary-color);
    color: white;
    padding: 12px 24px;
    border-radius: 30px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 2000;
    opacity: 0;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

@media (max-width: 768px) {
    .admin-panels {
        flex-direction: column;
    }
}
