/* Import a clean Amharic font */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Ethiopic:wght@400;700&display=swap');

:root {
    /* Consolidated Theme Variables */
    --primary: #1e3a8a; 
    --primary-hover: #172554;
    --secondary: #e67e22; 
    --dark: #0f172a;
    --light: #f8fafc;
    --light-bg: #ecf0f1;
    --text-dark: #333333;
    --text-light: #ffffff;
    --danger: #ef4444;
    --success: #22c55e;
    --warning: #eab308;
    --border: #cbd5e1;
    
    /* Gradient Variables */
    --gradient-primary: linear-gradient(135deg, rgba(30, 58, 128, 0.85), rgba(10, 23, 42, 0.95));
    --gradient-secondary: linear-gradient(135deg, rgba(230, 126, 34, 0.85), rgba(211, 84, 0, 0.9));
    --gradient-dark: linear-gradient(135deg, rgba(15, 23, 42, 0.95), rgba(10, 23, 42, 0.98));
    --gradient-card: linear-gradient(145deg, #ffffff, #f8fafc);
    --gradient-hero: linear-gradient(135deg, rgba(30, 58, 128, 0.85), rgba(10, 23, 42, 0.92));
    --gradient-success: linear-gradient(135deg, rgba(34, 197, 94, 0.85), rgba(22, 101, 52, 0.9));
    --gradient-danger: linear-gradient(135deg, rgba(239, 68, 68, 0.85), rgba(185, 28, 28, 0.9));
    --gradient-warning: linear-gradient(135deg, rgba(234, 179, 8, 0.85), rgba(161, 98, 7, 0.9));
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    font-family: 'Noto Sans Ethiopic', sans-serif;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    color: var(--dark);
    line-height: 1.6;
    min-height: 100vh;
}

/* --- Base Layout Framework --- */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 2.5rem;
    background-color: #f8fafc;
    border-bottom: 2px solid #cbd5e1;
    position: relative;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    position: sticky;
    top: 0;
    z-index: 1000;
}

header h1 {
    font-size: 1.35rem;
    margin: 0;
    color: #0f172a;
    letter-spacing: -0.025em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 70%;
    font-weight: 700;
}

header nav {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

header nav a {
    text-decoration: none;
    color: #334155;
    font-size: 1rem;
    font-weight: 600;
    transition: color 0.2s ease;
    position: relative;
}

header nav a::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--gradient-secondary);
    transition: width 0.3s ease;
}

header nav a:hover::after {
    width: 100%;
}

header nav a:hover {
    color: #2563eb;
    transform: translateY(-2px);
}

/* Specific styling for user roles */
header nav a.panel-link {
    background: var(--gradient-secondary);
    padding: 0.4rem 1rem;
    border-radius: 50px;
    font-weight: bold;
    color: white;
}

header nav a.panel-link::after {
    display: none;
}

header nav a.panel-link:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(230, 126, 34, 0.3);
}

/* Standard button styling */
.btn {
    display: inline-block;
    background: var(--gradient-secondary);
    color: var(--text-light);
    padding: 0.6rem 1.5rem;
    border-radius: 50px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s ease;
}

.btn:hover::before {
    left: 100%;
}

.btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(230, 126, 34, 0.3);
}

header nav a.btn {
    background-color: #2563eb;
    color: white;
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.2);
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

header nav a.btn:hover {
    background-color: #1d4ed8;
    color: white;
    box-shadow: 0 4px 6px rgba(37, 99, 235, 0.3);
    transform: none;
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
}

.btn-primary:hover {
    box-shadow: 0 10px 25px rgba(30, 58, 128, 0.3);
}

.btn-danger {
    background: var(--gradient-danger);
}

.btn-danger:hover {
    box-shadow: 0 10px 25px rgba(239, 68, 68, 0.3);
}

.btn-success {
    background: var(--gradient-success);
}

.btn-success:hover {
    box-shadow: 0 10px 25px rgba(34, 197, 94, 0.3);
}

/* --- Mobile Menu Toggle Button --- */
.nav-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    flex-direction: column;
    justify-content: space-between;
    /* FIX: bumped up from 30x24 to meet the ~44px touch-target guideline */
    width: 40px;
    height: 32px;
    padding: 4px;
    z-index: 1200;
}

.nav-toggle span {
    display: block;
    height: 3px;
    width: 100%;
    background-color: #0f172a;
    border-radius: 4px;
    transition: all 0.3s ease;
}

/* --- Hero Section --- */
.hero {
    background: var(--gradient-hero), url('../images/bggg2.jpg');
    background-size: cover;
    background-position: center;
    background-blend-mode: overlay;
    color: var(--text-light);
    padding: 5rem 5%;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.hero::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.05), transparent 70%);
    border-radius: 50%;
    pointer-events: none;
}

.hero::after {
    content: '';
    position: absolute;
    bottom: -30%;
    left: -10%;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(230, 126, 34, 0.1), transparent 70%);
    border-radius: 50%;
    pointer-events: none;
}

