* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Malgun Gothic', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

.app-container {
    max-width: 375px;
    margin: 0 auto;
    background: white;
    min-height: 100vh;
    position: relative;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
}

/* 헤더 */
.header {
    background: linear-gradient(135deg, #4FC3F7 0%, #29B6F6 100%);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.header h1 {
    font-size: 18px;
    font-weight: bold;
}

.school-name-display {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    padding: 8px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

/* 헤더 버튼 그룹 */
.header-buttons {
    display: flex;
    gap: 10px;
    align-items: center;
}

.logout-btn,
.refresh-btn,
.back-btn {
    background: none;
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.logout-btn:hover,
.refresh-btn:hover,
.back-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Refresh button animation on click */
.refresh-btn:active {
    transform: rotate(180deg);
    transition: transform 0.3s ease;
}

.logout-btn {
    opacity: 0.9;
}

/* Back button specific styling */
.back-btn {
    font-size: 16px;
    padding: 8px 12px;
    border-radius: 8px;
    font-weight: 500;
}

.back-btn:active {
    background: rgba(255, 255, 255, 0.2);
}

/* 탭 네비게이션 */
.tab-navigation {
    display: flex;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
}

.tab-btn {
    flex: 1;
    padding: 15px 10px;
    border: none;
    background: none;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s;
    border-bottom: 3px solid transparent;
}

.tab-btn.active {
    background: white;
    border-bottom-color: #4FC3F7;
    color: #4FC3F7;
    font-weight: bold;
}

/* 메인 콘텐츠 */
.main-content {
    padding: 20px;
    min-height: calc(100vh - 140px);
}

/* 온보딩 화면 */
.onboarding {
    text-align: center;
    padding: 60px 20px;
}

.onboarding h1 {
    color: #4FC3F7;
    font-size: 28px;
    margin-bottom: 20px;
}

.onboarding .welcome-text {
    font-size: 18px;
    margin-bottom: 40px;
    color: #666;
}

.feature-list {
    text-align: left;
    margin: 40px 0;
}

.feature-item {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
    font-size: 16px;
}

.feature-item .emoji {
    font-size: 20px;
    margin-right: 15px;
}

/* 버튼 스타일 */
.btn {
    display: inline-block;
    padding: 15px 30px;
    border: none;
    border-radius: 25px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s;
    text-decoration: none;
    text-align: center;
    font-weight: bold;
}

.btn-primary {
    background: linear-gradient(135deg, #4FC3F7 0%, #29B6F6 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(79, 195, 247, 0.4);
}

.btn-secondary {
    background: #FFA726;
    color: white;
}

.btn-success {
    background: #66BB6A;
    color: white;
}

.btn-danger {
    background: #EF5350;
    color: white;
}

.btn-small {
    padding: 8px 16px;
    font-size: 14px;
}

/* 카드 스타일 */
.card {
    background: white;
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 15px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    border: 1px solid #f0f0f0;
}

.card-header {
    display: flex;
    justify-content: between;
    align-items: center;
    margin-bottom: 15px;
}

.card-title {
    font-size: 18px;
    font-weight: bold;
    color: #333;
}

/* 통계 카드 */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 20px;
}

.stat-card {
    background: linear-gradient(135deg, #FF9800 0%, #FFB74D 100%);
    color: white;
    padding: 20px;
    border-radius: 15px;
    text-align: center;
}

.stat-number {
    font-size: 32px;
    font-weight: bold;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 14px;
    opacity: 0.9;
}

/* 학생 목록 */
.student-list {
    margin-top: 20px;
}

.student-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
    margin-bottom: 10px;
}

.student-info {
    flex: 1;
}

.student-name {
    font-weight: bold;
    margin-bottom: 5px;
}

.student-status {
    font-size: 14px;
    color: #666;
}

.status-badge {
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: bold;
}

.status-present {
    background: #C8E6C9;
    color: #2E7D32;
}

.status-late {
    background: #FFE0B2;
    color: #F57C00;
}

.status-absent {
    background: #FFCDD2;
    color: #C62828;
}

/* QR 코드 */
.qr-container {
    text-align: center;
    padding: 40px 20px;
}

.qr-code {
    width: 200px;
    height: 200px;
    background: #f0f0f0;
    border: 3px dashed #4FC3F7;
    border-radius: 15px;
    margin: 20px auto;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: #666;
}

/* 폼 스타일 */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: #333;
}

.form-input,
.form-select {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    font-size: 16px;
    transition: all 0.3s;
}

.form-input:focus,
.form-select:focus {
    outline: none;
    border-color: #4FC3F7;
}

/* Date picker - iOS Safari overflow fix, 75% width, center aligned */
input[type="date"] {
    max-width: 75%;
    width: 75%;
    box-sizing: border-box;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    display: block;
    margin: 0 auto;
    padding: 12px 15px;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    font-size: 16px;
}

/* 알림 스타일 */
.notification {
    display: flex;
    align-items: center;
    padding: 15px;
    background: #E3F2FD;
    border-left: 4px solid #2196F3;
    border-radius: 5px;
    margin-bottom: 15px;
}

.notification .emoji {
    font-size: 20px;
    margin-right: 10px;
}

/* 로딩 스피너 */
.loading {
    display: none;
    text-align: center;
    padding: 40px;
}

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

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

    100% {
        transform: rotate(360deg);
    }
}

/* 숨김 처리 */
.hidden {
    display: none !important;
}

/* Privacy Consent Modal */
.privacy-consent-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.privacy-consent-modal.active {
    opacity: 1 !important;
    pointer-events: all !important;
}

.privacy-consent-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.privacy-consent-container {
    position: relative;
    background: white;
    border-radius: 20px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    margin: 20px;
}

.privacy-consent-header {
    padding: 20px;
    border-bottom: 2px solid #e9ecef;
    background: #f8f9fa;
}

.privacy-consent-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: #333;
    text-align: center;
}

