/**
 * Custom CSS for Django Unfold Theme
 * School Management System Admin Interface
 * 
 * This file contains custom styling for:
 * - Admin site header and branding
 * - Color scheme and styling
 * - Responsive design for mobile/tablet
 * - Admin navigation and menu structure
 * - Additional UI enhancements
 * - RTL support for Pashto language
 */

/* ============================================================================
   RTL Support for Pashto Language
   ============================================================================ */

/* Force RTL direction for Pashto */
html[lang="ps"] {
    direction: rtl !important;
}

html[lang="ps"] body {
    direction: rtl !important;
}

/* RTL adjustments for inputs and text */
html[lang="ps"] input,
html[lang="ps"] textarea,
html[lang="ps"] select {
    text-align: right;
    direction: rtl;
}

/* Pashto RTL date/time fields: keep typing area on right, picker icon on left */
html[lang="ps"] input[type="date"],
html[lang="ps"] input[type="time"],
html[lang="ps"] input[type="datetime-local"],
html[lang="ps"] input.vDateField,
html[lang="ps"] input.vTimeField {
    direction: rtl;
    text-align: right;
    padding-right: 0.75rem !important;
    padding-left: 2.25rem !important;
    position: relative;
}

html[lang="ps"] input[type="date"]::-webkit-calendar-picker-indicator,
html[lang="ps"] input[type="time"]::-webkit-calendar-picker-indicator,
html[lang="ps"] input[type="datetime-local"]::-webkit-calendar-picker-indicator {
    position: absolute;
    left: 0.6rem;
    right: auto;
    margin: 0;
    cursor: pointer;
}

html[lang="ps"] .datetimeshortcuts {
    display: none !important;
}

html[lang="ps"] .afg-date-visible {
    direction: rtl;
    text-align: right;
}

html[lang="ps"] .text-left {
    text-align: right !important;
}

html[lang="ps"] .text-right {
    text-align: left !important;
}

/* Pashto font rendering */
html[lang="ps"] {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* RTL sidebar adjustments - Move sidebar to right */
html[lang="ps"] aside[class*="sidebar"],
html[lang="ps"] nav[class*="sidebar"],
html[lang="ps"] [class*="unfold-sidebar"] {
    right: 0 !important;
    left: auto !important;
}

html[lang="ps"] main,
html[lang="ps"] [class*="main-content"],
html[lang="ps"] [class*="unfold-main"] {
    margin-right: 280px !important;
    margin-left: 0 !important;
}

/* RTL action bar adjustments - Move action bar for RTL */
html[lang="ps"] #changelist-actions-wrapper {
    margin-right: 280px !important;
    margin-left: 0 !important;
}

html[lang="ps"] .changelist-actions {
    margin-right: 0 !important;
    margin-left: auto !important;
}

html[lang="ps"] .group.changelist-actions {
    margin-right: 280px !important;
}

/* Fix Tailwind classes for RTL */
html[lang="ps"] .lg\:left-0 {
    right: 0 !important;
    left: auto !important;
}

html[lang="ps"] .lg\:ml-\[280px\] {
    margin-right: 280px !important;
    margin-left: 0 !important;
}

html[lang="ps"] .left-0 {
    right: 0 !important;
    left: auto !important;
}

html[lang="ps"] .ml-\[280px\] {
    margin-right: 280px !important;
    margin-left: 0 !important;
}

/* RTL form adjustments */
html[lang="ps"] label {
    text-align: right;
    display: block;
}

html[lang="ps"] .help-text {
    text-align: right;
}

/* RTL table adjustments */
html[lang="ps"] table {
    direction: rtl;
}

html[lang="ps"] th,
html[lang="ps"] td {
    text-align: right;
}

/* RTL button adjustments */
html[lang="ps"] button,
html[lang="ps"] .button {
    direction: rtl;
}

/* ============================================================================
   Material Symbols Font Loading
   ============================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200');

/* ============================================================================
   Root Variables and Global Styles
   ============================================================================ */

:root {
    --primary-50: #f0f9ff;
    --primary-100: #e0f2fe;
    --primary-200: #bae6fd;
    --primary-300: #7dd3fc;
    --primary-400: #38bdf8;
    --primary-500: #0ea5e9;
    --primary-600: #0284c7;
    --primary-700: #0369a1;
    --primary-800: #075985;
    --primary-900: #0c3d66;

    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --info-color: #3b82f6;
}

/* ============================================================================
   Admin Site Header and Branding
   ============================================================================ */

