/*
 * Sivali SMS - Staff Management System
 * General Stylesheet
 *
 * This file contains common, reusable CSS styles for the entire application.
 * Styles specific to a single page's unique layout (e.g., dashboard grid)
 * or temporary debugging might remain in their respective <style> blocks.
 */

/* === General Body & Container Layout === */
body {
    background-image: url('../images/school_background.jpg'); /* Path from css/ to images/ */
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    margin: 0;
    padding: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: Arial, sans-serif;
    color: #333;
    background-color: #f4f4f4; /* Fallback background if no image */
}

.container {
    background-color: rgba(255, 255, 255, 0.9);
    padding: 25px 30px;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    margin: 50px auto;
    max-width: 900px;
    width: 90%;
    box-sizing: border-box;
    flex-grow: 1;
}


/* === Typography & Headings === */

/* Branded H1 Styling (Sivali SMS) */
h1 {
    color: #004085; /* A strong, deep blue for branding */
    text-align: center;
    margin-bottom: 10px;
    font-size: 3em; /* Larger size for impact on PC */
    font-weight: 900; /* Extra bold */
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3); /* More pronounced shadow */
    letter-spacing: 1px; /* Slight letter spacing for branding */
    text-transform: uppercase; /* Optional: Make it all caps */
    line-height: 1.2; /* Adjust line height for larger text */
}

/* Site description (usually below H1) */
.site-description {
    text-align: center;
    color: #555;
    font-size: 1.1em;
    margin-bottom: 25px;
}

/* Common H2 styling */
h2 {
    color: #0056b3; /* Consistent blue for section headings */
    margin-top: 0;
    font-size: 1.3em;
    margin-bottom: 15px;
}

/* General paragraph styling */
p {
    line-height: 1.6;
}

/* Specific styling for pre and code tags */
pre {
    background-color: #e9ecef;
    padding: 10px;
    border-radius: 4px;
    white-space: pre-wrap;
    word-wrap: break-word;
    border: 1px solid #ced4da;
}

code {
    background-color: #f8f9fa;
    padding: 2px 4px;
    border-radius: 3px;
    color: #e83e8c;
}


/* === Forms & Inputs === */

label {
    display: block;
    margin-top: 10px;
    font-weight: bold;
	text-align: center;
}

input[type="text"],
input[type="date"],
input[type="password"],
input[type="number"],
select,
input[list]
{
    width: 100%; /* Make inputs fill container */
    max-width: 400px; /* Limit max width for readability */
    padding: 8px;
    margin-top: 5px;
	margin-left: auto; /* NEW: Center horizontally */
    margin-right: auto; /* NEW: Center horizontally */
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box; /* Include padding in width */
}
input[type="file"] {
    width: auto;
    margin-top: 5px;
}

.form-group {
    margin-bottom: 15px;
}

/* Error and success messages for forms/pages */
.error {
    color: red;
    font-size: 0.9em;
    border: 1px solid red;
    padding: 5px;
    margin-top: 5px;
    list-style-type: none;
    background-color: #ffe0e0;
    border-radius: 4px;
}
.success {
    color: green;
    font-size: 1.1em;
    border: 1px solid green;
    padding: 10px;
    margin-bottom: 15px;
    background-color: #e0ffe0;
    border-radius: 4px;
}
ul.messages {
    padding-left: 0;
    list-style-type: none;
}


/* === Buttons & Links === */

button {
    background-color: #007bff;
    color: white;
    padding: 10px 15px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    margin-top: 20px;
    transition: background-color 0.3s ease;
}
button:hover {
    background-color: #0056b3;
}

/* Generic button-like link styling (for "Back to Dashboard", "Register here" etc.) */
.button-link {
    display: inline-block;
    padding: 8px 15px;
    margin-top: 10px;
    margin-left: 5px;
    background-color: #6c757d;
    color: white !important;
    text-decoration: none;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    font-size: 1em;
    line-height: normal;
    transition: background-color 0.3s ease;
}
.button-link:hover {
    background-color: #5a6268;
}
.button-link.alt-button-style {
    background-color: #428bca;
}
.button-link.alt-button-style:hover {
    background-color: #3071a9;
}