.privacy-consent-body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 20px;
    -webkit-overflow-scrolling: touch;
}

.privacy-consent-body::-webkit-scrollbar {
    width: 8px;
}

.privacy-consent-body::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.privacy-consent-body::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 10px;
}

.privacy-consent-body::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.privacy-consent-description {
    font-size: 14px;
    color: #666;
    line-height: 1.6;
    margin: 0 0 20px 0;
    text-align: center;
}

.privacy-consent-content .privacy-section {
    margin-bottom: 20px;
}

.privacy-consent-content .privacy-section:last-child {
    margin-bottom: 0;
}

.privacy-consent-content .privacy-heading {
    font-size: 15px;
    font-weight: 700;
    color: #333;
    margin: 0 0 10px 0;
    padding-bottom: 8px;
    border-bottom: 2px solid #e9ecef;
}

.privacy-consent-content .privacy-text {
    font-size: 13px;
    color: #666;
    line-height: 1.8;
    margin: 0;
    padding-left: 8px;
}

.privacy-consent-content .privacy-items {
    list-style: none;
    padding: 0;
    margin: 8px 0 0 0;
}

.privacy-consent-content .privacy-items li {
    font-size: 13px;
    color: #666;
    line-height: 1.8;
    padding: 5px 0 5px 20px;
    position: relative;
}

.privacy-consent-content .privacy-items li::before {
    content: "•";
    position: absolute;
    left: 5px;
    color: #4FC3F7;
    font-weight: bold;
    font-size: 16px;
}

.privacy-consent-footer-text {
    margin-top: 20px;
    padding: 15px;
    background: #e3f2fd;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
    color: #1976d2;
    text-align: center;
    line-height: 1.6;
}

.privacy-consent-actions {
    padding: 20px;
    border-top: 2px solid #e9ecef;
    background: #f8f9fa;
}

.privacy-consent-checkbox {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 15px;
    cursor: pointer;
    user-select: none;
}

.privacy-consent-checkbox input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin-right: 10px;
    cursor: pointer;
    accent-color: #4FC3F7;
}

.privacy-consent-checkbox span {
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

.privacy-consent-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.privacy-consent-buttons .btn {
    flex: 1;
    font-size: 14px;
    padding: 12px 15px;
}

.privacy-consent-buttons .btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* 반응형 */
@media (max-width: 320px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .header {
        padding: 10px 15px;
    }

    .main-content {
        padding: 15px;
    }

    .privacy-consent-container {
        width: 95%;
        max-height: 85vh;
        margin: 10px;
    }

    .privacy-consent-header h2 {
        font-size: 16px;
    }

    .privacy-consent-buttons {
        flex-direction: column;
    }

    .privacy-consent-buttons .btn {
        width: 100%;
    }
}
/* ============================================================================
 * Template-based Components (Phase 3)
 * ============================================================================ */

/* School Search Templates */
.school-card {
    transition: transform 0.2s, box-shadow 0.2s;
}

.school-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.school-card-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
}

