/* Mobile Optimization Styles - Main Mobile CSS File */

/* Login Page Mobile Optimization */
@media (max-width: 768px) {
    .login-body {
        padding: 10px;
        min-height: 100vh;
        background: linear-gradient(135deg, #11998e 0%, #38ef7d 50%, #56ab2f 100%);
    }

    .login-container {
        width: 100%;
        max-width: 100%;
        padding: 10px;
        margin: 0;
    }

    .login-card {
        width: 100%;
        max-width: 380px;
        padding: 22px 18px;
        margin: 0 auto;
        border-radius: 14px;
        box-shadow: 0 12px 34px rgba(2, 6, 23, 0.22);
        background: #ffffffee;
        backdrop-filter: blur(10px);
    }

    .login-card h1 {
        font-size: 20px;
        margin-bottom: 6px;
        line-height: 1.25;
        color: #0f172a;
        text-align: center;
    }

    .login-card p {
        font-size: 13px;
        margin-bottom: 18px;
        line-height: 1.35;
        color: #475569;
        text-align: center;
    }

    .logo {
        font-size: 40px;
        margin-bottom: 10px;
        text-align: center;
    }

    .input-group {
        margin-bottom: 14px;
    }

    .login-card .input-group+.input-group {
        margin-top: 6px;
    }

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

    .input-group input {
        width: 100%;
        padding: 15px 12px;
        font-size: 16px;
        /* Prevents zoom on iOS */
        border: 2px solid #e1e8ed;
        border-radius: 8px;
        background: #fff;
        transition: all 0.3s ease;
        box-sizing: border-box;
        -webkit-appearance: none;
        appearance: none;
    }

    .input-group input:focus {
        outline: none;
        border-color: #11998e;
        box-shadow: 0 0 0 3px rgba(17, 153, 142, 0.12);
    }

    .login-btn {
        width: 100%;
        padding: 13px;
        font-size: 15px;
        font-weight: 700;
        min-height: 46px;
        border-radius: 10px;
        background: linear-gradient(135deg, #10b981 0%, #22c55e 100%);
        color: white;
        border: none;
        cursor: pointer;
        transition: background .2s ease;
        -webkit-tap-highlight-color: transparent;
    }

    .login-btn:hover {
        background: linear-gradient(135deg, #0ea371 0%, #1fb456 100%);
    }

    .login-btn:active {
        transform: translateY(0);
        box-shadow: 0 2px 8px rgba(17, 153, 142, 0.3);
    }

    .error {
        font-size: 14px;
        padding: 10px;
        background: rgba(231, 76, 60, 0.1);
        border: 1px solid rgba(231, 76, 60, 0.3);
        border-radius: 6px;
        margin-bottom: 15px;
        color: #e74c3c;
        text-align: center;
    }

    /* Safe area bottom space for iOS */
    .login-body {
        padding-bottom: calc(10px + env(safe-area-inset-bottom));
    }
}

@media (max-width: 480px) {
    .login-body {
        padding: 5px;
        min-height: 100vh;
        display: flex;
        align-items: center;
        justify-content: center;
        overflow-x: hidden;
    }

    .login-container {
        padding: 10px;
        width: 100%;
        box-sizing: border-box;
    }

    .login-card {
        padding: 20px 15px;
        border-radius: 10px;
        width: 100%;
        max-width: 360px;
        margin: 0 auto;
    }

    .login-card h1 {
        font-size: 20px;
    }

    .login-card p {
        font-size: 13px;
    }

    .logo {
        font-size: 40px;
    }

    .input-group input {
        padding: 12px 10px;
        font-size: 16px;
        width: 100%;
        box-sizing: border-box;
    }

    .login-btn {
        padding: 12px;
        font-size: 15px;
        min-height: 48px;
        width: 100%;
        box-sizing: border-box;
    }
}

/* Navigation Mobile Improvements */
@media (max-width: 768px) {

    /* Compact Mobile Header */
    .simple-header {
        position: sticky !important;
        top: 0 !important;
        z-index: 1000 !important;
    }

    .header-container {
        padding: 8px 12px !important;
        justify-content: space-between !important;
        width: 100% !important;
        box-sizing: border-box !important;
        min-height: 50px !important;
    }

    /* Logo Area - compact */
    .header-left {
        flex: 0 1 auto !important;
    }

    .header-left .logo {
        gap: 8px !important;
        font-size: 15px !important;
    }

    .header-left .logo img {
        width: 32px !important;
        height: 32px !important;
        object-fit: contain !important;
    }

    .header-left .logo span {
        font-size: 14px !important;
        font-weight: 600 !important;
        white-space: nowrap !important;
    }

    /* Hide Desktop Navigation (Header Center) */
    .header-center,
    .nav-links {
        display: none !important;
    }

    /* Hide dropdowns and user info on mobile */
    .header-right .user-info,
    .header-right .dropdown {
        display: none !important;
    }

    /* Show Hamburger */
    .hamburger {
        display: flex !important;
        position: relative !important;
        top: auto !important;
        right: auto !important;
        width: 36px;
        height: 36px;
        background: rgba(255, 255, 255, 0.1);
        border: 1px solid rgba(255, 255, 255, 0.2);
        cursor: pointer;
        z-index: 1001;
        padding: 0;
        border-radius: 8px;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        gap: 4px;
    }

    .hamburger span {
        display: block;
        width: 20px;
        height: 2px;
        margin: 0 !important;
        background: white;
        border-radius: 2px;
        transition: all 0.3s ease;
    }

    /* Ensure Header Right is visible for hamburger */
    .header-right {
        display: flex !important;
        align-items: center;
        flex: 0 0 auto !important;
    }
}

/* Form Responsiveness Improvements */
@media (max-width: 768px) {
    .form-container {
        padding: 15px;
        margin: 0;
    }

    .mobile-form {
        max-width: 100%;
        margin: 0;
    }

    .form-card {
        padding: 20px;
        margin: 0;
        border-radius: 12px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }

    .form-section {
        padding: 15px;
        margin-bottom: 20px;
    }

    .form-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .form-row {
        flex-direction: column;
        gap: 15px;
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 16px;
        /* Prevents zoom on iOS */
        padding: 12px 15px;
        border: 2px solid #e1e8ed;
        border-radius: 8px;
        transition: border-color 0.3s ease;
        width: 100%;
        box-sizing: border-box;
    }

    .form-group input:focus,
    .form-group select:focus,
    .form-group textarea:focus {
        outline: none;
        border-color: #11998e;
        box-shadow: 0 0 0 3px rgba(17, 153, 142, 0.1);
    }

    .submit-btn {
        width: 100%;
        padding: 15px;
        font-size: 16px;
        margin-top: 20px;
        min-height: 48px;
        /* Touch-friendly */
        border-radius: 8px;
        background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
        color: white;
        border: none;
        cursor: pointer;
        transition: transform 0.2s ease;
    }

    .submit-btn:hover {
        transform: translateY(-2px);
    }

    .submit-btn:active {
        transform: translateY(0);
    }

    .step-buttons {
        flex-direction: column;
        gap: 10px;
        margin-top: 20px;
    }

    .btn-next,
    .btn-prev,
    .btn-submit {
        width: 100%;
        padding: 12px;
        font-size: 16px;
        min-height: 44px;
        border-radius: 8px;
        border: none;
        cursor: pointer;
        transition: all 0.3s ease;
        -webkit-tap-highlight-color: transparent;
    }

    .btn-next {
        background: #11998e;
        color: white;
    }

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

    .btn-next:hover,
    .btn-prev:hover {
        transform: translateY(-1px);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    }

    /* File upload mobile optimization */
    .form-group input[type="file"] {
        font-size: 14px;
        padding: 10px;
        border: 2px dashed #e1e8ed;
        border-radius: 8px;
        background: #f8f9fa;
        cursor: pointer;
    }

    .form-group input[type="file"]:hover {
        border-color: #11998e;
        background: #f0f8f5;
    }

    .file-preview {
        font-size: 13px;
        padding: 8px;
        background: #e8f5e8;
        border-radius: 6px;
        margin-top: 5px;
    }

    /* Step indicator mobile improvements */
    .form-steps {
        margin-bottom: 20px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .form-steps .step {
        flex: 0 0 auto;
        min-width: 80px;
        padding: 10px 8px;
        margin: 0 2px;
        border-radius: 8px;
        text-align: center;
        font-size: 12px;
        transition: all 0.3s ease;
    }

    /* Touch-friendly form elements */
    .form-group label {
        font-weight: 600;
        margin-bottom: 6px;
        display: block;
        color: #2c3e50;
    }

    /* Radio buttons and checkboxes */
    .head-options {
        display: flex;
        flex-direction: column;
        gap: 10px;
        margin-top: 15px;
    }

    .head-option {
        display: flex;
        align-items: center;
        padding: 12px;
        border: 2px solid #e1e8ed;
        border-radius: 8px;
        cursor: pointer;
        transition: all 0.3s ease;
        -webkit-tap-highlight-color: transparent;
    }

    .head-option:hover {
        border-color: #11998e;
        background: #f0f8f5;
    }

    .head-option input[type="radio"] {
        margin-right: 10px;
        transform: scale(1.2);
    }

    .head-option span {
        font-weight: 500;
    }

    /* Alert messages */
    .alert-info {
        padding: 15px;
        border-radius: 8px;
        margin-bottom: 20px;
        border-left: 4px solid #2196f3;
        background: linear-gradient(135deg, #e3f2fd 0%, #f3e5f5 100%);
    }

    /* Form validation feedback */
    .form-group.error input,
    .form-group.error select,
    .form-group.error textarea {
        border-color: #e74c3c;
        box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.1);
    }

    .form-group.error::after {
        content: "⚠️ Field ini wajib diisi";
        color: #e74c3c;
        font-size: 12px;
        margin-top: 4px;
        display: block;
    }
}

/* Table Responsiveness */
@media (max-width: 768px) {
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -15px;
        padding: 0 15px;
    }

    table {
        min-width: 600px;
        font-size: 14px;
    }

    th,
    td {
        padding: 8px 6px;
        white-space: nowrap;
    }

    .contribution-table th,
    .contribution-table td {
        padding: 6px 4px;
        font-size: 12px;
    }

    .contribution-table input {
        width: 50px;
        padding: 4px 6px;
        font-size: 12px;
    }

    /* Mobile table swipe indicator */
    .table-responsive::before {
        content: "← Swipe to scroll →";
        position: absolute;
        top: -25px;
        left: 50%;
        transform: translateX(-50%);
        font-size: 12px;
        color: #666;
        background: rgba(255, 255, 255, 0.9);
        padding: 5px 10px;
        border-radius: 15px;
        display: none;
    }

    .table-responsive:hover::before {
        display: block;
    }
}

/* Dashboard Mobile Enhancements */
@media (max-width: 768px) {
    .dashboard-container {
        padding: 10px;
    }

    .dashboard-header {
        padding: 20px 15px;
        text-align: center;
    }

    .dashboard-header h1 {
        font-size: 1.8em;
    }

    .dashboard-stats {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }

    .stat-card {
        padding: 20px 15px;
        text-align: center;
    }

    .stat-number {
        font-size: 2em;
    }

    .dashboard-actions {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .action-card {
        padding: 20px 15px;
        text-align: center;
    }

    .action-icon {
        font-size: 2em;
        margin-bottom: 10px;
    }

    .recent-activity {
        padding: 20px 15px;
    }

    .activity-item {
        padding: 12px 0;
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .activity-content {
        flex: 1;
        width: 100%;
    }
}

/* Member Detail Mobile UX */
@media (max-width: 768px) {
    .family-grid {
        display: flex !important;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        gap: 15px;
        padding: 10px;
        margin-bottom: 20px;
        -webkit-overflow-scrolling: touch;
    }

    .family-card {
        flex: 0 0 300px !important;
        scroll-snap-align: start;
        min-height: 380px;
    }

    .family-header {
        padding: 15px;
        text-align: center;
    }

    .family-name {
        font-size: 1.3em;
    }

    .family-body {
        padding: 15px;
    }

    .info-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .info-label {
        font-weight: bold;
        color: #11998e;
    }

    .info-value {
        width: 100%;
        text-align: left;
    }

    .family-actions {
        flex-direction: column;
        gap: 8px;
    }

    .btn {
        width: 100%;
        padding: 12px;
        font-size: 14px;
    }

    /* Touch-friendly carousel navigation */
    .carousel-nav {
        display: flex;
        justify-content: center;
        gap: 15px;
        margin-top: 20px;
    }

    .carousel-btn {
        width: 40px;
        height: 40px;
        font-size: 20px;
        border-radius: 50%;
        background: #11998e;
        color: white;
        border: none;
        cursor: pointer;
        transition: all 0.3s ease;
    }

    .carousel-btn:hover {
        background: #0d7d73;
        transform: scale(1.1);
    }

    /* Swipe indicators */
    .swipe-indicator {
        display: block;
        text-align: center;
        color: #666;
        font-size: 0.9em;
        margin: 10px 0;
        opacity: 0.8;
    }
}

/* General Mobile Optimizations */
@media (max-width: 768px) {
    body {
        font-size: 14px;
        line-height: 1.5;
    }

    .container {
        margin: 0;
        padding: 15px;
        max-width: 100%;
    }

    h1 {
        font-size: 1.8em;
    }

    h2 {
        font-size: 1.5em;
    }

    h3 {
        font-size: 1.3em;
    }

    /* Touch-friendly buttons */
    button,
    .btn,
    input[type="submit"],
    input[type="button"] {
        min-height: 44px;
        font-size: 16px;
        padding: 12px 16px;
    }

    /* Improved input focus */
    input:focus,
    select:focus,
    textarea:focus {
        outline: none;
        border-color: #11998e;
        box-shadow: 0 0 0 3px rgba(17, 153, 142, 0.1);
        transform: scale(1.02);
    }

    /* Loading states */
    .loading {
        opacity: 0.7;
        pointer-events: none;
        position: relative;
    }

    .loading::after {
        content: '';
        position: absolute;
        top: 50%;
        left: 50%;
        width: 20px;
        height: 20px;
        margin: -10px 0 0 -10px;
        border: 2px solid #f3f3f3;
        border-top: 2px solid #11998e;
        border-radius: 50%;
        animation: spin 1s linear infinite;
    }

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

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

    /* Modal improvements */
    .modal-content {
        margin: 20px;
        max-height: calc(100vh - 40px);
        overflow-y: auto;
    }

    /* Notification positioning */
    .notification {
        left: 10px;
        right: 10px;
        width: auto;
    }
}

/* Performance Optimizations */
@media (max-width: 480px) {

    /* Reduce animations on very small screens */
    *,
    *::before,
    *::after {
        animation-duration: 0.2s !important;
        animation-delay: 0s !important;
        transition-duration: 0.2s !important;
    }

    /* Simplify gradients */
    .navbar {
        background: #1a1a2e;
    }

    .nav-menu {
        background: #1a1a2e;
    }

    /* Reduce shadow complexity */
    .form-card,
    .stat-card,
    .action-card {
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    }
}

/* Print styles for mobile */
@media print {

    .hamburger,
    .nav-menu {
        display: none !important;
    }

    .navbar {
        position: static;
        background: white;
        color: black;
        border-bottom: 2px solid black;
    }

    .nav-logo {
        color: black;
    }
}