.unfold-header {
    background: linear-gradient(135deg, var(--primary-700) 0%, var(--primary-600) 100%);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.unfold-header h1 {
    color: white;
    font-weight: 700;
    font-size: 1.5rem;
    letter-spacing: -0.5px;
    display: flex;
    align-items: center;
}




.unfold-header .site-title {
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.875rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ============================================================================
   Navigation and Menu Structure
   ============================================================================ */

.unfold-sidebar {
    background-color: #f8fafc;
    border-right: 1px solid #e2e8f0;
}

.unfold-sidebar-nav {
    padding: 1rem 0;
}

.unfold-sidebar-nav-item {
    padding: 0.75rem 1rem;
    color: #475569;
    font-weight: 500;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.unfold-sidebar-nav-item:hover {
    background-color: #f1f5f9;
    color: var(--primary-600);
    border-left-color: var(--primary-500);
}

.unfold-sidebar-nav-item.active {
    background-color: #eff6ff;
    color: var(--primary-700);
    border-left-color: var(--primary-600);
    font-weight: 600;
}

.unfold-sidebar-nav-item-icon {
    margin-right: 0.75rem;
    font-size: 1.25rem;
}

.unfold-sidebar-nav-group {
    margin: 0.5rem 0;
}

.unfold-sidebar-nav-group-title {
    padding: 0.75rem 1rem;
    color: #64748b;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.unfold-sidebar-nav-group-items {
    padding-left: 0;
}

.unfold-sidebar-nav-group-item {
    padding-left: 2.5rem;
}

/* Pashto admin nav readability: slightly larger text + more icon/text space */
html[lang="ps"] aside nav a,
html[lang="ps"] .unfold-sidebar-nav-item {
    font-size: 1rem !important;
    line-height: 1.6 !important;
    font-weight: 600 !important;
}

html[lang="ps"] aside nav a[class*="flex"] {
    gap: 0.95rem !important;
}

html[lang="ps"] aside nav a .material-symbols-outlined,
html[lang="ps"] .unfold-sidebar-nav-item .material-symbols-outlined {
    font-size: 22px !important;
    margin-inline-start: 0.45rem !important;
}

/* ============================================================================
   List View Customization
   ============================================================================ */

.unfold-list-view {
    background-color: #ffffff;
}

.unfold-list-header {
    background: linear-gradient(to right, #f8fafc, #f1f5f9);
    border-bottom: 2px solid #e2e8f0;
    padding: 1.5rem;
}

.unfold-list-header h2 {
    color: var(--primary-900);
    font-size: 1.875rem;
    font-weight: 700;
    margin: 0;
}

.unfold-list-filters {
    background-color: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.unfold-list-filters-title {
    color: #1e293b;
    font-weight: 600;
    margin-bottom: 1rem;
}

.unfold-list-filter-item {
    margin-bottom: 1rem;
}

.unfold-list-filter-item label {
    display: block;
    color: #475569;
    font-weight: 500;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.unfold-list-filter-item select,
.unfold-list-filter-item input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid #cbd5e1;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    transition: border-color 0.2s ease;
}

.unfold-list-filter-item select:focus,
.unfold-list-filter-item input:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.1);
}

.unfold-list-table {
    width: 100%;
    border-collapse: collapse;
    background-color: #ffffff;
}

.unfold-list-table thead {
    background-color: #f1f5f9;
    border-bottom: 2px solid #e2e8f0;
}

.unfold-list-table th {
    padding: 1rem;
    text-align: left;
    color: #1e293b;
    font-weight: 600;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.unfold-list-table tbody tr {
    border-bottom: 1px solid #e2e8f0;
    transition: background-color 0.2s ease;
}

.unfold-list-table tbody tr:hover {
    background-color: #f8fafc;
}

.unfold-list-table td {
    padding: 1rem;
    color: #475569;
    font-size: 0.875rem;
}

.unfold-list-table td a {
    color: var(--primary-600);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
}

.unfold-list-table td a:hover {
    color: var(--primary-700);
    text-decoration: underline;
}

/* ============================================================================
   Form Customization
   ============================================================================ */

.unfold-form {
    background-color: #ffffff;
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.unfold-form-fieldset {
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    background-color: #f8fafc;
}

.unfold-form-fieldset legend {
    color: var(--primary-700);
    font-weight: 600;
    font-size: 1rem;
    padding: 0 0.5rem;
    margin-left: -0.5rem;
}

.unfold-form-field {
    margin-bottom: 1.5rem;
}

.unfold-form-field label {
    display: block;
    color: #1e293b;
    font-weight: 500;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.unfold-form-field label .required {
    color: #ef4444;
    margin-left: 0.25rem;
}

.unfold-form-field input[type="text"],
.unfold-form-field input[type="email"],
.unfold-form-field input[type="password"],
.unfold-form-field input[type="number"],
.unfold-form-field input[type="date"],
.unfold-form-field input[type="time"],
.unfold-form-field input[type="datetime-local"],
.unfold-form-field select,
.unfold-form-field textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #cbd5e1;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-family: inherit;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.unfold-form-field input:focus,
.unfold-form-field select:focus,
.unfold-form-field textarea:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.1);
}

.unfold-form-field textarea {
    resize: vertical;
    min-height: 120px;
}

.unfold-form-field .help-text {
    display: block;
    color: #64748b;
    font-size: 0.75rem;
    margin-top: 0.5rem;
    font-style: italic;
}

.unfold-form-field .errorlist {
    list-style: none;
    padding: 0;
    margin: 0.5rem 0 0 0;
}

.unfold-form-field .errorlist li {
    color: #ef4444;
    font-size: 0.75rem;
    padding: 0.5rem;
    background-color: #fee2e2;
    border-left: 3px solid #ef4444;
    margin-bottom: 0.5rem;
}

/* ============================================================================
   Buttons and Actions
   ============================================================================ */

.unfold-button {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.unfold-button-primary {
    background-color: var(--primary-600);
    color: white;
}

.unfold-button-primary:hover {
    background-color: var(--primary-700);
    box-shadow: 0 4px 6px rgba(2, 132, 199, 0.3);
}

.unfold-button-secondary {
    background-color: #e2e8f0;
    color: #1e293b;
}

.unfold-button-secondary:hover {
    background-color: #cbd5e1;
}

.unfold-button-danger {
    background-color: #ef4444;
    color: white;
}

.unfold-button-danger:hover {
    background-color: #dc2626;
    box-shadow: 0 4px 6px rgba(239, 68, 68, 0.3);
}

.unfold-button-success {
    background-color: var(--success-color);
    color: white;
}

.unfold-button-success:hover {
    background-color: #059669;
    box-shadow: 0 4px 6px rgba(16, 185, 129, 0.3);
}

/* ============================================================================
   Dashboard Widgets
   ============================================================================ */

.unfold-dashboard {
    background-color: #f8fafc;
    padding: 2rem;
}

.unfold-dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.unfold-dashboard-widget {
    background-color: #ffffff;
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    padding: 1.5rem;
    transition: all 0.2s ease;
}

.unfold-dashboard-widget:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
}

.unfold-dashboard-widget-title {
    color: #1e293b;
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
}

.unfold-dashboard-widget-icon {
    width: 2rem;
    height: 2rem;
    background-color: #eff6ff;
    border-radius: 0.375rem;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 0.75rem;
    color: var(--primary-600);
    font-size: 1.25rem;
}

.unfold-dashboard-widget-content {
    color: #475569;
    font-size: 0.875rem;
}

.unfold-dashboard-widget-stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid #e2e8f0;
}

.unfold-dashboard-widget-stat:last-child {
    border-bottom: none;
}

.unfold-dashboard-widget-stat-label {
    color: #64748b;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.unfold-dashboard-widget-stat-value {
    color: var(--primary-700);
    font-size: 1.5rem;
    font-weight: 700;
}

/* ============================================================================
   Status Badges
   ============================================================================ */

.unfold-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.unfold-badge-success {
    background-color: #d1fae5;
    color: #065f46;
}

.unfold-badge-warning {
    background-color: #fef3c7;
    color: #92400e;
}

.unfold-badge-danger {
    background-color: #fee2e2;
    color: #991b1b;
}

.unfold-badge-info {
    background-color: #dbeafe;
    color: #1e40af;
}

/* ============================================================================
   Responsive Design for Mobile/Tablet
   ============================================================================ */

@media (max-width: 768px) {
    .unfold-sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        width: 100%;
        height: 100vh;
        background-color: #f8fafc;
        z-index: 1000;
        transition: left 0.3s ease;
        overflow-y: auto;
    }

    .unfold-sidebar.open {
        left: 0;
    }

    .unfold-main {
        margin-left: 0;
    }

    .unfold-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .unfold-header-toggle {
        display: block;
        background: none;
        border: none;
        color: white;
        font-size: 1.5rem;
        cursor: pointer;
    }

    .unfold-dashboard-grid {
        grid-template-columns: 1fr;
    }

    .unfold-list-table {
        font-size: 0.75rem;
    }

    .unfold-list-table th,
    .unfold-list-table td {
        padding: 0.75rem 0.5rem;
    }

    .unfold-form-fieldset {
        padding: 1rem;
    }

    .unfold-button {
        width: 100%;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .unfold-header h1 {
        font-size: 1.25rem;
    }

    .unfold-dashboard-widget {
        padding: 1rem;
    }

    .unfold-list-filters {
        padding: 0.75rem;
    }

    .unfold-form-fieldset {
        padding: 0.75rem;
        margin-bottom: 1rem;
    }

    .unfold-button {
        padding: 0.625rem 1rem;
        font-size: 0.75rem;
    }
}

/* ============================================================================
   Print Styles
   ============================================================================ */

@media print {

    .unfold-sidebar,
    .unfold-header,
    .unfold-button,
    .unfold-list-filters {
        display: none;
    }

    .unfold-main {
        margin-left: 0;
    }

    .unfold-list-table {
        box-shadow: none;
    }
}

/* ============================================================================
   Accessibility Enhancements
   ============================================================================ */

.unfold-button:focus,
.unfold-form-field input:focus,
.unfold-form-field select:focus,
.unfold-form-field textarea:focus {
    outline: 2px solid var(--primary-500);
    outline-offset: 2px;
}

.unfold-skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--primary-600);
    color: white;
    padding: 0.5rem 1rem;
    text-decoration: none;
    z-index: 100;
}

.unfold-skip-link:focus {
    top: 0;
}

/* ============================================================================
   Animation and Transitions
   ============================================================================ */

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.unfold-fade-in {
    animation: fadeIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(-100%);
    }

    to {
        transform: translateX(0);
    }
}

