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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: #f5f5f7;
    color: #1d1d1f;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header Styles */
header {
    background: white;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
}

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

header h1 {
    color: #2c3e50;
    margin: 0;
    font-size: 2.5rem;
    font-weight: 700;
    flex: 1;
    text-align: center;
}

.config-btn {
    background: #17a2b8;
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 1.5rem;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.config-btn:hover {
    background: #138496;
    transform: scale(1.1) rotate(45deg);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

nav {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

.nav-btn {
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #495057;
}

.nav-btn:hover {
    background: #e9ecef;
    transform: translateY(-2px);
}

.nav-btn.active {
    background: #007bff;
    color: white;
    border-color: #007bff;
}

/* Section Styles */
.section {
    display: none !important;
    background: white;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

.section.active {
    display: block !important;
    animation: fadeIn 0.3s ease-in;
}

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

.section h2 {
    color: #2c3e50;
    margin-bottom: 25px;
    font-size: 2rem;
    font-weight: 600;
    border-bottom: 3px solid #007bff;
    padding-bottom: 10px;
}

/* Form Styles */
.form-container {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 25px;
    margin-bottom: 25px;
    border: 1px solid #e9ecef;
}

.form-container h3 {
    color: #495057;
    margin-bottom: 20px;
    font-size: 1.5rem;
    font-weight: 600;
}

.form-row {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.form-group {
    margin-bottom: 20px;
    flex: 1;
    min-width: 200px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #495057;
    font-size: 14px;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s ease;
    background: white;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.form-group input:required:invalid {
    border-color: #dc3545;
}

.form-group input:required:valid {
    border-color: #28a745;
}

/* Button Styles */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

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

.btn-primary {
    background: linear-gradient(135deg, #007bff, #0056b3);
    color: white;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #0056b3, #004085);
}

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

.btn-secondary:hover {
    background: #5a6268;
}

.btn-success {
    background: linear-gradient(135deg, #28a745, #1e7e34);
    color: white;
}

.btn-success:hover {
    background: linear-gradient(135deg, #1e7e34, #155724);
}

.btn-warning {
    background: linear-gradient(135deg, #ffc107, #e0a800);
    color: #212529;
}

.btn-warning:hover {
    background: linear-gradient(135deg, #e0a800, #d39e00);
}

.btn-danger {
    background: linear-gradient(135deg, #dc3545, #c82333);
    color: white;
}

.btn-danger:hover {
    background: linear-gradient(135deg, #c82333, #bd2130);
}

.form-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 30px;
    flex-wrap: wrap;
}

/* Child Form Styles */
.child-form {
    background: white;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
    position: relative;
}

.child-form h4 {
    color: #007bff;
    margin-bottom: 15px;
    font-size: 1.2rem;
}

.remove-child-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Parent Form Styles */
.parent-form {
    background: white;
    border: 2px solid #28a745;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
    position: relative;
}

.parent-form h4 {
    color: #28a745;
    margin-bottom: 15px;
    font-size: 1.2rem;
}

.remove-parent-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.remove-parent-btn:hover {
    background: #c82333;
    transform: rotate(90deg);
    transition: all 0.3s ease;
}

/* Sign In/Out Styles */
.signin-container {
    max-width: 600px;
    margin: 0 auto;
}

.suggestions {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    max-height: 200px;
    overflow-y: auto;
    position: absolute;
    width: 100%;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.suggestion-item {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid #f8f9fa;
    transition: background-color 0.2s ease;
}

.suggestion-item:hover {
    background: #f8f9fa;
}

.suggestion-item:last-child {
    border-bottom: none;
}

.selected-children {
    margin: 20px 0;
}

.selected-child {
    display: inline-block;
    background: #007bff;
    color: white;
    padding: 8px 16px;
    margin: 5px;
    border-radius: 20px;
    font-size: 14px;
    position: relative;
}

.selected-child .remove-btn {
    background: none;
    border: none;
    color: white;
    margin-left: 8px;
    cursor: pointer;
    font-size: 16px;
}

/* Collector / signature section */
.selected-collector {
    margin-top: 8px;
}

.selected-collector .selected-child {
    background: #28a745;
}

.signature-section {
    margin-top: 20px;
}

.signature-section label {
    display: block;
    font-weight: 600;
    color: #495057;
    font-size: 14px;
    margin-bottom: 8px;
}

.signature-canvas-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
}

#signatureCanvas,
#leaderSignatureCanvas {
    border: 2px solid #dee2e6;
    border-radius: 8px;
    background: white;
    cursor: crosshair;
    touch-action: none;
    max-width: 100%;
}

#signatureCanvas.has-signature,
#leaderSignatureCanvas.has-signature {
    border-color: #28a745;
}

/* Sync status indicator */
.sync-status {
    position: absolute;
    top: 20px;
    right: 20px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 400;
    color: #888;
    display: flex;
    align-items: center;
    gap: 5px;
}

.sync-status.synced {
    background: transparent;
    color: #888;
    border: none;
}

.sync-status.syncing {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeeba;
    font-weight: 600;
}

.sync-status.pending {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    font-weight: 600;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 13px;
}

/* Attendance Styles */
.attendance-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    flex-wrap: wrap;
    gap: 15px;
}

.attendance-count {
    font-size: 1.2rem;
    font-weight: 600;
    color: #007bff;
}

.attendance-list {
    overflow-x: auto;
}

#attendanceTable {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

#attendanceTable th {
    background: #007bff;
    color: white;
    padding: 15px;
    text-align: left;
    font-weight: 600;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#attendanceTable td {
    padding: 15px;
    border-bottom: 1px solid #e9ecef;
    font-size: 14px;
}

#attendanceTable tbody tr:hover {
    background: #f8f9fa;
}

#attendanceTable tbody tr:last-child td {
    border-bottom: none;
}

/* Child link styling in attendance table */
.child-link {
    color: #007bff;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
}

.child-link:hover {
    color: #0056b3;
    text-decoration: underline;
    cursor: pointer;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: none;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    z-index: 1000;
}

.loading-overlay.show {
    display: flex;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #e9ecef;
    border-top: 4px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

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

/* Message Container */
.message-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1100;
}

.message {
    background: white;
    border-radius: 8px;
    padding: 16px 20px;
    margin-bottom: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-left: 4px solid;
    animation: slideIn 0.3s ease-out;
    min-width: 300px;
}

.message.success {
    border-left-color: #28a745;
    background: #d4edda;
    color: #155724;
}

.message.error {
    border-left-color: #dc3545;
    background: #f8d7da;
    color: #721c24;
}

.message.info {
    border-left-color: #007bff;
    background: #d1ecf1;
    color: #0c5460;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .form-row {
        flex-direction: column;
    }
    
    .form-group {
        min-width: auto;
    }
    
    .nav-btn {
        padding: 10px 16px;
        font-size: 14px;
    }
    
    .attendance-controls {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }
    
    .message {
        min-width: auto;
        margin: 0 10px 10px 10px;
    }
    
    .message-container {
        right: 0;
        left: 0;
        top: 10px;
    }
    
    /* Ensure sections display correctly on mobile */
    .section {
        display: none !important;
    }
    
    .section.active {
        display: block !important;
    }
}

@media (max-width: 480px) {
    .section {
        padding: 20px 15px;
    }
    
    .form-container {
        padding: 15px;
    }
    
    #attendanceTable {
        font-size: 12px;
    }
    
    #attendanceTable th,
    #attendanceTable td {
        padding: 8px;
    }
}

/* iPad Specific Optimizations */
@media (min-width: 768px) and (max-width: 1024px) {
    .container {
        padding: 30px;
    }
    
    .section {
        padding: 40px;
    }
    
    .form-group input,
    .form-group textarea,
    .form-group select {
        font-size: 18px;
        padding: 16px 20px;
    }
    
    .btn {
        font-size: 18px;
        padding: 16px 32px;
    }
    
    .nav-btn {
        font-size: 18px;
        padding: 16px 32px;
    }
}

/* Authentication Styles */
.auth-required {
    text-align: center;
    padding: 60px 20px;
    max-width: 500px;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
}

.auth-required h2 {
    color: #2c3e50;
    margin-bottom: 20px;
    font-size: 2rem;
}

.auth-required p {
    margin-bottom: 20px;
    color: #666;
    font-size: 1.1rem;
    line-height: 1.6;
}

.auth-required .btn {
    margin-top: 20px;
    font-size: 1.1rem;
    padding: 16px 32px;
}

/* Ministry selector landing page */
.ministry-landing-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #f5f5f7;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 20px;
}

.ministry-landing-card {
    background: white;
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    padding: 56px 48px;
    max-width: 460px;
    width: 100%;
    text-align: center;
}

.ministry-landing-icon {
    font-size: 2.8rem;
    color: #007bff;
    margin-bottom: 16px;
}

.ministry-landing-title {
    font-size: 2.4rem;
    font-weight: 700;
    color: #1d1d1f;
    margin-bottom: 12px;
}

.ministry-landing-subtitle {
    font-size: 1.05rem;
    color: #666;
    line-height: 1.6;
    margin-bottom: 36px;
}

.ministry-pick-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.ministry-pick-btn {
    display: block;
    width: 100%;
    padding: 18px 24px;
    font-size: 1.1rem;
    font-weight: 600;
    color: white;
    background: #007bff;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.ministry-pick-btn:hover {
    background: #0056b3;
}

.ministry-pick-btn:active {
    transform: scale(0.98);
}

/* Configuration Required Styles */
.config-required {
    text-align: center;
    padding: 40px 20px;
    max-width: 600px;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
}

.config-required h2 {
    color: #2c3e50;
    margin-bottom: 20px;
    font-size: 2rem;
}

.config-required p {
    margin-bottom: 20px;
    color: #666;
    font-size: 1.1rem;
    line-height: 1.6;
}

.config-steps {
    text-align: left;
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    margin: 25px 0;
    border-left: 4px solid #17a2b8;
}

.config-steps h3 {
    color: #2c3e50;
    margin-bottom: 15px;
    font-size: 1.2rem;
}

.config-steps ol {
    margin: 0;
    padding-left: 20px;
}

.config-steps li {
    margin-bottom: 10px;
    color: #495057;
    line-height: 1.5;
}

.config-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 30px;
}

.config-actions .btn {
    font-size: 1.1rem;
    padding: 16px 24px;
    min-width: 200px;
}

/* User Info Styles */
.user-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 15px;
    padding: 10px 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.user-info span {
    color: #2c3e50;
    font-weight: 500;
}

.user-info .btn {
    margin: 0;
    padding: 8px 16px;
    font-size: 14px;
}

/* Responsive user info */
@media (max-width: 768px) {
    .user-info {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
}

/* Ministry Management Styles */
.header-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

.ministry-selector {
    padding: 8px 12px;
    border: 2px solid #007bff;
    border-radius: 8px;
    background: white;
    color: #2c3e50;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 200px;
}

.ministry-selector:hover {
    border-color: #0056b3;
    background: #f8f9fa;
}

.ministry-selector:focus {
    outline: none;
    border-color: #0056b3;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.ministries-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ministry-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: white;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.ministry-item:hover {
    border-color: #007bff;
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.1);
}

.ministry-item.selected {
    border-color: #28a745;
    background: #f0fff4;
}

.ministry-info {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.ministry-info strong {
    color: #2c3e50;
    font-size: 16px;
}

.ministry-info small {
    color: #6c757d;
    font-size: 12px;
    font-family: monospace;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

@media (max-width: 768px) {
    .header-controls {
        flex-direction: column;
        width: 100%;
        gap: 10px;
    }
    
    .ministry-selector {
        width: 100%;
    }
}

/* Disclaimer and Agreement Styles */
.disclaimer-text {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    border-left: 4px solid #007bff;
    margin-bottom: 20px;
    line-height: 1.6;
}

.disclaimer-text p {
    margin-bottom: 15px;
    color: #495057;
}

.disclaimer-text p:last-child {
    margin-bottom: 0;
}

.checkbox-group {
    margin-top: 15px;
}

.checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-weight: 600;
    color: #495057;
}

.checkbox-label input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    margin: 0;
    flex-shrink: 0;
    vertical-align: middle;
}

.checkbox-label span {
    user-select: none;
    white-space: nowrap;
    line-height: 20px;
}

/* Form Help Text */
.form-help-text {
    background: #e7f3ff;
    padding: 12px 16px;
    border-radius: 6px;
    border-left: 3px solid #007bff;
    margin: 15px 0;
    font-size: 14px;
    line-height: 1.5;
    color: #495057;
}

.form-group small {
    display: block;
    margin-top: 5px;
    font-size: 13px;
    color: #6c757d;
    line-height: 1.4;
}

.form-group small.field-description {
    margin-top: 5px;
    margin-bottom: 15px;
}