.school-info {
    flex: 1;
}

.school-address {
    color: #666;
    font-size: 14px;
    margin-top: 5px;
}

.school-type {
    color: #999;
    font-size: 12px;
    margin-top: 3px;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}

.empty-icon {
    font-size: 48px;
    margin-bottom: 15px;
    opacity: 0.5;
}

.empty-title {
    font-size: 16px;
    font-weight: bold;
    margin-bottom: 8px;
}

.empty-subtitle {
    font-size: 14px;
    color: #999;
}

/* Hidden if empty utility */
.hidden-if-empty:empty {
    display: none;
}

/* Modal System (Phase 3.2) */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

/* Modal overlay base styles */
.modal-overlay {
    animation: fadeIn 0.2s ease-out;
}

/* Modal content base styles */
.modal-content {
    background: white;
    border-radius: 12px;
    padding: 15px;
    max-width: 95%;
    max-height: 85%;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease-out;
}

/* Attendance modal - wider for mobile */
#attendance-modal-template .modal-content {
    max-width: 98%;
    padding: 10px;
}

@keyframes slideUp {
    from {
        transform: translateY(30px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Modal header */
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    border-bottom: 2px solid #e0e0e0;
    padding-bottom: 15px;
}

.modal-title {
    margin: 0;
    font-size: 16px;
    font-weight: bold;
}

#attendance-modal-template .modal-title {
    font-size: 15px;
}

.modal-close-btn {
    background: #f44336;
    color: white;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    font-size: 18px;
    cursor: pointer;
    transition: background-color 0.2s;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close-btn:hover {
    background: #d32f2f;
}

/* Modal body */
.modal-body {
    margin-bottom: 20px;
}

/* Modal footer */
.modal-footer {
    text-align: center;
    margin-top: 20px;
}

/* Attendance Modal Styles */
.attendance-controls {
    display: flex;
    gap: 6px;
    margin-bottom: 10px;
    align-items: center;
}

.attendance-date-input {
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    flex: 1;
    width: auto;      /* Override input[type="date"] 75% */
    max-width: 100%;  /* Prevent overflow on iPhone */
    min-width: 0;     /* Allow flex item to shrink below content size on iOS */
    margin: 0;        /* Override input[type="date"] center align */
    display: inline-block; /* Override input[type="date"] block */
    font-size: 13px;
}

.attendance-controls .btn-small {
    padding: 6px 12px;
    font-size: 12px;
}

.attendance-summary {
    background: #f5f5f5;
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 10px;
}

.attendance-summary h4 {
    margin: 0 0 8px 0;
    color: #333;
    font-size: 14px;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    text-align: center;
}

.summary-grid-extended {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    text-align: center;
    margin-bottom: 10px;
    font-size: 11px;
}

.summary-grid-extended .summary-stat {
    padding: 6px 4px;
}

@media (max-width: 360px) {
    .summary-grid-extended {
        grid-template-columns: repeat(3, 1fr);
        font-size: 10px;
    }
}

.summary-stat {
    padding: 10px;
    border-radius: 6px;
}

.summary-stat.present {
    background: #e8f5e8;
}

.summary-stat.late {
    background: #fff3e0;
}

.summary-stat.absent {
    background: #ffebee;
}

.summary-stat.total {
    background: #e3f2fd;
}

.summary-number {
    font-size: 18px;
    font-weight: bold;
}

.summary-grid-extended .summary-number {
    font-size: 16px;
}

.summary-number.present {
    color: #4caf50;
}

.summary-number.late {
    color: #ff9800;
}

.summary-number.absent {
    color: #f44336;
}

.summary-number.total {
    color: #2196f3;
}

.summary-label {
    font-size: 11px;
    color: #666;
    margin-top: 3px;
}

.summary-grid-extended .summary-label {
    font-size: 10px;
}

.summary-subtitle {
    font-size: 9px;
    color: #999;
    margin-top: 1px;
}

.summary-rate {
    margin-top: 10px;
    text-align: center;
    font-size: 14px;
    color: #666;
}

.summary-rate-value {
    font-weight: bold;
    color: #4caf50;
}

.attendance-table-container {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: 8px;
}

.attendance-table {
    width: 100%;
    border-collapse: collapse;
}

.attendance-table thead {
    background: #f0f0f0;
    position: sticky;
    top: 0;
}

.attendance-table th,
.attendance-table td {
    padding: 6px 4px;
    border-bottom: 1px solid #ddd;
}

.attendance-table th {
    text-align: left;
    font-size: 12px;
    font-weight: 600;
}

.attendance-table td {
    font-size: 12px;
}

.attendance-table td:nth-child(3),
.attendance-table td:nth-child(4) {
    text-align: center;
}

/* Excel Modal Styles */
.excel-period {
    margin-bottom: 25px;
}

.excel-period h4 {
    color: #333;
    margin-bottom: 15px;
}

.date-range {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 20px;
}

.date-range input {
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    flex: 1;
    width: auto;      /* Override input[type="date"] 75% */
    max-width: none;  /* Override input[type="date"] max-width */
    margin: 0;        /* Override input[type="date"] center align */
    display: inline-block; /* Override input[type="date"] block */
}

.excel-types {
    display: grid;
    gap: 15px;
}

.excel-type-option {
    display: flex;
    align-items: center;
    padding: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.excel-type-option:hover {
    border-color: #4caf50;
}

.excel-type-option input[type="radio"] {
    margin-right: 10px;
}

.excel-type-label {
    flex: 1;
}

.excel-type-title {
    font-weight: bold;
    color: #333;
    margin-bottom: 3px;
}

.excel-type-desc {
    font-size: 12px;
    color: #666;
}

.excel-preview {
    margin-top: 20px;
}

.excel-preview h4 {
    color: #333;
    margin-bottom: 10px;
}

.excel-preview-content {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #f9f9f9;
    padding: 10px;
}

/* ===============================================
   🔄 Refresh Button Animation
   =============================================== */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Apply spin animation when refresh button has 'spin' animation */
.refresh-btn[style*="spin"] {
    animation: spin 0.5s ease;
}

/* ===============================================
   📢 NOTIFICATIONS TAB STYLES
   =============================================== */

/* Notifications Header */
.notifications-header {
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    margin-bottom: 15px;
}

.notifications-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.notifications-title h2 {
    font-size: 20px;
    margin: 0;
}

.unread-count {
    background: #ff4444;
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: bold;
}

/* Notifications List */
.notifications-list {
    padding: 0 15px 15px;
}

.notifications-loading {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

.notifications-empty {
    text-align: center;
    padding: 60px 20px;
    color: #999;
}

.empty-icon {
    font-size: 60px;
    margin-bottom: 15px;
}

.notifications-items {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Notification Item */
.notification-item {
    background: white;
    border-radius: 12px;
    padding: 15px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: all 0.2s;
    border-left: 4px solid transparent;
}

.notification-item:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
}

.notification-item.unread {
    background: linear-gradient(to right, #e3f2fd 0%, #ffffff 100%);
    border-left-color: #2196F3;
}

.notification-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.role-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: bold;
    color: white;
}

.notification-time {
    font-size: 12px;
    color: #999;
}

.notification-content {
    margin-bottom: 10px;
}

.notification-icon-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.notification-icon {
    font-size: 20px;
}

.notification-title {
    font-size: 16px;
    font-weight: bold;
    color: #333;
    margin: 0;
}

.notification-message {
    font-size: 14px;
    color: #666;
    margin: 0;
    line-height: 1.5;
    word-break: break-word;
    overflow-wrap: break-word;
    white-space: pre-wrap;
}

.notification-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.notification-type-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 8px;
    font-size: 11px;
    background: #f5f5f5;
    color: #666;
}

.notification-status {
    display: flex;
    align-items: center;
}

.unread-dot {
    width: 8px;
    height: 8px;
    background: #2196F3;
    border-radius: 50%;
    display: inline-block;
}

/* Infinite Scroll Sentinel */
.loading-sentinel {
    height: 1px;
    margin: 20px 0;
}

.notifications-end {
    text-align: center;
    padding: 20px;
    color: #999;
    font-size: 14px;
}

/* Tab Badge (for tab button) */
.notifications-tab-badge {
    background: #ff4444;
    color: white;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: bold;
    margin-left: 5px;
    display: none;
}

/* Responsive adjustments */
@media (max-width: 320px) {
    .notification-item {
        padding: 12px;
    }

    .notification-title {
        font-size: 14px;
    }

    .notification-message {
        font-size: 13px;
    }
}
