:root {
    --primary: #2563eb;
    --secondary: #059669;
    --danger: #dc2626;
    --warning: #d97706;
    --dark: #1e293b;
    --light: #f8fafc;
    --gray: #64748b;
    --border: #e2e8f0;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}

html, body {
    overflow-x: hidden;
    max-width: 100vw;
}

body {
    background-color: #f1f5f9;
    color: #334155;
    line-height: 1.6;
    font-size: 16px;
    width: 100%;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 16px;
    width: 100%;
}

/* Header Styles */
header {
    background-color: white;
    border-bottom: 1px solid var(--border);
    padding: 12px 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    width: 100%;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

/* Logo & Menu Toggle */
.logo-container {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    color: var(--dark);
    flex-shrink: 0;
    margin-right: 12px;
    order: -1;
}

.logo {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: white;
    font-size: 14px;
    flex-shrink: 0;
    background: linear-gradient(135deg, #2563eb, #3b82f6);
}

.responsive-image {
    max-width: 100%;
    height: auto;
}

.school-name {
    font-size: 18px;
    font-weight: 600;
    color: var(--dark);
    white-space: nowrap;
    overflow: visible;
    text-overflow: unset;
    flex-shrink: 0;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    flex-shrink: 0;
}

/* Login Form Styles */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 80vh;
    padding: 20px 0;
    width: 100%;
}

.login-form {
    background: white;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    width: 100%;
    max-width: 400px;
    border: 1px solid var(--border);
}

.login-form h2 {
    text-align: center;
    margin-bottom: 24px;
    color: var(--dark);
    font-size: 24px;
    word-wrap: break-word;
}

.form-group {
    margin-bottom: 20px;
    width: 100%;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: var(--dark);
    font-size: 14px;
}

.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.2s;
    max-width: 100%;
}

.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.full-width-input {
    width: 100% !important;
}

/* Button Styles */
.btn {
    display: inline-block;
    padding: 12px 20px;
    background-color: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    transition: all 0.2s;
    text-align: center;
    min-height: 44px;
    width: 100%;
    max-width: 100%;
    text-decoration: none;
    line-height: 1.2;
}

.btn:hover {
    background-color: #1d4ed8;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.btn:active {
    transform: translateY(0);
}

.btn-secondary {
    background-color: var(--secondary);
}

.btn-secondary:hover {
    background-color: #047857;
}

.btn-danger {
    background-color: var(--danger);
}

.btn-danger:hover {
    background-color: #b91c1c;
}

.btn-warning {
    background-color: var(--warning);
}

.btn-warning:hover {
    background-color: #b45309;
}

/* Button kecil untuk aksi tabel */
.btn-small {
    padding: 6px 12px !important;
    font-size: 12px !important;
    min-height: 32px !important;
    width: auto !important;
    margin: 2px !important;
}

/* Tombol logout khusus */
#logoutBtn {
    margin: 20px 16px !important;
    width: calc(100% - 32px) !important;
    display: block !important;
    position: static !important;
    z-index: 1000 !important;
    cursor: pointer !important;
    pointer-events: auto !important;
}

/* Dashboard Styles */
.dashboard {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 24px;
    margin-top: 24px;
    min-height: calc(100vh - 80px);
    width: 100%;
}

.sidebar {
    background: white;
    border-radius: 12px;
    padding: 0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    border: 1px solid var(--border);
    height: fit-content;
    position: sticky;
    top: 90px;
    width: 100%;
}

.sidebar-header {
    display: none;
    padding: 16px;
    border-bottom: 1px solid var(--border);
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.sidebar-header h3 {
    margin: 0;
    font-size: 18px;
}

.close-sidebar {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--gray);
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar ul {
    list-style: none;
    padding: 16px 0;
    width: 100%;
}

.sidebar li {
    margin-bottom: 4px;
    width: 100%;
}

.sidebar a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    text-decoration: none;
    color: var(--dark);
    border-radius: 0;
    transition: all 0.2s;
    font-size: 15px;
    border-left: 3px solid transparent;
    width: 100%;
}