.unfold-slide-in {
    animation: slideIn 0.3s ease;
}

/* ============================================================================
   Dark Mode Support (Optional)
   ============================================================================ */

@media (prefers-color-scheme: dark) {
    .unfold-sidebar {
        background-color: #1e293b;
        border-right-color: #334155;
    }

    .unfold-sidebar-nav-item {
        color: #cbd5e1;
    }

    .unfold-sidebar-nav-item:hover {
        background-color: #334155;
        color: var(--primary-400);
    }

    .unfold-sidebar-nav-item.active {
        background-color: #0f172a;
        color: var(--primary-300);
    }

    .unfold-list-view {
        background-color: #0f172a;
    }

    .unfold-list-header {
        background: linear-gradient(to right, #1e293b, #334155);
    }

    .unfold-list-header h2 {
        color: #f1f5f9;
    }

    .unfold-list-filters {
        background-color: #1e293b;
        border-color: #334155;
    }

    .unfold-list-table {
        background-color: #0f172a;
    }

    .unfold-list-table thead {
        background-color: #1e293b;
        border-bottom-color: #334155;
    }

    .unfold-list-table th {
        color: #f1f5f9;
    }

    .unfold-list-table tbody tr {
        border-bottom-color: #334155;
    }

    .unfold-list-table tbody tr:hover {
        background-color: #1e293b;
    }

    .unfold-list-table td {
        color: #cbd5e1;
    }

    .unfold-form {
        background-color: #0f172a;
    }

    .unfold-form-fieldset {
        background-color: #1e293b;
        border-color: #334155;
    }

    .unfold-form-fieldset legend {
        color: var(--primary-400);
    }

    .unfold-form-field label {
        color: #f1f5f9;
    }

    .unfold-form-field input,
    .unfold-form-field select,
    .unfold-form-field textarea {
        background-color: #1e293b;
        color: #f1f5f9;
        border-color: #334155;
    }

    .unfold-dashboard {
        background-color: #0f172a;
    }

    .unfold-dashboard-widget {
        background-color: #1e293b;
    }
}

/* ============================================================================
   Hide Settings Icon in Admin Header
   ============================================================================ */

/* Only hide the settings/gear icon, not all material symbols */
a[href="/admin/"][class*="bg-primary-600"] {
    display: none !important;
}

/* Ensure Material Symbols are visible for sidebar navigation */
.material-symbols-outlined {
    display: inline-block !important;
    font-family: 'Material Symbols Outlined' !important;
    font-weight: normal !important;
    font-style: normal !important;
    font-size: 18px !important;
    line-height: 1 !important;
    letter-spacing: normal !important;
    text-transform: none !important;
    white-space: nowrap !important;
    word-wrap: normal !important;
    direction: ltr !important;
    -webkit-font-feature-settings: 'liga' !important;
    -webkit-font-smoothing: antialiased !important;
    vertical-align: middle !important;
}

/* Ensure the admin logo appears correctly */
.admin-logo {
    width: 24px !important;
    height: 24px !important;
    margin-right: 8px !important;
    vertical-align: middle !important;
    display: inline-block !important;
}