/* ========================================
   MOBILE & RESPONSIVE STYLES
   Media Queries, Touch Optimizations
   ======================================== */

/* Mobile responsiveness for table */
@media (max-width: 768px) {
    .findings-table-container {
        font-size: 0.8rem;
    }

    .findings-table th,
    .findings-table td {
        padding: 12px 8px;
    }

    .field-name {
        min-width: 100px;
    }

    .suggested-value {
        min-width: 150px;
        max-width: 200px;
    }

    .context-cell {
        min-width: 150px;
        max-width: 200px;
    }
}

/* ========================================
   COMPREHENSIVE MOBILE RESPONSIVENESS
   ======================================== */

/* Mobile-first approach with progressive enhancement */

/* Base mobile styles (320px+) */
@media (max-width: 480px) {
    .container {
        padding: 12px;
    }

    .site-header h1 {
        font-size: 1.5rem;
        padding: 16px 0;
    }

    .project-header {
        padding: 20px;
        margin-bottom: 20px;
    }

    .project-header h1 {
        font-size: 1.5rem;
        margin-bottom: 12px;
    }

    .project-header .project-meta {
        flex-direction: column;
        gap: 8px;
        font-size: 0.9rem;
    }

    .card {
        padding: 20px;
        margin-bottom: 20px;
    }

    .card h2 {
        font-size: 1.25rem;
    }

    .card h3 {
        font-size: 1.1rem;
    }

    /* Mobile-optimized forms */
    .form-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    input, textarea, select {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 12px 16px;
    }

    /* Mobile buttons */
    button, .btn {
        padding: 12px 20px;
        font-size: 0.9rem;
        min-height: 44px; /* Touch-friendly */
    }

    /* Mobile tables - horizontal scroll */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .table {
        min-width: 600px;
        font-size: 0.9rem;
    }

    .table th,
    .table td {
        padding: 12px 8px;
        white-space: nowrap;
    }

    /* Mobile project cards */
    .grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .project-card {
        padding: 16px;
    }

    .project-card .pc-title {
        font-size: 1.1rem;
    }

    /* Mobile modals */
    .modal-content {
        width: 95%;
        padding: 20px;
        max-height: 90vh;
    }

    .modal-header h3 {
        font-size: 1.1rem;
    }

    /* Mobile dashboard */
    .dashboard-header {
        flex-direction: column;
        gap: 16px;
        text-align: center;
        padding: 20px;
    }

    .dashboard-title h1 {
        font-size: 1.8rem;
    }

    .dashboard-actions {
        flex-direction: column;
        width: 100%;
    }

    .pdf-upload-form {
        flex-direction: column;
        width: 100%;
        gap: 12px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .stat-card {
        padding: 16px;
    }

    .stat-number {
        font-size: 1.5rem;
    }

    /* Mobile timeline */
    .timeline-container {
        padding: 16px;
    }

    .timeline-item {
        padding-left: 40px;
    }

    .timeline-item::before {
        left: 8px;
        width: 12px;
        height: 12px;
    }

    /* Mobile search */
    .toolbar {
        flex-direction: column;
        gap: 12px;
    }

    .toolbar input[type="search"] {
        min-width: auto;
        width: 100%;
    }
}

/* Small tablets (481px - 768px) */
@media (min-width: 481px) and (max-width: 768px) {
    .container {
        padding: 16px;
    }

    .dashboard-content {
        grid-template-columns: 1fr;
    }

    .project-grid {
        grid-template-columns: 1fr;
    }

    .findings-grid {
        grid-template-columns: 1fr;
    }

    .form-actions {
        flex-direction: column;
    }

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

    .grid {
        grid-template-columns: 1fr;
    }
}

/* Tablets (769px - 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
    .dashboard-content {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .project-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .findings-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Desktop (1025px+) */
@media (min-width: 1025px) {
    .dashboard-content {
        grid-template-columns: 2fr 1fr;
    }

    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .project-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .findings-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets */
    button, .btn {
        min-height: 48px;
        padding: 14px 24px;
    }

    .table th,
    .table td {
        padding: 16px 12px;
    }

    /* Remove hover effects on touch devices */
    .card:hover {
        transform: none;
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
    }

    .project-card:hover {
        transform: none;
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    }

    .stat-card:hover {
        transform: none;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .card {
        border-width: 0.5px;
    }

    .table {
        border-width: 0.5px;
    }
}

/* Landscape mobile orientation */
@media (max-width: 768px) and (orientation: landscape) {
    .modal-content {
        max-height: 95vh;
        overflow-y: auto;
    }

    .dashboard-header {
        flex-direction: row;
        text-align: left;
    }

    .dashboard-actions {
        flex-direction: row;
    }
}

/* Print styles */
@media print {
    .site-header,
    .dashboard-actions,
    .modal,
    button,
    .btn {
        display: none !important;
    }

    .card {
        box-shadow: none;
        border: 1px solid #000;
        break-inside: avoid;
    }

    .table {
        border-collapse: collapse;
    }

    .table th,
    .table td {
        border: 1px solid #000;
        padding: 8px;
    }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f172a;
        --card: #1e293b;
        --text: #f8fafc;
        --muted: #94a3b8;
        --border: #334155;
    }

    .table {
        background: var(--card);
        color: var(--text);
    }

    .table th {
        background: #334155;
        color: var(--text);
    }
}

/* Focus management for keyboard navigation */
@media (prefers-reduced-motion: no-preference) {
    button:focus,
    .btn:focus,
    input:focus,
    textarea:focus,
    select:focus {
        outline: 2px solid var(--primary);
        outline-offset: 2px;
    }
}

/* Mobile-specific utility classes */
.mobile-only {
    display: block;
}

.desktop-only {
    display: none;
}

@media (min-width: 769px) {
    .mobile-only {
        display: none;
    }

    .desktop-only {
        display: block;
    }
}

/* Mobile navigation improvements */
.mobile-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--card);
    border-top: 1px solid var(--border);
    padding: 12px;
    z-index: 100;
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px;
    text-decoration: none;
    color: var(--muted);
    font-size: 0.75rem;
    flex: 1;
    text-align: center;
}