.sidebar a:hover, .sidebar a.active {
    background-color: #f1f5f9;
    border-left-color: var(--primary);
    color: var(--primary);
}

.main-content {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    border: 1px solid var(--border);
    min-height: 600px;
    width: 100%;
    overflow: hidden;
}

.content-section {
    display: none;
    width: 100%;
}

.content-section.active {
    display: block;
}

/* Table Styles */
.table-container {
    width: 100%;
    overflow-x: auto;
    position: relative;
    -webkit-overflow-scrolling: touch;
    margin: 16px 0;
}

.table-container table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    min-width: 600px;
}

.table-container th, 
.table-container td {
    padding: 12px 8px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.table-container th {
    background-color: #f8fafc;
    font-weight: 600;
    color: var(--dark);
    position: sticky;
    top: 0;
}

table tr:hover {
    background-color: #f8fafc;
}

/* Sortable table headers */
.sortable-header {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 20px;
    transition: background-color 0.2s;
}

.sortable-header:hover {
    background-color: #e2e8f0 !important;
}

.sortable-header.active {
    background-color: #dbeafe !important;
    color: #1e40af;
}

.sort-arrow {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-weight: bold;
}

/* Form Styles */
.form-container {
    max-width: 600px;
    margin: 0 auto;
    width: 100%;
}

.radio-group {
    display: flex;
    gap: 20px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 8px 0;
    white-space: nowrap;
}

.radio-label input {
    width: auto;
}

/* Alert Styles */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 14px;
    width: 100%;
}

.alert-success {
    background-color: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.alert-error {
    background-color: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

/* Card Styles */
.card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    border: 1px solid var(--border);
    margin-bottom: 20px;
    width: 100%;
    overflow: hidden;
}

.card h3 {
    margin-bottom: 16px;
    color: var(--dark);
    font-size: 18px;
    word-wrap: break-word;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
    width: 100%;
}

.stat-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    border: 1px solid var(--border);
    width: 100%;
}

.stat-card h3 {
    font-size: 28px;
    margin-bottom: 8px;
    color: var(--primary);
}

.stat-card p {
    color: var(--gray);
    font-size: 14px;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.modal-content {
    background: white;
    padding: 24px;
    border-radius: 12px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    width: 100%;
}

.close-modal {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--gray);
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Status badges */
.status-badge {
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    display: inline-block;
}

.status-hadir {
    background-color: #f0fdf4;
    color: #166534;
}

.status-sakit {
    background-color: #fffbeb;
    color: #92400e;
}

.status-izin {
    background-color: #eff6ff;
    color: #1e40af;
}

.status-alfa {
    background-color: #fef2f2;
    color: #991b1b;
}

.status-admin {
    background-color: #f3e8ff;
    color: #7c3aed;
}

.status-guru {
    background-color: #ecfdf5;
    color: #047857;
}

/* Student list for absence input */
.student-list {
    margin: 16px 0;
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    width: 100%;
}

.student-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
}

.student-item:last-child {
    border-bottom: none;
}

