/* =========================================
   Global Theme Variables (Root)
   ========================================= */
:root {
    /* Colors */
    --bg-color: #f1f5f9;
    --form-bg: #ffffff;
    --primary-dark: #0f172a;
    --primary-hover: #1e293b;
    --text-main: #334155;
    --text-muted: #64748b;
    --border-color: #cbd5e1;
    --input-bg: #f8fafc;
    --focus-ring: rgba(59, 130, 246, 0.2);
    --focus-border: #3b82f6;
    
    /* Font Sizes (Reduced for compact look) */
    --font-xs: 0.7rem;     /* 11px - for labels/errors */
    --font-sm: 0.8rem;     /* 13px - for inputs */
    --font-md: 0.9rem;     /* 14.5px - for buttons */
    --font-lg: 1.15rem;    /* 18px - for headers */

    /* Spacing & Layout */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 12px;
    --space-lg: 16px;
    --radius-sm: 4px;
    --radius-md: 6px;
}

/* =========================================
   Form Layout & 100vh Viewport Setup
   ========================================= */
body {
    margin: 0;
    
    padding: 0;
    background-color: var(--bg-color);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: var(--text-main);
    height: 100vh;
    overflow-x: hidden;
    
}

.content-wrapper {
    margin-left: 250px;
    display: flex;
    justify-content: center;
    min-height: calc(100vh - 60px);
    padding: var(--space-sm);
}

.form-container {
    width: 100%;
    max-width: 850px;
    max-height: 95vh; /* Prevents form from crossing screen height */
    background: var(--form-bg);
    padding: var(--space-lg) 24px;
    border-radius: var(--radius-md);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    overflow-y: auto; /* Internal scroll ONLY if viewed on very small mobile screens */
}

/* Custom minimal scrollbar for the form */
.form-container::-webkit-scrollbar { width: 5px; }
.form-container::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 10px; }

.form-header {
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-sm);
    border-bottom: 1px solid var(--border-color);
}

.form-header h2 {
    margin: 0;
    color: var(--primary-dark);
    font-size: var(--font-lg);
}

/* 2-Column Grid Setup */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-md) var(--space-lg); /* Reduced gap */
}

.full-width {
    grid-column: span 2;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    font-size: var(--font-xs);
    font-weight: 600;
    margin-bottom: var(--space-xs);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group input, 
.form-group textarea, 
.form-group select {
    padding: 6px 10px; /* Reduced padding */
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: var(--font-sm);
    background-color: var(--input-bg);
    transition: all 0.2s ease;
}

.form-group input:focus, 
.form-group textarea:focus, 
.form-group select:focus {
    outline: none;
    border-color: var(--focus-border);
    background-color: var(--form-bg);
    box-shadow: 0 0 0 3px var(--focus-ring);
}

.form-group textarea {
    resize: none;
    height: 45px; /* Shortened textarea to save vertical space */
}

/* Image Preview Inline with file input to save space */
.photo-upload-wrapper {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.current-photo-preview {
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    height: 35px;
    width: 35px;
    object-fit: cover;
}

.btn-submit {
    grid-column: span 2;
    padding: 8px 15px; /* Compact Button */
    background-color: var(--primary-dark);
    color: #ffffff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: var(--font-md);
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
    margin-top: var(--space-xs);
}

.btn-submit:hover {
    background-color: var(--primary-hover);
}

.error-msg {
    color: #ef4444;
    background: #fef2f2;
    padding: var(--space-sm);
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-sm);
    border: 1px solid #fecaca;
    font-size: var(--font-xs);
}
.error-msg p { margin: 2px 0; }

/* =========================================
   Data Table & List Styles
   ========================================= */
.table-wrapper {
    width: 100%;
    max-width: 1200px;
    margin: 10 auto;
    background: var(--form-bg);
    border-radius: var(--radius-md);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    max-height: 95vh; /* Prevents overflow beyond screen height */
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid var(--border-color);
}

.table-header h2 {
    margin: 0;
    color: var(--primary-dark);
    font-size: var(--font-lg);
}

.btn-add {
    background-color: var(--primary-dark);
    color: #ffffff;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-size: var(--font-sm);
    font-weight: 600;
    transition: background 0.2s;
}

.btn-add:hover { background-color: var(--primary-hover); color: white;}

.table-responsive {
    overflow-y: auto;
    overflow-x: auto;
    padding: 0 var(--space-md) var(--space-md) var(--space-md);
}

/* Custom scrollbar for the table */
.table-responsive::-webkit-scrollbar { width: 5px; height: 5px; }
.table-responsive::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 10px; }

.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: var(--space-sm);
}