/* New Modal/Popup Styles */
/* New Modal/Popup Styles - DEFINITIVE FIX */
.modal {
    display: none; /* Hidden by default (will be overridden by JS for block) */
    position: fixed !important; /* CRITICAL: Force fixed positioning for overlay */
    z-index: 10000 !important; /* CRITICAL: Ensure it's on top of everything */
    left: 0 !important; /* Force position to top-left of viewport */
    top: 0 !important;
    width: 100% !important; /* Force full width */
    height: 100% !important; /* Force full height */
    background-color: rgba(0,0,0,0.6) !important; /* CRITICAL: Darker background w/ more opacity */
    /* Center modal content using flexbox when displayed by JS */
    display: flex; /* This will be applied via JS setting display:block */
    align-items: center; /* Center vertically */
    justify-content: center; /* Center horizontally */
    box-sizing: border-box !important; /* Ensure padding/border don't break width/height */
}
/* Ensure modal-content and other modal elements remain as they are */

/* Small action buttons (e.g., in Admin Quick Actions, Edit button in tables) */
.action-button-small {
    display: inline-block;
    padding: 8px 15px;
    border-radius: 5px;
    text-decoration: none;
    font-size: 0.9em;
    transition: background-color 0.3s ease;
    white-space: nowrap;
    box-sizing: border-box;
    background-color: #6c757d;
    color: white !important;
}
.action-button-small:hover {
    background-color: #5a6268;
}
/* Specific colors for quick action buttons */
.action-button-small.action-button-primary {
    background-color: #007bff;
    color: white !important;
}
.action-button-small.action-button-primary:hover {
    background-color: #0056b3;
}
.action-button-small.action-button-data-entry {
    background-color: #ffc107;
    color: #343a40 !important;
}
.action-button-small.action-button-data-entry:hover {
    background-color: #e0a800;
}
/* Edit button in manage_users.php table */
.edit-button {
    background-color: #007bff;
    color: white !important;
    padding: 5px 10px;
    font-size: 0.9em;
}
.edit-button:hover { background-color: #0056b3; }


/* === Common Sections (Relief Summary, Timetable, Birthdays, Profile Display, Admin Actions, Dashboard Buttons) === */

/* General container styling for these sections */
.relief-summary, .class-timetable-section, .birthdays-section, .profile-details-display, .admin-actions, .dashboard-buttons {
    background-color: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    margin-top: 30px;
    border: 1px solid #e2e3e5;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}
/* Specific styling for h2 inside these sections */
.relief-summary h2, .class-timetable-section h2 {
    color: #0056b3;
    margin-top: 0;
    font-size: 1.3em;
    margin-bottom: 15px;
    text-align: center;
}
/* Styling for lists within these sections (if any, like birthdays) */
.relief-summary ul, .class-timetable-section ul, .birthdays-section ul {
    list-style-type: none;
    padding: 0;
    margin: 0;
}
.relief-summary li, .class-timetable-section li {
    background-color: #e0f2f7;
    margin-bottom: 8px;
    padding: 10px;
    border-radius: 5px;
    border-left: 5px solid #007bff;
    font-size: 0.95em;
}

/* Birthday section specific overrides */
.birthdays-section {
    background-color: #f0fff0;
    border: 1px solid #e0ffe0;
}
.birthdays-section h3 {
    color: #28a745;
    margin-bottom: 15px;
    font-size: 1.5em;
    text-align: center;
}
.birthdays-section ul {
    list-style-type: none;
    padding: 0;
    margin: 0;
}
.birthdays-section li {
    font-size: 1.1em;
    color: #333;
    margin-bottom: 5px;
    font-weight: bold;
}
.birthdays-section p {
    font-style: italic;
    color: #666;
    text-align: center;
}


/* === PC Table Styles (Standard Layout) === */
.relief-summary table,
.class-timetable-section table,
#manage-users-table
{
    width: 100%;
    border-collapse: collapse;
    margin-top: 0;
    margin-bottom: 20px;
    display: table; /* CRITICAL: Ensure table is displayed as a table on PC */
    table-layout: auto; /* Allow browser to determine column widths */
    overflow-x: auto; /* Add horizontal scroll for PC if table content is too wide */
    -webkit-overflow-scrolling: touch; /* Smooth scrolling for iOS */
}
.relief-summary th, .relief-summary td,
.class-timetable-section th, .class-timetable-section td,
#manage-users-table th, #manage-users-table td {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: left;
    white-space: normal; /* Allow text to wrap naturally on PC */
    overflow: visible; /* No hidden overflow on PC */
    text-overflow: clip; /* No ellipsis on PC */
    /* CRITICAL: Reset mobile-specific display/position properties */
    display: table-cell;
    position: static;
    padding-left: 8px; /* Reset padding-left from mobile overrides */
}
.relief-summary th,
.class-timetable-section th,
#manage-users-table th {
    background-color: #f2f2f2;
}
/* Reset mobile-specific styles for table rows/cells on PC */
.relief-summary tr, .class-timetable-section tr, #manage-users-table tr {
    background-color: initial;
    border: initial;
    margin-bottom: initial;
    border-radius: initial;
    box-shadow: initial;
    display: table-row; /* CRITICAL: Ensure table row is displayed as a table-row on PC */
}
.relief-summary td:last-child,
.class-timetable-section td:last-child,
#manage-users-table td:last-child {
    border-bottom: 1px solid #ddd; /* Ensure bottom border is present for last cell on PC */
}
/* Hide mobile labels on PC - This rule remains crucial */
.relief-summary td .mobile-label,
.class-timetable-section td .mobile-label,
#manage-users-table td .mobile-label {
    display: none !important; /* Keep !important here to forcefully hide mobile labels on PC */
}


