/* School Management System - Premium Responsive CSS */
/* Import Poppins Font */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');

/* CSS Variables for theming */
:root {
    --primary-color: #e43a21;
    --secondary-color: #000000;
    --accent-color: #e43a21;
    --success-color: #51CF66;
    --warning-color: #FFA94D;
    --danger-color: #FF6B6B;
    --dark-bg: #1a1a2e;
    --dark-card: #16213e;
    --light-bg: #f8f9fa;
    --light-card: #ffffff;
    --text-dark: #2d3748;
    --text-light: #ffffff;
    --text-muted: #718096;
    --border-color: #e2e8f0;
    --shadow: 0 0.25rem 0.375rem rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 0.625rem 1.5625rem rgba(0, 0, 0, 0.15);
    --gradient-primary: linear-gradient(135deg, #e43a21 0%, #000000 100%);
    --gradient-secondary: linear-gradient(135deg, #000000 0%, #e43a21 100%);
    --gradient-success: linear-gradient(135deg, #51CF66 0%, #4facfe 100%);
    --font-primary: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --transition: all 0.3s ease;
}

/* Dark mode variables */
body.dark-mode {
    --light-bg: #050505;
    --light-card: #16213e;
    --text-dark: #1d43cf;
    --border-color: #2d3748;
    --text-muted: #a0aec0;
}

/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-primary);
    background-color: var(--light-bg);
    color: var(--text-dark);
    line-height: 1.6;
    transition: var(--transition);
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.2;
    margin-bottom: 1rem;
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.75rem; }
h4 { font-size: 1.5rem; }
h5 { font-size: 1.25rem; }
h6 { font-size: 1rem; }

p {
    margin-bottom: 1rem;
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--secondary-color);
}

/* Container and Layout */
.container {
    width: 100%;
    max-width: 75rem;
    margin: 0 auto;
    padding: 0 1.25rem;
}

.container-fluid {
    width: 100%;
    padding: 0 1.25rem;
}

/* Grid System */
.row {
    display: flex;
    flex-wrap: wrap;
    margin: 0 -0.625rem;
}

.col {
    flex: 1;
    padding: 0 0.625rem;
}

.col-1 { flex: 0 0 8.333%; max-width: 8.333%; }
.col-2 { flex: 0 0 16.666%; max-width: 16.666%; }
.col-3 { flex: 0 0 25%; max-width: 25%; }
.col-4 { flex: 0 0 33.333%; max-width: 33.333%; }
.col-5 { flex: 0 0 41.666%; max-width: 41.666%; }
.col-6 { flex: 0 0 50%; max-width: 50%; }
.col-7 { flex: 0 0 58.333%; max-width: 58.333%; }
.col-8 { flex: 0 0 66.666%; max-width: 66.666%; }
.col-9 { flex: 0 0 75%; max-width: 75%; }
.col-10 { flex: 0 0 83.333%; max-width: 83.333%; }
.col-11 { flex: 0 0 91.666%; max-width: 91.666%; }
.col-12 { flex: 0 0 100%; max-width: 100%; }

/* Page Header */
.page-header {
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 0.125rem solid var(--border-color);
}

.page-title {
    font-size: 2rem;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 0.5rem;
}

.page-header .text-muted {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Card Component */
.card {
    background: var(--light-card);
    border-radius: 0.75rem;
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-0.125rem);
}

.card-header {
    padding-bottom: 1rem;
    margin-bottom: 1rem;
    border-bottom: 0.125rem solid var(--border-color);
}

.card-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-dark);
}

.card-body {
    padding: 0;
}

.card-footer {
    padding-top: 1rem;
    margin-top: 1rem;
    border-top: 0.0625rem solid var(--border-color);
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 500;
    text-align: center;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-0.125rem);
    box-shadow: 0 0.25rem 0.75rem rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-warning {
    background: var(--warning-color);
    color: white;
}

.btn-outline {
    background: transparent;
    border: 0.125rem solid var(--primary-color);
    color: var(--primary-color);
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.btn-lg {
    padding: 1rem 2rem;
    font-size: 1.125rem;
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-dark);
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: 0.125rem solid var(--border-color);
    border-radius: 0.5rem;
    background: var(--light-card);
    color: var(--text-dark);
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.1875rem rgba(74, 144, 226, 0.1);
}

.form-control::placeholder {
    color: var(--text-muted);
}

select.form-control {
    cursor: pointer;
}

textarea.form-control {
    min-height: 6.25rem;
    resize: vertical;
}

.form-check {
    display: flex;
    align-items: center;
    margin-bottom: 0.5rem;
}