.mobile-nav-item.active {
    color: var(--primary);
}

.mobile-nav-item i {
    font-size: 1.2rem;
}

@media (max-width: 768px) {
    .mobile-nav {
        display: flex;
    }

    body {
        padding-bottom: 80px; /* Space for mobile nav */
    }
}

/* Responsive */
@media (max-width: 860px) {
    .form-grid {
        grid-template-columns: 1fr;
    }

    .container {
        padding: 20px;
    }

    .site-header h1 {
        font-size: 22px;
    }

    .project-header .project-meta {
        flex-direction: column;
        gap: 12px;
    }

    .card {
        padding: 24px;
    }

    .grid {
        grid-template-columns: 1fr;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
	.project-title-section {
		flex-direction: column;
		align-items: flex-start;
		gap: 1rem;
	}

	.key-info-row {
		grid-template-columns: 1fr;
	}

	.details-grid {
		grid-template-columns: 1fr;
	}

	.detail-field {
		flex-direction: column;
		gap: 0.25rem;
	}

	.detail-field label {
		flex: none;
		padding-right: 0;
	}
}

/* RESPONSIVE DESIGN FOR CREATIVE LAYOUT */
@media (max-width: 1024px) {
	.creative-layout {
		grid-template-columns: 1fr;
		gap: 1.5rem;
	}

	.stats-dashboard {
		grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
	}
}

@media (max-width: 768px) {
	.project-hero {
		padding: 2rem 1.5rem;
	}

	.project-main-title {
		font-size: 2.25rem;
	}

	.stats-dashboard {
		grid-template-columns: 1fr;
		gap: 1rem;
	}

	.stat-card {
		padding: 1.5rem;
	}

	.info-row {
		flex-direction: column;
		gap: 0.5rem;
	}

	.info-label {
		flex: none;
		padding-right: 0;
	}

	.card-content {
		padding: 1.5rem;
	}
}

/* Mobile responsiveness for delete modal */
@media (max-width: 768px) {
    .delete-project-modal {
        width: 95vw;
        max-width: none;
    }

    .warning-banner {
        flex-direction: column;
        text-align: center;
    }

    .impact-list li {
        font-size: 14px;
    }

    .confirmation-checkbox {
        font-size: 13px;
    }
}

/* ========================================
   COMPREHENSIVE MOBILE FIXES
   ======================================== */

/* Fix navbar white text on white background issue on mobile */
@media (max-width: 991px) {
    /* Bootstrap's navbar collapse breakpoint */
    .navbar {
        background: var(--valerin-primary) !important;
    }

    .navbar .nav-link {
        color: white !important;
        padding: 12px 16px !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }

    .navbar .nav-link:hover {
        color: var(--valerin-accent) !important;
        background: rgba(255, 255, 255, 0.1);
    }

    .navbar-brand {
        color: white !important;
    }

    .navbar-toggler {
        border-color: rgba(255, 255, 255, 0.3);
        padding: 8px 12px;
    }

    .navbar-toggler-icon {
        background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba(255, 255, 255, 0.9)' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
    }

    .navbar-collapse {
        background: var(--valerin-primary);
        margin-top: 12px;
        padding: 12px 0;
        border-radius: 8px;
    }

    .dropdown-menu {
        background: var(--valerin-primary-dark);
        border: none;
    }

    .dropdown-item {
        color: white !important;
        padding: 12px 20px;
    }

    .dropdown-item:hover {
        background: rgba(255, 255, 255, 0.1) !important;
        color: var(--valerin-accent) !important;
    }
}

/* Mobile button sizing - smaller edit/delete buttons */
@media (max-width: 768px) {
    /* Reduce button sizes for mobile */
    button, .btn {
        font-size: 0.8rem !important;
        padding: 8px 14px !important;
        min-height: 38px !important;
    }

    /* Extra small buttons for inline actions (edit/delete in tables) */
    .table button,
    .table .btn,
    button[onclick*="toggleEditForm"],
    button[onclick*="deleteProject"],
    button[onclick*="delete"],
    .edit-btn,
    .delete-btn,
    .danger,
    .btn-danger {
        font-size: 0.7rem !important;
        padding: 6px 10px !important;
        min-height: 32px !important;
        letter-spacing: 0.02em !important;
    }

    /* Remove emoji icons on mobile to save space */
    button[onclick*="toggleEditForm"]:before {
        display: none;
    }

    /* Smaller action buttons in cards */
    .card button,
    .card .btn {
        font-size: 0.75rem !important;
        padding: 8px 12px !important;
    }

    /* Make button groups stack vertically on very small screens */
    .form-actions,
    .modal-footer,
    .button-group {
        flex-direction: column !important;
        gap: 8px !important;
    }

    .form-actions button,
    .modal-footer button {
        width: 100% !important;
    }
}

/* Extra small screens - even more compact */
@media (max-width: 480px) {
    button, .btn {
        font-size: 0.75rem !important;
        padding: 6px 12px !important;
        min-height: 36px !important;
    }

    .table button,
    .table .btn,
    .edit-btn,
    .delete-btn {
        font-size: 0.65rem !important;
        padding: 4px 8px !important;
        min-height: 28px !important;
    }

    /* Compact table cells on mobile */
    .table th,
    .table td {
        padding: 10px 8px !important;
        font-size: 0.8rem !important;
    }

    /* Smaller headings */
    h1 {
        font-size: 1.5rem !important;
    }

    h2 {
        font-size: 1.25rem !important;
    }

    h3 {
        font-size: 1.1rem !important;
    }

    /* Reduce card padding */
    .card {
        padding: 16px !important;
        margin-bottom: 16px !important;
    }

    /* Smaller project header */
    .project-header {
        padding: 20px !important;
        margin-bottom: 20px !important;
    }

    .project-header h1 {
        font-size: 1.5rem !important;
    }
}

/* Landscape orientation fixes for mobile */
@media (max-width: 768px) and (orientation: landscape) {
    /* Reduce vertical padding in landscape */
    .site-header h1 {
        padding: 12px 0 !important;
        font-size: 1.5rem !important;
    }

    .project-header {
        padding: 16px !important;
        margin-bottom: 16px !important;
    }

    .card {
        padding: 16px !important;
        margin-bottom: 16px !important;
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    /* Increase touch targets for mobile */
    button, .btn, a.btn {
        min-height: 44px !important;
        min-width: 44px !important;
    }

    /* Remove hover effects on touch devices */
    .card:hover {
        transform: none !important;
    }

    button:hover, .btn:hover {
        transform: none !important;
    }

    /* Better tap highlights */
    button, .btn, a {
        -webkit-tap-highlight-color: rgba(59, 130, 246, 0.2);
    }
}

/* Fix white space and scrolling issues on mobile */
@media (max-width: 768px) {
    body {
        overflow-x: hidden;
    }

    .container {
        max-width: 100%;
        padding-left: 16px;
        padding-right: 16px;
    }

    /* Prevent horizontal scroll from tables */
    .table-container,
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin-left: -16px;
        margin-right: -16px;
        padding-left: 16px;
        padding-right: 16px;
    }

    /* Fix modal sizing on mobile */
    .modal-content {
        width: 95vw !important;
        max-width: 95vw !important;
        margin: 8px;
    }

    .modal-header h3,
    .modal-header h2 {
        font-size: 1.1rem !important;
    }

    /* Smaller form labels and inputs on mobile */
    label {
        font-size: 0.9rem;
        margin-bottom: 6px;
    }

    input, textarea, select {
        font-size: 16px !important; /* Prevents iOS zoom */
    }

    /* Better spacing for form groups */
    .form-group {
        margin-bottom: 16px;
    }
}

/* Fix document thumbnails on mobile */
@media (max-width: 768px) {
    .document-grid,
    .documents-list {
        grid-template-columns: 1fr !important;
        gap: 12px;
    }

    .document-card,
    .document-item {
        padding: 12px;
    }

    .document-thumbnail {
        max-width: 80px;
        max-height: 80px;
    }
}

/* Fix stats cards on mobile */
@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 12px !important;
    }

    .stat-card {
        padding: 12px !important;
    }

    .stat-number {
        font-size: 1.5rem !important;
    }

    .stat-label {
        font-size: 0.75rem !important;
    }
}

/* Fix timeline on mobile */
@media (max-width: 768px) {
    .timeline-item {
        padding-left: 32px !important;
    }

    .timeline-item::before {
        left: 6px !important;
        width: 10px !important;
        height: 10px !important;
    }

    .timeline-content {
        font-size: 0.85rem;
    }

    .timeline-date {
        font-size: 0.75rem;
    }
}

/* Fix navbar brand/logo sizing on mobile */
@media (max-width: 768px) {
    .navbar-brand {
        font-size: 1.5rem !important;
    }

    .navbar-brand img {
        max-height: 32px;
    }
}

/* PDF viewer modal fixes for mobile */
@media (max-width: 768px) {
    .pdf-modal,
    .document-modal {
        width: 100vw !important;
        height: 100vh !important;
        max-width: 100vw !important;
        max-height: 100vh !important;
        margin: 0 !important;
        border-radius: 0 !important;
    }

    .pdf-viewer,
    .document-viewer {
        width: 100% !important;
        height: calc(100vh - 60px) !important;
    }
}