.hero h2 {
    font-size: 3rem;
    margin-bottom: 1rem;
    position: relative;
    z-index: 1;
    text-shadow: 0 2px 20px rgba(0,0,0,0.3);
}

.hero p {
    font-size: 1.2rem;
    margin-bottom: 2rem;
    max-width: 700px;
    margin-inline: auto;
    position: relative;
    z-index: 1;
    opacity: 0.95;
}

.hero .btn {
    position: relative;
    z-index: 1;
}

/* --- Container --- */
.container {
    width: 90%;
    max-width: 1200px;
    margin: 2rem auto;
}

/* --- Grid System --- */
.grid-3 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

/* --- Cards --- */
.card {
    background: var(--gradient-card);
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
    border: 1px solid var(--border);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--gradient-primary);
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

.card:hover::before {
    transform: scaleX(1);
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 40px rgba(30, 58, 128, 0.1);
    border-color: rgba(30, 58, 128, 0.2);
}

/* --- Announcement Card --- */
.announcement-card {
    border-left: 5px solid var(--warning);
    margin-bottom: 2rem;
}

.announcement-card.display-flex {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 1.5rem;
}

.announcement-image img {
    width: 100%;
    max-width: 300px;
    height: auto;
    max-height: 250px;
    border-radius: 8px;
    object-fit: cover;
    display: block;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.announcement-content {
    flex: 1;
}

.announcement-content h3 {
    color: var(--warning);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0;
}

.announcement-content p {
    margin-bottom: 0;
}

/* --- Service Cards --- */
.service-card {
    background: var(--gradient-card);
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
    border: 1px solid var(--border);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.service-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--gradient-primary);
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

.service-card:hover::before {
    transform: scaleX(1);
}

.service-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 40px rgba(30, 58, 128, 0.1);
    border-color: rgba(30, 58, 128, 0.2);
}

.service-icon {
    margin-bottom: 1rem;
    font-size: 2.5rem;
    color: var(--primary);
}

.service-card h3 {
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
}

.service-card p {
    color: #64748b;
    margin-top: 0.5rem;
}

.btn-link {
    display: inline-block;
    margin-top: 1rem;
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
}

.btn-link:hover {
    color: var(--secondary);
    transform: translateX(5px);
}

/* --- Metrics Dashboard Panel --- */
.stats-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-box {
    background: var(--gradient-card);
    padding: 1.5rem;
    border-radius: 12px;
    border-left: 5px solid var(--primary);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.stat-box::after {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 100px;
    height: 100px;
    background: radial-gradient(circle, rgba(30, 58, 128, 0.05), transparent);
    border-radius: 50%;
}

.stat-box:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(30, 58, 128, 0.08);
}

.stat-box h3 {
    font-size: 0.9rem;
    text-transform: uppercase;
    color: #64748b;
}

.stat-box p {
    font-size: 1.8rem;
    font-weight: bold;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* --- Standard Forms --- */
.form-group {
    margin-bottom: 1.2rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.4rem;
    font-weight: 600;
    color: var(--dark);
}

.form-control {
    width: 100%;
    padding: 0.6rem 1rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.3s ease;
    background: white;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(30, 58, 128, 0.1);
}

/* --- Master Data Tables --- */
.table-responsive {
    overflow-x: auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    border: 1px solid var(--border);
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

th, td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border);
}

