/* Mobile App-like Design */
@media (max-width: 768px) {
    /* App Container */
    body {
        padding-bottom: calc(100px + env(safe-area-inset-bottom, 0px)); /* Space for bottom navigation so content at end of page is visible on all accounts */
        background: #f5f5f5;
    }

    .main-container {
        padding: 0;
        padding-bottom: calc(100px + env(safe-area-inset-bottom, 0px));
    }

    .container-fluid {
        padding: 0;
    }

    /* App Header (flex so injected menu button sits beside title) */
    .app-header {
        position: sticky;
        top: 0;
        z-index: 1000;
        background: linear-gradient(135deg, #1a5f5f 0%, #2d7a7a 100%);
        color: white;
        padding: 0.85rem 1rem;
        box-shadow: 0 2px 10px rgba(0,0,0,0.1);
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 0.5rem;
    }

    .app-header-menu-btn {
        background: rgba(255,255,255,0.2);
        border: none;
        color: white;
        width: 42px;
        height: 42px;
        border-radius: 10px;
        font-size: 1.4rem;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
        order: -1;
    }
    .app-header-menu-btn:active {
        background: rgba(255,255,255,0.35);
    }

    .app-header-notifications-btn {
        position: absolute;
        top: 0.85rem;
        left: 1rem;
        background: rgba(255,255,255,0.2);
        border: none;
        color: white;
        width: 42px;
        height: 42px;
        border-radius: 10px;
        font-size: 1.25rem;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
        text-decoration: none;
        z-index: 2;
    }
    .app-header-notifications-btn:active {
        background: rgba(255,255,255,0.35);
    }
    .app-header-notifications-btn .app-header-notifications-badge {
        position: absolute;
        top: -4px;
        right: -4px;
        min-width: 18px;
        height: 18px;
        padding: 0 5px;
        font-size: 0.7rem;
        font-weight: 600;
        line-height: 18px;
        text-align: center;
        background: #dc3545;
        color: white;
        border-radius: 9px;
        border: 2px solid #1a5f5f;
    }

    .app-header h1 {
        font-size: 1.5rem;
        margin: 0;
        font-weight: 600;
        flex: 1;
        min-width: 0;
    }

    .app-header p {
        font-size: 0.9rem;
        margin: 0.25rem 0 0 0;
        opacity: 0.9;
        width: 100%;
    }

    /* لوحة ولي الأمر: هيدر وبانر مضغوطين لتقليل الحجم عند التمرير */
    .parent-dashboard-page .app-header.app-header-compact,
    .parent-dashboard-page .app-header {
        padding: 0.5rem 0.75rem;
    }
    .parent-dashboard-page .app-header h1 {
        font-size: 1.25rem;
    }
    .parent-dashboard-page .app-header p {
        font-size: 0.8rem;
        margin-top: 0.15rem;
    }
    .parent-dashboard-page .parent-dashboard-banner {
        padding: 0.4rem 0.75rem;
    }
    .parent-dashboard-page .parent-dashboard-banner-inner {
        font-size: 0.9rem;
    }
}

/* لوحة ولي الأمر - سطح المكتب: تقليل حجم الهيدر */
.parent-dashboard-page .page-header {
    padding: 0.75rem 0;
}
.parent-dashboard-page .page-header h1 {
    font-size: 1.35rem;
    margin-bottom: 0.25rem;
}

@media (max-width: 768px) {
    /* Bottom Navigation Bar */
    .bottom-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: white;
        border-top: 1px solid #e0e0e0;
        padding: 0.5rem 0;
        z-index: 1000;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
        display: flex;
        justify-content: space-around;
        align-items: center;
    }

    .bottom-nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        text-decoration: none;
        color: #666;
        font-size: 0.75rem;
        padding: 0.5rem;
        min-width: 60px;
        transition: all 0.3s;
    }

    .bottom-nav-item.active {
        color: #1a5f5f;
    }

    .bottom-nav-item i {
        font-size: 1.5rem;
        margin-bottom: 0.25rem;
    }

    /* Sidebar Overlay with blur */
    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.35);
        -webkit-backdrop-filter: blur(4px);
        backdrop-filter: blur(4px);
        z-index: 1100;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0.3s ease;
    }
    .sidebar-overlay.open {
        opacity: 1;
        visibility: visible;
    }

    /* Mobile Sidebar Panel - slides in from physical right */
    .mobile-sidebar {
        position: fixed;
        top: 0;
        right: 0 !important;
        left: auto !important;
        width: 300px;
        max-width: 88vw;
        height: 100%;
        background: #fafbfc;
        z-index: 1101;
        box-shadow: -8px 0 32px rgba(0,0,0,0.12);
        display: flex;
        flex-direction: column;
        transform: translateX(100%);
        transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1), box-shadow 0.35s ease;
        overflow: hidden;
        border-radius: 20px 0 0 20px;
    }
    .mobile-sidebar.open {
        transform: translateX(0);
        box-shadow: -12px 0 40px rgba(0,0,0,0.15);
    }

    /* Sidebar Header - gradient with Islamic pattern overlay */
    .sidebar-header {
        background: linear-gradient(145deg, #0f4a4a 0%, #1a5f5f 40%, #2d7a7a 100%);
        color: white;
        padding: 1.5rem 1.25rem;
        display: flex;
        align-items: center;
        justify-content: space-between;
        flex-shrink: 0;
        position: relative;
    }
    .sidebar-header-pattern::before {
        content: "";
        position: absolute;
        inset: 0;
        background: repeating-linear-gradient(
            45deg,
            transparent,
            transparent 8px,
            rgba(255,255,255,0.03) 8px,
            rgba(255,255,255,0.03) 16px
        );
        pointer-events: none;
        border-radius: 20px 0 0 0;
    }
    .sidebar-user {
        display: flex;
        align-items: center;
        gap: 1rem;
        min-width: 0;
        position: relative;
        z-index: 1;
    }
    .sidebar-user-avatar {
        width: 52px;
        height: 52px;
        border-radius: 50%;
        background: linear-gradient(135deg, rgba(255,255,255,0.35) 0%, rgba(255,255,255,0.15) 100%);
        border: 2px solid rgba(255,255,255,0.5);
        display: flex;
        align-items: center;
        justify-content: center;
        font-weight: 700;
        font-size: 1.35rem;
        flex-shrink: 0;
    }
    .sidebar-user-info {
        display: flex;
        flex-direction: column;
        gap: 0.35rem;
        min-width: 0;
    }
    .sidebar-user-name {
        font-weight: 700;
        font-size: 1.05rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        letter-spacing: 0.01em;
    }
    .sidebar-user-role-badge {
        display: inline-block;
        font-size: 0.75rem;
        padding: 0.2rem 0.6rem;
        border-radius: 20px;
        background: rgba(255,255,255,0.25);
        font-weight: 600;
        width: fit-content;
    }
    .sidebar-close-btn {
        background: rgba(255,255,255,0.2);
        border: none;
        color: white;
        width: 42px;
        height: 42px;
        border-radius: 12px;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
        position: relative;
        z-index: 1;
        transition: background 0.2s;
    }
    .sidebar-close-btn:active {
        background: rgba(255,255,255,0.35);
    }

    /* Islamic-style divider between header and nav */
    .sidebar-divider {
        height: 3px;
        background: linear-gradient(90deg, transparent 0%, rgba(26, 95, 95, 0.25) 20%, rgba(26, 95, 95, 0.4) 50%, rgba(26, 95, 95, 0.25) 80%, transparent 100%);
        flex-shrink: 0;
    }

    /* Sidebar Body (scrollable nav) */
    .sidebar-body {
        flex: 1;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        padding: 0.85rem 0.75rem;
    }
    .sidebar-nav {
        display: flex;
        flex-direction: column;
        gap: 0.2rem;
    }
    .sidebar-nav-item {
        display: flex;
        align-items: center;
        gap: 0.85rem;
        padding: 0.7rem 1rem;
        color: #2c3e50;
        text-decoration: none;
        font-size: 0.95rem;
        border: none;
        background: none;
        width: 100%;
        text-align: right;
        cursor: pointer;
        transition: background 0.2s, border-color 0.2s;
        min-height: 48px;
        border-radius: 12px;
        border-right: 3px solid transparent;
    }
    .sidebar-nav-item:hover {
        background: rgba(26, 95, 95, 0.08);
    }
    .sidebar-nav-item.active {
        background: linear-gradient(90deg, rgba(26, 95, 95, 0.12) 0%, rgba(26, 95, 95, 0.06) 100%);
        color: #1a5f5f;
        font-weight: 600;
        border-right-color: #1a5f5f;
    }
    .sidebar-nav-item > i {
        font-size: 1.15rem;
        width: 38px;
        height: 38px;
        min-width: 38px;
        min-height: 38px;
        flex-shrink: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 10px;
        background: rgba(26, 95, 95, 0.1);
        color: #1a5f5f;
    }
    .sidebar-nav-item.active > i {
        background: rgba(26, 95, 95, 0.2);
        color: #0f4a4a;
    }
    .sidebar-nav-item.sub {
        padding-right: 2.5rem;
        font-size: 0.9rem;
    }
    .sidebar-nav-item.sub > i {
        width: 32px;
        height: 32px;
        min-width: 32px;
        min-height: 32px;
        font-size: 1rem;
    }

    /* Collapsible nav groups */
    .sidebar-nav-group {
        border: none;
        padding: 0;
        margin: 0;
        background: none;
    }
    .sidebar-nav-group-toggle {
        display: flex;
        align-items: center;
        gap: 0.85rem;
        padding: 0.7rem 1rem;
        width: 100%;
        border: none;
        background: none;
        color: #2c3e50;
        font-size: 0.95rem;
        text-align: right;
        cursor: pointer;
        transition: background 0.2s;
        min-height: 48px;
        border-radius: 12px;
    }
    .sidebar-nav-group-toggle:hover {
        background: rgba(26, 95, 95, 0.08);
    }
    .sidebar-nav-group-toggle > i:first-of-type {
        font-size: 1.15rem;
        width: 38px;
        height: 38px;
        min-width: 38px;
        min-height: 38px;
        flex-shrink: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 10px;
        background: rgba(26, 95, 95, 0.1);
        color: #1a5f5f;
    }
    .sidebar-nav-group-toggle .bi-chevron-down {
        margin-right: auto;
        font-size: 0.85rem;
        transition: transform 0.25s ease;
        color: #1a5f5f;
    }
    .sidebar-nav-group-toggle:not(.collapsed) .bi-chevron-down {
        transform: rotate(180deg);
    }
    .sidebar-nav-group .collapse {
        padding-right: 0;
        background: rgba(26, 95, 95, 0.03);
        border-radius: 0 0 12px 12px;
        margin-bottom: 0.2rem;
    }
    .sidebar-nav-group .collapse .sidebar-nav-item {
        border-radius: 0;
    }

    /* Sidebar Footer */
    .sidebar-footer {
        flex-shrink: 0;
        padding: 1rem 1rem;
        border-top: 1px solid rgba(0,0,0,0.06);
        background: linear-gradient(180deg, #f0f2f5 0%, #e8eaee 100%);
        display: flex;
        flex-direction: column;
        gap: 0.35rem;
    }
    .sidebar-footer .sidebar-nav-item {
        border-radius: 10px;
    }
    .sidebar-logout-form {
        margin: 0;
        padding: 0;
    }
    .sidebar-logout-btn {
        color: #721c24;
    }
    .sidebar-logout-btn:hover {
        background: rgba(114, 28, 36, 0.08);
    }
    .sidebar-logout-btn > i {
        background: rgba(114, 28, 36, 0.12) !important;
        color: #721c24 !important;
    }

    body.sidebar-open {
        overflow: hidden;
    }

    /* App Header with inner (optional when using partial) */
    .app-header-inner {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        width: 100%;
    }
    .app-header-inner .sidebar-toggle-btn {
        background: rgba(255,255,255,0.2);
        border: none;
        color: white;
        padding: 0.5rem;
        font-size: 1.35rem;
        display: flex;
        align-items: center;
        justify-content: center;
        min-width: 44px;
        min-height: 44px;
        border-radius: 8px;
        flex-shrink: 0;
    }
    .app-header-inner .sidebar-toggle-btn:active {
        background: rgba(255,255,255,0.3);
    }
    .app-header-inner h1 {
        flex: 1;
        margin: 0;
        font-size: 1.25rem;
        min-width: 0;
    }
    .app-header-spacer {
        width: 44px;
        flex-shrink: 0;
    }

    /* Card Design for Mobile */
    .card-modern {
        border-radius: 12px;
        margin-bottom: 1rem;
        box-shadow: 0 2px 6px rgba(0,0,0,0.06);
        border: 1px solid #dee2e6;
    }

    .card-header {
        border-radius: 12px 12px 0 0 !important;
        padding: 1rem;
    }

    .card-body {
        padding: 1rem;
    }

    /* Plan details: vertical layout and sections on mobile */
    .plan-details {
        padding: 0;
    }
    .plan-detail-section {
        border-bottom: 1px solid rgba(0,0,0,0.08);
        padding-bottom: 1rem;
        margin-bottom: 1rem;
    }
    .plan-detail-section:last-child {
        border-bottom: none;
        margin-bottom: 0;
        padding-bottom: 0;
    }
    .plan-detail-row {
        display: flex;
        flex-direction: column;
        gap: 0.25rem;
        margin-bottom: 1rem;
    }
    .plan-detail-row:last-child {
        margin-bottom: 0;
    }

    /* Stat Cards */
    .stat-card {
        border-radius: 16px;
        padding: 1.5rem;
        margin-bottom: 1rem;
        box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    }

    .stat-card-small {
        border-radius: 12px;
        padding: 1rem;
        margin-bottom: 1rem;
    }

    /* Buttons */
    .btn {
        border-radius: 10px;
        padding: 0.75rem 1.5rem;
        font-weight: 500;
        font-size: 0.95rem;
    }

    .btn-group {
        width: 100%;
    }

    .btn-group .btn {
        flex: 1;
    }

    /* List Items */
    .list-group-item {
        border-radius: 10px;
        margin-bottom: 0.5rem;
        border: 1px solid #e0e0e0;
        padding: 1rem;
    }

    /* Forms */
    .form-control,
    .form-select {
        border-radius: 10px;
        padding: 0.75rem;
        border: 1px solid #e0e0e0;
    }

    /* Page Header */
    .page-header {
        background: white;
        padding: 1rem;
        margin-bottom: 1rem;
        border-radius: 0;
        box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    }

    .page-header h1 {
        font-size: 1.5rem;
        margin: 0;
    }

    /* Quick Actions Grid */
    .quick-actions {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
        padding: 1rem;
    }

    .quick-action-btn {
        background: white;
        border: 1px solid #e0e0e0;
        border-radius: 12px;
        padding: 1.5rem 1rem;
        text-align: center;
        text-decoration: none;
        color: #333;
        display: flex;
        flex-direction: column;
        align-items: center;
        transition: all 0.3s;
        box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    }

    .quick-action-btn:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 8px rgba(0,0,0,0.1);
        color: #1a5f5f;
    }

    .quick-action-btn i {
        font-size: 2rem;
        margin-bottom: 0.5rem;
        color: #1a5f5f;
    }

    /* Student Card */
    .student-card {
        background: white;
        border-radius: 12px;
        padding: 1rem;
        margin-bottom: 1rem;
        box-shadow: 0 2px 6px rgba(0,0,0,0.06);
        border: 1px solid #dee2e6;
        display: flex;
        align-items: center;
        gap: 1rem;
    }

    .student-avatar {
        width: 50px;
        height: 50px;
        border-radius: 50%;
        background: linear-gradient(135deg, #1a5f5f 0%, #2d7a7a 100%);
        display: flex;
        align-items: center;
        justify-content: center;
        color: white;
        font-weight: bold;
        font-size: 1.2rem;
    }

    .student-info {
        flex: 1;
    }

    .student-name {
        font-weight: 600;
        font-size: 1rem;
        margin-bottom: 0.25rem;
    }

    .student-details {
        font-size: 0.85rem;
        color: #666;
    }

    /* Attendance Status */
    .attendance-status {
        display: inline-block;
        padding: 0.25rem 0.75rem;
        border-radius: 20px;
        font-size: 0.8rem;
        font-weight: 500;
    }

    .status-present {
        background: #d4edda;
        color: #155724;
    }

    .status-absent {
        background: #f8d7da;
        color: #721c24;
    }

    .status-late {
        background: #fff3cd;
        color: #856404;
    }

    /* Progress Bar */
    .progress {
        height: 8px;
        border-radius: 10px;
        background: #e0e0e0;
    }

    .progress-bar {
        border-radius: 10px;
    }

    /* Swipe Actions */
    .swipeable-item {
        position: relative;
        overflow: hidden;
    }

    .swipe-actions {
        position: absolute;
        right: 0;
        top: 0;
        bottom: 0;
        display: flex;
        align-items: center;
        padding: 0 1rem;
        background: #dc3545;
        color: white;
        transform: translateX(100%);
        transition: transform 0.3s;
    }

    /* Hide desktop elements (keep landing page navbar visible on mobile) */
    .navbar:not(.navbar-landing) {
        display: none !important;
    }

    .footer {
        display: none !important;
    }

    /* Hide desktop page headers */
    .page-header.d-none.d-md-block {
        display: none !important;
    }

   

    /* General app styling */
    html {
        min-height: 100%;
        overflow-x: hidden;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        touch-action: manipulation;
    }

    body {
        min-height: 100%;
        -webkit-overflow-scrolling: touch;
        touch-action: manipulation;
    }


    .bottom-nav {
        padding-bottom: env(safe-area-inset-bottom);
    }

    /* Smooth scrolling */
    * {
        -webkit-tap-highlight-color: transparent;
    }

    /* Better touch targets */
    .btn, .card, .list-group-item {
        min-height: 44px;
        touch-action: manipulation;
    }

    /* Pull to refresh indicator */
    .pull-to-refresh {
        text-align: center;
        padding: 1rem;
        color: #666;
    }

    /* Full width on mobile */
    .row {
        margin: 0;
    }

    .row > * {
        padding: 0.5rem;
    }

    /* Ensure all content has proper spacing */
    .container-fluid > * {
        margin-left: 0.5rem;
        margin-right: 0.5rem;
    }

    /* Cards should be full width on mobile */
    .card-modern {
        margin-left: 0.5rem;
        margin-right: 0.5rem;
    }

    /* Stat cards spacing */
    .stat-card {
        margin-left: 0.5rem;
        margin-right: 0.5rem;
    }

    /* Alerts spacing */
    .alert {
        margin-left: 0.5rem;
        margin-right: 0.5rem;
    }

    /* Tables should scroll horizontally */
    .table-responsive {
        margin-left: 0.5rem;
        margin-right: 0.5rem;
    }

    /* Forms spacing */
    form {
        margin-left: 0.5rem;
        margin-right: 0.5rem;
    }

    /* Lists spacing */
    .list-group {
        margin-left: 0.5rem;
        margin-right: 0.5rem;
    }

    /* Better spacing for quick actions */
    .quick-actions {
        margin: 0;
        padding: 1rem;
    }

    /* Ensure proper z-index stacking */
    .app-header {
        z-index: 1000;
    }

    .bottom-nav {
        z-index: 1000;
    }

    /* Prevent text selection on buttons */
    .btn, .bottom-nav-item, .quick-action-btn {
        user-select: none;
        -webkit-user-select: none;
    }

    /* Loading states */
    .loading {
        display: flex;
        justify-content: center;
        align-items: center;
        padding: 2rem;
    }

    .spinner {
        width: 40px;
        height: 40px;
        border: 4px solid #f3f3f3;
        border-top: 4px solid #1a5f5f;
        border-radius: 50%;
        animation: spin 1s linear infinite;
    }

    @keyframes spin {
        0% { transform: rotate(0deg); }
        100% { transform: rotate(360deg); }
    }

    /* Table responsive */
    .table-responsive {
        border-radius: 12px;
        overflow: hidden;
    }

    .table {
        margin: 0;
    }

    /* Modal full screen on mobile */
    .modal-dialog {
        margin: 0;
        max-width: 100%;
        height: 100%;
    }

    .modal-content {
        height: 100%;
        border-radius: 0;
    }

    /* Search bar */
    .search-bar {
        background: white;
        padding: 1rem;
        margin-bottom: 1rem;
        border-radius: 0;
    }

    .search-box {
        border-radius: 25px;
        padding: 0.75rem 1.5rem;
    }
}

/* Student card and card-modern on desktop (Teacher area) */
@media (min-width: 769px) {
    .student-card {
        border: 1px solid #dee2e6;
        border-radius: 12px;
        background: #fff;
        padding: 1rem;
        display: flex;
        align-items: center;
        gap: 1rem;
        box-shadow: 0 2px 6px rgba(0,0,0,0.06);
    }
    .card-modern {
        border-radius: 12px;
        box-shadow: 0 2px 6px rgba(0,0,0,0.06);
    }
}

/* Tablet adjustments */
@media (min-width: 769px) and (max-width: 1024px) {
    .quick-actions {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Animation for mobile */
@keyframes slideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.mobile-slide-up {
    animation: slideUp 0.3s ease-out;
}

/* Plan detail labels and values (visual hierarchy, all breakpoints) */
.plan-detail-label {
    font-size: 0.875rem;
    color: #6c757d;
    font-weight: 500;
    margin-bottom: 0.15rem;
}
.plan-detail-value {
    font-size: 1rem;
    font-weight: 600;
    color: #1a1a1a;
}

@media (min-width: 769px) {
    .plan-detail-row {
        flex-direction: row;
        align-items: baseline;
        gap: 0.5rem;
        margin-bottom: 0.5rem;
    }
    .plan-detail-label {
        margin-bottom: 0;
        min-width: 10rem;
    }
    .plan-detail-section {
        margin-bottom: 1rem;
        padding-bottom: 1rem;
    }
}