.student-item > div {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* Progress bar */
.progress-bar {
    height: 8px;
    background-color: #e2e8f0;
    border-radius: 4px;
    margin-top: 8px;
    overflow: hidden;
    width: 100%;
    position: relative;
}

.progress-fill {
    height: 100%;
    background-color: var(--secondary);
    border-radius: 4px;
    transition: width 0.3s;
}

/* Filter controls */
.filter-controls {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    align-items: center;
    width: 100%;
}

.filter-controls > * {
    flex: 1;
    min-width: 150px;
}

.filter-controls select, .filter-controls input {
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    min-height: 44px;
    flex: 1;
    min-width: 150px;
}

.filter-controls .btn {
    flex: 0 0 auto;
    width: auto;
    min-width: 100px;
}

/* Demo accounts */
.demo-accounts {
    margin-top: 20px;
    padding: 16px;
    background-color: #f8fafc;
    border-radius: 8px;
    font-size: 13px;
    border: 1px solid var(--border);
    width: 100%;
}

.demo-accounts h4 {
    margin-bottom: 8px;
    color: var(--dark);
}

.demo-accounts p {
    margin-bottom: 4px;
    line-height: 1.4;
    word-wrap: break-word;
}

/* Import/Export Styles */
.export-options, .import-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.export-option, .import-option {
    background: #f8fafc;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.export-option h4, .import-option h4 {
    margin-bottom: 8px;
    color: #1e293b;
}

.export-option p, .import-option p {
    color: #64748b;
    margin-bottom: 15px;
    font-size: 14px;
}

.import-option ul {
    margin: 10px 0;
    padding-left: 20px;
}

.import-option li {
    margin-bottom: 4px;
    font-size: 13px;
}

/* Progress Bar untuk Import */
.progress-container {
    margin-top: 15px;
    background: #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
}

.progress-bar-import {
    height: 20px;
    background: linear-gradient(90deg, #2563eb, #3b82f6);
    border-radius: 10px;
    transition: width 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
    font-weight: bold;
}

/* Rank badges untuk ranking guru */
.rank-badge {
    display: inline-block;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    text-align: center;
    line-height: 30px;
    font-weight: bold;
    color: white;
}

.rank-1 {
    background: linear-gradient(135deg, #FFD700, #FFA500);
}

.rank-2 {
    background: linear-gradient(135deg, #C0C0C0, #A0A0A0);
}

.rank-3 {
    background: linear-gradient(135deg, #CD7F32, #A56C27);
}

/* Style untuk multiple select */
select[multiple] {
    min-height: 150px;
    padding: 8px;
}

select[multiple] option {
    padding: 8px 12px;
    margin: 2px 0;
    border-radius: 4px;
    cursor: pointer;
}

select[multiple] option:hover {
    background-color: #e2e8f0;
}

select[multiple] option:checked {
    background-color: #2563eb;
    color: white;
}

/* Style untuk notification */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 16px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    z-index: 10000;
    max-width: 400px;
    animation: slideIn 0.3s ease;
}

.notification-success {
    background-color: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.notification-error {
    background-color: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

.notification-info {
    background-color: #eff6ff;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.notification-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.notification-content button {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    margin-left: 10px;
    color: inherit;
}

/* Form actions untuk modal */
.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

.form-actions .btn {
    width: auto;
    min-width: 100px;
}

/* Disabled input styles */
.disabled-input {
    background-color: #f8f9fa;
    color: #6c757d;
    cursor: not-allowed;
    border-color: #e9ecef;
}

.form-help {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    color: #6c757d;
}

/* Kelas section untuk guru per kelas */
.kelas-section {
    margin-bottom: 20px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #f8fafc;
}

.kelas-section h4 {
    margin-bottom: 12px;
    color: var(--dark);
    font-size: 16px;
}

/* Ranking badges */
.ranking-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-weight: bold;
    font-size: 12px;
    color: white;
}

.ranking-1 {
    background: linear-gradient(135deg, #FFD700, #FFA500);
}

.ranking-2 {
    background: linear-gradient(135deg, #C0C0C0, #A0A0A0);
}

.ranking-3 {
    background: linear-gradient(135deg, #CD7F32, #A56C27);
}

.ranking-4, .ranking-5, .ranking-6, .ranking-7, .ranking-8, .ranking-9, .ranking-10 {
    background: linear-gradient(135deg, #6b7280, #9ca3af);
}

/* Fix untuk tombol yang tidak bisa diklik */
.menu-toggle, 
.close-sidebar, 
.close-modal, 
#logoutBtn,
.btn {
    cursor: pointer !important;
    pointer-events: auto !important;
    z-index: 1000 !important;
    position: relative !important;
}

/* Pastikan tombol visible */
.btn:not([style*="display: none"]) {
    display: inline-block !important;
}

/* Pastikan sidebar dapat diklik ketika aktif */
.sidebar.active {
    z-index: 1001 !important;
}

/* Pastikan modal dapat diklik */
.modal {
    z-index: 1002 !important;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 0 12px;
    }
    
    .sortable-header {
        font-size: 12px;
        padding: 8px 4px 8px 4px;
    }
    
    .sort-arrow {
        right: 4px;
    }
    
    .menu-toggle {
        display: block;
    }
    
    .school-name {
        font-size: 16px;
        white-space: normal;
    }
    
    .dashboard {
        grid-template-columns: 1fr;
        gap: 0;
        margin-top: 16px;
    }
    
    .sidebar {
        position: fixed;
        top: 0;
        left: -100%;
        width: 100%;
        height: 100vh;
        z-index: 1000;
        border-radius: 0;
        transition: left 0.3s;
        box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    }
    
    .sidebar.active {
        left: 0;
    }
    
    .sidebar-header {
        display: flex;
    }
    
    .main-content {
        padding: 16px;
        border-radius: 0;
        border: none;
        box-shadow: none;
        min-height: auto;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .stat-card {
        padding: 16px;
    }
    
    .filter-controls {
        flex-direction: column;
    }
    
    .filter-controls select, .filter-controls input {
        width: 100%;
        min-width: auto;
    }
    
    .filter-controls .btn {
        width: 100%;
    }
    
    .table-container {
        font-size: 12px;
    }
    
    .table-container th, 
    .table-container td {
        padding: 8px 4px;
    }
    
    .btn-small {
        padding: 4px 8px !important;
        font-size: 11px !important;
        min-height: 28px !important;
    }
    
    /* Pastikan kolom aksi cukup lebar untuk tombol */
    table td:last-child {
        min-width: 120px;
    }
    
    .login-form {
        padding: 20px;
        margin: 0 10px;
    }
    
    .card {
        padding: 16px;
    }
    
    .radio-group {
        flex-direction: column;
        gap: 8px;
    }
    
    .form-container {
        padding: 0 8px;
    }
    
    .export-options, .import-options {
        grid-template-columns: 1fr;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .form-actions .btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .user-info {
        flex-direction: column;
        align-items: flex-end;
        gap: 4px;
        font-size: 12px;
    }
    
    .student-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .student-item > div {
        width: 100%;
        justify-content: space-between;
    }
    
    .modal-content {
        padding: 16px;
        margin: 10px;
    }
    
    .school-name {
        font-size: 14px;
    }
    
    .logo {
        width: 35px;
        height: 35px;
        font-size: 12px;
    }
    
    table {
        min-width: 400px;
    }
    
    .btn {
        font-size: 14px;
        padding: 10px 16px;
    }
    
    .notification {
        right: 10px;
        left: 10px;
        max-width: none;
    }
}

/* Touch optimizations */
@media (hover: none) and (pointer: coarse) {
    .btn {
        min-height: 48px;
        font-size: 16px;
    }
    
    .sidebar a {
        padding: 16px 20px;
        min-height: 54px;
    }
    
    .form-group input, .form-group select, .form-group textarea {
        font-size: 16px;
        min-height: 48px;
    }
    
    /* Prevent zoom on iOS */
    select, input, textarea {
        font-size: 16px;
    }
}

/* Ensure all interactive elements are properly sized for touch */
button, .btn, input[type="checkbox"], input[type="radio"] {
    min-height: 44px;
    min-width: 44px;
}

/* Fix for long text in tables */
table td {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Additional responsive fixes */
@media (max-width: 360px) {
    .container {
        padding: 0 8px;
    }
    
    .login-form {
        padding: 16px;
    }
    
    .card {
        padding: 12px;
    }
    
    .stats-grid {
        gap: 8px;
    }
    
    .stat-card {
        padding: 12px;
    }
    
    .stat-card h3 {
        font-size: 24px;
    }
}

/* Loading states */
.loading {
    opacity: 0.7;
    pointer-events: none;
}

/* Success animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.alert-success {
    animation: fadeIn 0.3s ease;
}

/* Custom scrollbar */
.table-container::-webkit-scrollbar {
    height: 8px;
}

.table-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.table-container::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.table-container::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

.student-list::-webkit-scrollbar {
    width: 6px;
}

.student-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.student-list::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.modal-content::-webkit-scrollbar {
    width: 6px;
}

.modal-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.modal-content::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}