.data-table th {
    background-color: var(--bg-color);
    color: var(--text-muted);
    font-size: var(--font-xs);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 10px;
    text-align: left;
    position: sticky;
    top: 0;
    z-index: 10;
}

.data-table td {
    padding: 10px;
    font-size: var(--font-sm);
    color: var(--text-main);
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.data-table tr:hover {
    background-color: #f8fafc;
}

/* Badges for Status */
.badge {
    padding: 4px 8px;
    border-radius: 20px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
}
.badge-active { background-color: #dcfce7; color: #166534; }
.badge-inactive { background-color: #fee2e2; color: #991b1b; }

/* Action Buttons */
.action-group {
    display: flex;
    gap: 5px;
}

.btn-action {
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.7rem;
    text-decoration: none;
    color: #fff;
    font-weight: 600;
    transition: opacity 0.2s;
}

.btn-action:hover { opacity: 0.8; }
.btn-view { background-color: #3b82f6; }
.btn-edit { background-color: #eab308; color: #854d0e; }
.btn-print { background-color: #64748b; }
.btn-delete { background-color: #ef4444; }

/* Alerts */
.alert-success {
    background: #dcfce7; color: #166534; padding: var(--space-sm) var(--space-lg);
    font-size: var(--font-sm); border-bottom: 1px solid #bbf7d0;
}

/* =========================================
   Student Avatar (Table Profile Picture)
   ========================================= */
.student-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #e2e8f0;
    display: block;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.avatar-placeholder {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background-color: #e2e8f0;
    color: var(--primary-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-sm);
    font-weight: 700;
    text-transform: uppercase;
    border: 2px solid #cbd5e1;
}

/* Adjust table cell for photo */
.td-photo {
    width: 50px;
    text-align: center;
}
/* =========================================
   Student Profile View Styles
   ========================================= */
.profile-card {
    width: 100%;
    max-width: 800px; /* Thoda chhota rakha hai compact look ke liye */
    margin: 0 auto;
    background: var(--form-bg);
    border-radius: var(--radius-md);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    padding: 30px;
    max-height: 95vh;
    overflow-y: auto;
}

/* Custom scrollbar for Profile Card */
.profile-card::-webkit-scrollbar { width: 5px; }
.profile-card::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 10px; }

.profile-header {
    display: flex;
    align-items: center;
    gap: 20px;
}

.profile-photo-large {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--bg-color);
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.profile-placeholder-large {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background-color: #e2e8f0;
    color: var(--primary-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 700;
    text-transform: uppercase;
    border: 3px solid var(--bg-color);
}

.profile-title h2 { margin: 0 0 5px 0; font-size: 1.5rem; color: var(--primary-dark); }
.profile-title p { margin: 0; color: var(--text-muted); font-size: var(--font-sm); display: flex; align-items: center; gap: 10px; }

.profile-actions { margin-left: auto; display: flex; gap: 10px; }

.btn-outline {
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-main);
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-decoration: none;
    font-size: var(--font-sm);
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: all 0.2s;
}

.btn-outline:hover { background: var(--bg-color); border-color: var(--text-muted); }

.profile-body {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-top: 25px;
    padding-top: 25px;
    border-top: 1px solid var(--border-color);
}

.detail-group { display: flex; flex-direction: column; }
.detail-group label { font-size: var(--font-xs); color: var(--text-muted); text-transform: uppercase; font-weight: 600; margin-bottom: 4px; letter-spacing: 0.5px; }
.detail-group .value { font-size: var(--font-sm); color: var(--text-main); font-weight: 500; }
.detail-full { grid-column: span 2; }

/* Print Media Query - Optimized for Paper */
@media print {
    body { background: white; height: auto; overflow: visible; }
    .content-wrapper { padding: 0; min-height: auto; display: block; }
    .profile-card { box-shadow: none; max-width: 100%; border: none; padding: 0; max-height: none; overflow: visible; }
    /* Hide Sidebars, Headers and Buttons while printing */
    .sidebar, .topbar, .profile-actions, .admin-sidebar, header { display: none !important; }
    .profile-body { border-top: 2px solid #000; margin-top: 20px; padding-top: 20px; }
}

@media (max-width: 600px) {
    .profile-header { flex-direction: column; text-align: center; }
    .profile-actions { margin: 15px auto 0 auto; }
    .profile-body { grid-template-columns: 1fr; gap: 15px; }
    .detail-full { grid-column: span 1; }
}

@media (max-width: 768px) {
    .form-grid { grid-template-columns: 1fr; gap: var(--space-sm); }
    .full-width, .btn-submit { grid-column: span 1; }
    .form-container { max-height: 100vh; padding: 15px; border-radius: 0; }
}