.form-check input {
    margin-right: 0.5rem;
    width: 1.125rem;
    height: 1.125rem;
    cursor: pointer;
}

/* Tables */
.table-responsive {
    overflow-x: auto;
    margin-bottom: 1.5rem;
    -webkit-overflow-scrolling: touch;
    border-radius: 0.75rem;
    box-shadow: var(--shadow);
}

.table-responsive::-webkit-scrollbar {
    height: 0.5rem;
}

.table-responsive::-webkit-scrollbar-track {
    background: var(--light-bg);
    border-radius: 0.25rem;
}

.table-responsive::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 0.25rem;
}

.table-responsive::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-color);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--light-card);
    border-radius: 0.75rem;
    overflow: hidden;
}

thead {
    background: var(--gradient-primary);
    color: white;
}

th, td {
    padding: 1rem;
    text-align: left;
    border-bottom: 0.0625rem solid var(--border-color);
}

th {
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.875rem;
    letter-spacing: 0.03125rem;
}

tbody tr:hover {
    background-color: rgba(74, 144, 226, 0.05);
}

tbody tr:last-child td {
    border-bottom: none;
}

/* Responsive Table - Mobile Stacked Layout */
@media (max-width: 768px) {
    .table-responsive {
        overflow-x: visible;
    }

    table {
        min-width: 100%;
    }

    thead {
        display: none;
    }

    tbody tr {
        display: block;
        margin-bottom: 1rem;
        border: 0.0625rem solid var(--border-color);
        border-radius: 0.5rem;
        overflow: hidden;
    }

    td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.75rem 1rem;
        border-bottom: 0.0625rem solid var(--border-color);
        white-space: normal;
        text-align: right;
    }

    td:last-child {
        border-bottom: none;
    }

    td::before {
        content: attr(data-label);
        font-weight: 600;
        text-transform: uppercase;
        font-size: 0.75rem;
        color: var(--text-muted);
        text-align: left;
        flex: 1;
        padding-right: 1rem;
    }

    td:empty::before {
        display: none;
    }
}