th {
    background: linear-gradient(135deg, #f1f5f9, #e2e8f0);
    font-weight: 600;
    color: var(--dark);
}

tr:hover {
    background: linear-gradient(135deg, #f8fafc, #f1f5f9);
}

/* --- Control Layout Elements --- */
.admin-layout {
    display: grid;
    grid-template-columns: 240px 1fr;
    min-height: calc(100vh - 70px);
}

.sidebar {
    background: var(--gradient-dark);
    color: white;
    padding: 1.5rem 1rem;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    /* FIX: give the sidebar its own stacking context so .nav-overlay
       (z-index: 1050) reliably renders above it on mobile */
    position: relative;
    z-index: 1;
}

.sidebar a {
    display: block;
    color: #cbd5e1;
    text-decoration: none;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    transition: all 0.3s ease;
    position: relative;
}

.sidebar a::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 3px;
    background: var(--gradient-secondary);
    transform: scaleY(0);
    transition: transform 0.3s ease;
}

.sidebar a:hover::before,
.sidebar a.active::before {
    transform: scaleY(1);
}

.sidebar a:hover,
.sidebar a.active {
    background: var(--gradient-primary);
    color: white;
    transform: translateX(5px);
}

.main-content {
    padding: 2rem;
}

/* --- Footer --- */
footer {
    background: var(--gradient-dark);
    color: #94a3b8;
    text-align: center;
    padding: 2rem;
    margin-top: 4rem;
    border-top: 1px solid rgba(255,255,255,0.05);
}

/* --- Alert Notification Framework --- */
.alert {
    padding: 1rem 1.5rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    border-left: 5px solid transparent;
    font-weight: 500;
}

.alert-success {
    background: linear-gradient(135deg, #dcfce7, #bbf7d0);
    color: #166534;
    border-left-color: #22c55e;
}

.alert-danger {
    background: linear-gradient(135deg, #fee2e2, #fecaca);
    color: #991b1b;
    border-left-color: #ef4444;
}

.alert-warning {
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    color: #92400e;
    border-left-color: #eab308;
}

.alert-info {
    background: linear-gradient(135deg, #dbeafe, #bfdbfe);
    color: #1e40af;
    border-left-color: #3b82f6;
}

/* --- Responsive Media Queries --- */

@media (max-width: 992px) {
    .nav-toggle {
        display: flex;
    }
    
    header nav {
        position: fixed;
        top: 0;
        right: -100%;
        width: 280px;
        height: 100vh;
        background-color: #ffffff;
        flex-direction: column;
        align-items: flex-start;
        padding: 6rem 2rem 2rem 2rem;
        box-shadow: -10px 0 25px rgba(0, 0, 0, 0.15);
        transition: right 0.35s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 1100;
        gap: 1.5rem;
    }

    header nav.active {
        right: 0;
    }

    header nav a {
        width: 100%;
        font-size: 1.15rem;
        padding: 0.75rem 0;
        border-bottom: 1px solid #e2e8f0;
    }

    header nav a::after {
        display: none; 
    }

    header nav a.btn {
        text-align: center;
        margin-top: 1rem;
        width: 100%;
        box-sizing: border-box;
    }

    .nav-overlay {
        display: none;
        position: fixed;
        /* FIX: percentage top/left/width/height on a fixed element could
           resolve against a constrained containing block; inset + vw/vh
           guarantees full-viewport coverage over BOTH the content and
           the admin sidebar */
        inset: 0;
        width: 100vw;
        height: 100vh;
        background: rgba(15, 23, 42, 0.5);
        backdrop-filter: blur(2px);
        z-index: 1050;
    }

    .nav-overlay.active {
        display: block;
    }

    .hero h2 {
        font-size: 2.4rem;
    }

    /* FIX: the admin sidebar now collapses to a horizontal scroll bar
       at the SAME breakpoint the hamburger nav appears (992px), instead
       of at 768px. That mismatch was the cause of the overlapping
       sidebar + hamburger nav layout between 768px and 992px. */
    .admin-layout {
        display: flex;
        flex-direction: column;
    }

    .sidebar {
        display: flex;
        flex-direction: row;
        overflow-x: auto;
        white-space: nowrap;
        gap: 0.5rem;
        padding: 0.75rem;
        background: var(--gradient-dark);
        border-bottom: 2px solid rgba(255, 255, 255, 0.1);
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none; /* Hide scrollbar for clean UI */
    }

    .sidebar::-webkit-scrollbar {
        display: none;
    }

    /* FIX: fade indicator at the right edge to hint the chip row scrolls */
    .sidebar::after {
        content: '';
        position: sticky;
        top: 0;
        right: 0;
        align-self: stretch;
        flex: 0 0 24px;
        background: linear-gradient(to right, transparent, rgba(15, 23, 42, 0.9));
        pointer-events: none;
    }

    /* Hide the heading label on mobile to save space */
    .sidebar h3 {
        display: none;
    }

    /* Make individual links act as compact touch-friendly chips */
    .sidebar a {
        display: inline-block;
        padding: 0.5rem 0.8rem;
        font-size: 0.85rem;
        border-radius: 6px;
        margin-bottom: 0;
        flex-shrink: 0;
    }

    .sidebar a::before {
        display: none; /* Remove left indicator bar on mobile layout */
    }

    .sidebar a:hover,
    .sidebar a.active {
        transform: translateY(-2px); /* Subtle lift instead of horizontal shift */
    }
}

@media (max-width: 768px) {
    header {
        padding: 1rem 5%;
    }
    
    header h1 {
        font-size: 1.3rem;
    }

    header nav a.panel-link,
    header nav a.btn {
        width: 100%;
        border-radius: 8px;
    }
    
    .hero {
        padding: 3rem 1rem;
    }

    .hero h2 {
        font-size: 1.8rem;
    }
    
    .hero p {
        font-size: 0.95rem;
    }
    
    .container {
        width: 95%;
        margin: 1rem auto;
    }

    .grid-3 {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .stats-container {
        grid-template-columns: 1fr;
    }
    
    .announcement-card.display-flex {
        flex-direction: column;
        text-align: center;
        gap: 1rem;
    }
    
    .announcement-content h3 {
        justify-content: center;
    }

    .main-content {
        padding: 1rem;
    }

    th, td {
        padding: 0.75rem 0.6rem;
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 1.1rem;
    }

    .hero h2 {
        font-size: 1.5rem;
    }

    .card, .service-card, .stat-box {
        padding: 1rem;
    }
}