/* === Footer === */
.footer {
    margin-top: 40px;
    padding: 20px;
    background-color: rgba(255, 255, 255, 0.9);
    border-top: 1px solid #eee;
    font-size: 0.85em;
    color: #555;
    text-align: center;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.1);
    width: 100%;
    box-sizing: border-box;
}
.footer p { margin: 0; }
.footer a { color: #007bff; text-decoration: none; }
.footer a:hover { text-decoration: underline; }


/* === Header Welcome Section (GIF & Greeting) === */
.header-welcome-section {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 30px;
    gap: 15px;
}
.welcome-text-and-time {
    flex-grow: 1;
    text-align: center;
    min-width: 250px;
}
.welcome-greeting, .current-time-display {
    font-size: 1.2em;
    color: #444;
    margin-bottom: 5px;
    font-weight: bold;
}
.header-gif-container {
    flex-shrink: 0;
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    overflow: hidden;
}
.header-gif-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
}


/* === Mobile Responsiveness (max-width: 768px) === */
@media (max-width: 768px) {
    body {
        background-image: url('../images/school_background.jpg');
        background-size: cover;
        background-position: center;
        background-repeat: no-repeat;
        background-attachment: fixed;
        background-color: transparent !important;
    }
    .container { margin: 20px auto; padding: 15px; }

    /* H1 Branding adjustment for mobile */
    h1 {
        font-size: 2.2em;
        text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
        letter-spacing: 0.5px;
    }


    /* Common mobile button/link styles */
    button, .button-link, .action-button-small {
        display: block;
        width: 90%;
        max-width: 300px;
        margin: 10px auto;
        box-sizing: border-box;
    }
	
/* Refined Auth links on mobile (My Profile / Logout) - FINAL, FORCEFUL FIX FOR SERIAL LAYOUT */
    @media (max-width: 768px) {
        /* ... (Keep other existing mobile-specific styles above this block) ... */

        .auth-links {
            display: flex !important; /* CRITICAL: Force flex display */
            flex-direction: row !important; /* CRITICAL: Force them to stay in a row */
            justify-content: center !important; /* Force center horizontally */
            align-items: center !important; /* Force center vertically */
            flex-wrap: nowrap !important; /* CRITICAL: Prevent wrapping onto new lines */
            gap: 8px !important; /* Force space between buttons */
            margin-bottom: 20px !important; /* Force consistent spacing */
            overflow-x: auto !important; /* Allow horizontal scrolling if buttons are too wide */
            -webkit-overflow-scrolling: touch !important; /* Smooth scrolling for iOS */
            padding: 0 5px !important; /* Add slight horizontal padding to prevent buttons touching edges */
        }
        .auth-links a {
            display: inline-block !important; /* CRITICAL: Force inline-block for buttons */
            width: auto !important; /* Let content dictate width */
            max-width: unset !important; /* Remove any max-width restriction */
            margin: 5px !important; /* Adjust margins for spacing between buttons */
            padding: 8px 15px !important; /* Standard button padding */
            font-size: 0.9em !important; /* Smaller font size for compact buttons */
            flex-shrink: 0 !important; /* Prevent shrinking */
            box-sizing: border-box !important; /* Include padding in width */
            text-align: center !important; /* Center text within the button */
        }
        /* Remove the nested @media (max-width: 480px) for .auth-links as you never want stacking */
    }

    /* Header Welcome Section adjustments for mobile */
    .header-welcome-section {
        flex-direction: column;
        text-align: center;
    }
    .welcome-text-and-time {
        min-width: unset;
        width: 100%;
    }
    .header-gif-container {
        width: 60px; height: 60px;
        margin: 10px auto;
    }

    /* Admin Actions section stacking on mobile */
    .admin-actions {
        flex-direction: column;
        align-items: center;
        padding: 15px;
    }
    .admin-actions strong {
        margin-bottom: 10px;
    }
    .admin-actions a.action-button-small {
        width: 100%;
        text-align: center;
        margin-left: 0;
    }


    /* --- Mobile Table Styles (Stacking with Labels) - FINAL, ROBUST FIX for Mobile View --- */
    @media (max-width: 768px) {
        /* Keep other existing mobile-specific styles like h1, container, buttons, etc. above this block */

        .relief-summary table,
        .class-timetable-section table,
        
        {
            border: 0; /* Remove outer table border */
            width: 100%; /* Ensure table takes full width */
            margin-bottom: 15px; /* Space after each table block */
            display: block; /* CRITICAL: Make the entire table a block element on mobile */
            overflow-x: hidden; /* Prevent horizontal scrolling on the table itself */
        }

        .relief-summary thead,
        .class-timetable-section thead,
        
            display: none; /* CRITICAL: Hide table headers on mobile */
        }

        .relief-summary tr,
        .class-timetable-section tr,
        
            background-color: #ffffff; /* White background for each row/card */
            border: 1px solid #ddd; /* Border for each row/card */
            margin-bottom: 15px; /* Space between rows (each row is now a card) */
            display: block; /* CRITICAL: Make each row a block (a "card") */
            border-radius: 8px; /* Rounded corners for rows */
            box-shadow: 0 2px 5px rgba(0,0,0,0.1); /* Subtle shadow for cards */
            padding: 10px; /* Padding inside the row/card */
        }

        .relief-summary td,
        .class-timetable-section td,
        
            border-bottom: 1px solid #eee; /* Horizontal line between "cells" in the card */
            display: flex; /* CRITICAL: Use flexbox for label and value alignment within each cell */
            justify-content: space-between; /* Push label to left, value to right */
            align-items: center; /* Vertically center label and value */
            padding: 8px 0; /* Vertical padding within each cell */
            font-size: 0.95em; /* Readable font size */
            white-space: normal; /* Allow text to wrap naturally if long */
            overflow: hidden; /* Hide overflow of text in value */
            text-overflow: ellipsis; /* Add ellipsis if text is still too long after wrapping */
            word-break: break-word; /* Ensure long words break */
            height: auto; /* Adjust height based on content */
            min-height: 24px; /* Minimum height for a line */
            text-align: left; /* Align text within its flex container */
        }

        .relief-summary td:last-child,
        .class-timetable-section td:last-child,
        
            border-bottom: 0; /* No border for the last cell in a row/card */
        }

        /* Labels embedded directly in HTML with .mobile-label class - CRITICAL FOR DISPLAY */
        .relief-summary td .mobile-label,
        .class-timetable-section td .mobile-label,
        
            display: inline-block !important; /* CRITICAL: Force display on mobile */
            width: 40%; /* Allocate width for the label */
            min-width: 90px; /* Ensure labels have enough room */
            font-weight: bold;
            color: #555;
            text-align: left;
            margin-right: 10px; /* Space between label and value */
            white-space: nowrap; /* Keep label text on one line */
            overflow: hidden; /* Hide overflowing label text */
            text-overflow: ellipsis; /* Add ellipsis to truncated label text */
            flex-shrink: 0; /* Prevent label from shrinking */
            box-sizing: border-box;
        }

        /* Re-ensure general table cell appearance */
        /* These rules are inherited by default on mobile unless overridden */
        /* You can specifically add them if needed, but display:flex on td should manage this */
        /* .relief-summary td, .class-timetable-section td, #manage-users-table td {
            padding-left: 8px;
            position: static;
        } */
    }