/* Navigation */
.navbar {
    background: var(--gradient-primary);
    padding: 0.5rem 0;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.navbar-brand {
    font-size: 1.5rem;
    font-weight: 700;
    color: white;
}

.navbar-nav {
    display: flex;
    list-style: none;
    gap: 2rem;
    align-items: center;
}

.nav-link {
    color: white;
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    transition: var(--transition);
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Sidebar */
.sidebar {
    width: 16.25rem;
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    background: var(--gradient-primary);
    padding: 2rem 0;
    overflow-y: auto;
    transition: var(--transition);
    z-index: 999;
}

.sidebar-header {
    padding: 0 1.5rem 2rem;
    color: white;
    border-bottom: 0.0625rem solid rgba(255, 255, 255, 0.1);
}

.sidebar-menu {
    list-style: none;
    padding: 1rem 0;
}

.sidebar-menu li {
    margin-bottom: 0.5rem;
}

.sidebar-menu a {
    display: flex;
    align-items: center;
    padding: 0.875rem 1.5rem;
    color: white;
    transition: var(--transition);
    position: relative;
}

.sidebar-menu a:hover,
.sidebar-menu a.active {
    background: rgba(255, 255, 255, 0.1);
    border-left: 0.25rem solid white;
}

.sidebar-menu i {
    margin-right: 1rem;
    font-size: 1.25rem;
}

/* Main Content with Sidebar */
.main-wrapper {
    display: flex;
}

.main-content {
    flex: 1;
    margin-left: 16.25rem;
    padding: 2rem;
    min-height: 100vh;
    transition: var(--transition);
}

/* Dashboard Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}

/* Tablet: 2 columns */
@media (max-width: 992px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Mobile: 1 column */
@media (max-width: 576px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

.stat-card {
    background: var(--light-card);
    border-radius: 0.75rem;
    padding: 1.5rem;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-0.3125rem);
    box-shadow: var(--shadow-lg);
}

.stat-icon {
    width: 3.75rem;
    height: 3.75rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: white;
}

.stat-icon.primary { background: var(--gradient-primary); }
.stat-icon.success { background: var(--gradient-success); }
.stat-icon.warning { background: var(--warning-color); }
.stat-icon.danger { background: var(--danger-color); }

.stat-details h3 {
    font-size: 2rem;
    margin-bottom: 0.25rem;
}

.stat-details p {
    color: var(--text-muted);
    margin: 0;
}

/* Alerts */
.alert {
    padding: 1rem 1.5rem;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    border-left: 0.25rem solid;
}

.alert-success {
    background: rgba(81, 207, 102, 0.1);
    border-color: var(--success-color);
    color: var(--success-color);
}

.alert-danger {
    background: rgba(255, 107, 107, 0.1);
    border-color: var(--danger-color);
    color: var(--danger-color);
}

.alert-warning {
    background: rgba(255, 169, 77, 0.1);
    border-color: var(--warning-color);
    color: var(--warning-color);
}

.alert-info {
    background: rgba(74, 144, 226, 0.1);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 1.25rem;
    color: white;
}

.badge-primary { background: var(--primary-color); }
.badge-success { background: var(--success-color); }
.badge-danger { background: var(--danger-color); }
.badge-warning { background: var(--warning-color); }
.badge-secondary { background: var(--secondary-color); }

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--light-card);
    border-radius: 0.75rem;
    padding: 2rem;
    max-width: 37.5rem;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateY(-3.125rem);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: var(--text-muted);
}

/* Loading Spinner */
.spinner {
    width: 2.5rem;
    height: 2.5rem;
    border: 0.25rem solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

/* Dark Mode Toggle */
.dark-mode-toggle {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 3.0rem;
    height: 3.0rem;
    border-radius: 50%;
    background: var(--gradient-primary);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    font-size: 1.5rem;
    transition: var(--transition);
    z-index: 998;
}

.dark-mode-toggle:hover {
    transform: scale(1.1);
}

/* Utilities */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }
.p-1 { padding: 0.5rem; }
.p-2 { padding: 1rem; }
.p-3 { padding: 1.5rem; }
.p-4 { padding: 2rem; }
.d-none { display: none; }
.d-block { display: block; }
.d-flex { display: flex; }
.justify-between { justify-content: space-between; }
.align-center { align-items: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.gap-3 { gap: 1.5rem; }

/* Responsive Design */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .col-md-1 { flex: 0 0 8.333%; max-width: 8.333%; }
    .col-md-2 { flex: 0 0 16.666%; max-width: 16.666%; }
    .col-md-3 { flex: 0 0 25%; max-width: 25%; }
    .col-md-4 { flex: 0 0 33.333%; max-width: 33.333%; }
    .col-md-5 { flex: 0 0 41.666%; max-width: 41.666%; }
    .col-md-6 { flex: 0 0 50%; max-width: 50%; }
    .col-md-7 { flex: 0 0 58.333%; max-width: 58.333%; }
    .col-md-8 { flex: 0 0 66.666%; max-width: 66.666%; }
    .col-md-9 { flex: 0 0 75%; max-width: 75%; }
    .col-md-10 { flex: 0 0 83.333%; max-width: 83.333%; }
    .col-md-11 { flex: 0 0 91.666%; max-width: 91.666%; }
    .col-md-12 { flex: 0 0 100%; max-width: 100%; }
}

@media (max-width: 768px) {
    html {
        font-size: 14px;
    }

    h1 { font-size: 2rem; }
    h2 { font-size: 1.75rem; }
    h3 { font-size: 1.5rem; }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .navbar-nav {
        flex-direction: column;
        gap: 0.5rem;
    }

    .col-sm-1, .col-sm-2, .col-sm-3, .col-sm-4, .col-sm-5, .col-sm-6,
    .col-sm-7, .col-sm-8, .col-sm-9, .col-sm-10, .col-sm-11, .col-sm-12 {
        flex: 0 0 100%;
        max-width: 100%;
    }

    .main-content {
        padding: 1rem;
    }

    /* Enhanced mobile table styling */
    table {
        font-size: 0.875rem;
    }

    th, td {
        padding: 0.75rem 0.5rem;
        font-size: 0.8rem;
    }

    /* Better button spacing on mobile */
    .btn {
        font-size: 0.875rem;
        padding: 0.625rem 1.25rem;
    }

    .btn-sm {
        padding: 0.375rem 0.75rem;
        font-size: 0.75rem;
    }

    /* Improve form spacing on mobile */
    .form-group {
        margin-bottom: 1rem;
    }

    /* Better modal on mobile */
    .modal-content {
        padding: 1.5rem;
        max-height: 85vh;
    }
}

@media (max-width: 480px) {
    html {
        font-size: 13px;
    }

    .btn {
        width: 100%;
        margin-bottom: 0.5rem;
    }

    .modal-content {
        width: 95%;
        padding: 1rem;
    }
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.fade-in {
    animation: fadeIn 0.5s ease;
}

.slide-in-right {
    animation: slideInRight 0.5s ease;
}

/* Print Styles */
@media print {
    .sidebar,
    .dark-mode-toggle,
    .btn,
    .navbar {
        display: none !important;
    }

    .main-content {
        margin-left: 0;
    }
}