/* Dodatkowe style dla System Katalogowy Komponentów */

/* Custom max-width klasa */
.max-w-8xl {
    max-width: 100rem; /* 1600px */
}

/* Style podstawowe */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Form elements styling - ensure proper visibility */
input, select, textarea {
    color: #1f2937 !important; /* Dark gray text */
    background-color: #ffffff !important; /* White background */
    border: 1px solid #d1d5db !important; /* Light gray border */
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    font-size: 14px;
    line-height: 1.5;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

input:focus, select:focus, textarea:focus {
    outline: none !important;
    border-color: #3b82f6 !important; /* Blue border on focus */
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1) !important; /* Blue glow */
    background-color: #ffffff !important; /* Ensure white background on focus */
}

input::placeholder, textarea::placeholder {
    color: #9ca3af !important; /* Light gray placeholder */
    opacity: 1;
}

/* Disabled form elements */
input:disabled, select:disabled, textarea:disabled {
    background-color: #f9fafb !important;
    color: #6b7280 !important;
    cursor: not-allowed;
    opacity: 0.75;
}

/* Readonly form elements */
input:read-only, select:read-only, textarea:read-only {
    background-color: #f9fafb !important;
    color: #374151 !important;
    cursor: default;
}

/* Style dla autocomplete detali */
.autocomplete-wrapper {
    position: relative;
}

.autocomplete-dropdown {
    z-index: 1000;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    background: white;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.autocomplete-item {
    padding: 0.75rem;
    cursor: pointer;
    border-bottom: 1px solid #f1f5f9;
    transition: background-color 0.15s ease;
}

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

.autocomplete-item:hover,
.autocomplete-item.active {
    background-color: #f8fafc;
    border-radius: 0.5rem;
}

.autocomplete-item mark {
    background-color: #fef08a;
    padding: 0.1rem 0.2rem;
    border-radius: 0.25rem;
}

.autocomplete-input:focus + .autocomplete-dropdown {
    border-color: #3b82f6;
}

/* Poprawki do scrollbarów */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Animacje dla modalów */
.modal-enter {
    animation: modalEnter 0.3s ease-out forwards;
}

@keyframes modalEnter {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Modal container - responsive sizing with proper scrolling */
.modal-container {
    width: 85vw !important;
    height: 85vh !important;
    max-width: 900px !important;
    max-height: 90vh !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    position: relative;

    /* Force GPU acceleration for smoother scrolling */
    transform: translateZ(0);
    -webkit-transform: translateZ(0);

    /* Ensure proper scrolling behavior */
    overscroll-behavior: contain;
    scroll-behavior: smooth;
}

/* Special handling for flex column modals */
.modal-container.flex.flex-col {
    display: flex !important;
    flex-direction: column !important;
}

.modal-container.flex.flex-col > * {
    flex-shrink: 0;
}

.modal-container.flex.flex-col > .overflow-y-auto {
    flex: 1 1 0%;
    min-height: 0;
}

/* Form elements in modals - extra specificity to ensure visibility */
.modal-container input,
.modal-container select,
.modal-container textarea {
    color: #1f2937 !important; /* Dark gray text */
    background-color: #ffffff !important; /* White background */
    border: 1px solid #d1d5db !important; /* Light gray border */
    border-radius: 0.5rem !important;
}

.modal-container input:focus,
.modal-container select:focus,
.modal-container textarea:focus {
    border-color: #3b82f6 !important;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1) !important;
    background-color: #ffffff !important;
}

.modal-container input::placeholder,
.modal-container textarea::placeholder {
    color: #9ca3af !important;
    opacity: 1;
}

/* Autocomplete inputs in modals */
.modal-container .autocomplete-input {
    color: #1f2937 !important;
    background-color: #ffffff !important;
    border: 1px solid #d1d5db !important;
}

.modal-container .autocomplete-input:focus {
    border-color: #3b82f6 !important;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1) !important;
}

/* Legacy support - keep existing modal styles for other modals */
.fixed.inset-0 .bg-white.rounded-xl:not(.modal-container) {
    width: 90vw !important;
    height: 85vh !important;
    max-width: 1200px !important;
    max-height: 90vh !important;
    margin: 7.5vh auto !important;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

/* Responsive modal sizing */

/* Desktop and large screens */
@media (min-width: 1024px) {
    div.modal-container,
    .bg-white.modal-container {
        width: 90vw !important;
        height: 90vh !important;
        max-width: none !important;
        max-height: 95vh !important;
        min-width: 90vw !important;
        min-height: 90vh !important;
    }

    .fixed.inset-0 .bg-white.rounded-xl:not(.modal-container) {
        width: 90vw !important;
        height: 90vh !important;
        max-width: none !important;
        margin: 5vh auto !important;
    }
}

/* Tablets */
@media (min-width: 768px) and (max-width: 1023px) {
    .modal-container {
        width: 85vw !important;
        height: 85vh !important;
        max-width: 900px !important;
        max-height: 90vh !important;
    }
}

/* Large mobile phones */
@media (min-width: 480px) and (max-width: 767px) {
    .modal-container {
        width: 95vw !important;
        height: 90vh !important;
        max-width: none !important;
        max-height: 95vh !important;
        padding: 1rem !important;
    }
}

/* Small mobile phones */
@media (max-width: 479px) {
    .modal-container {
        width: 98vw !important;
        height: 95vh !important;
        max-width: none !important;
        max-height: 98vh !important;
        padding: 0.75rem !important;
        margin: 1vh 1vw !important;
        border-radius: 0.75rem !important;
    }

    /* Ensure modal content is scrollable on very small screens */
    .modal-container .grid {
        gap: 0.75rem !important;
    }

    .modal-container .space-y-4 > * + * {
        margin-top: 0.75rem !important;
    }

    /* Make form elements more compact on mobile */
    .modal-container input,
    .modal-container select,
    .modal-container textarea {
        padding: 0.75rem 0.5rem !important;
        font-size: 16px !important; /* Prevent zoom on iOS */
        color: #1f2937 !important; /* Dark gray text */
        background-color: #ffffff !important; /* White background */
        border: 1px solid #d1d5db !important; /* Light gray border */
    }

    .modal-container .grid-cols-2 {
        grid-template-columns: 1fr !important;
        gap: 0.75rem !important;
    }
}

/* Style dla podglądów zdjęć i PDF w trybie pełnoekranowym */
.fixed.inset-0.bg-black.bg-opacity-90 > div,
.fixed.inset-0.bg-black.bg-opacity-50 > div {
    width: 90vw !important;
    height: 90vh !important;
    max-width: 90vw !important;
    max-height: 90vh !important;
}

/* Style modali dla bazy technologów */
#detalPreviewModal .bg-white,
#detalModal .bg-white,
#protocolPreviewModal .bg-white,
#maszynaModal .bg-white,
#testNarzedziModal .bg-white,
#importOsprzetModal .bg-white {
    width: 90vw !important;
    height: 90vh !important;
    max-width: none !important;
    max-height: none !important;
}

/* Style dla logo w nagłówku */
.logo-header {
    height: 3rem; /* 48px */
    width: auto;
    max-width: 30rem;
    transition: all 0.3s ease;
}

.logo-header:hover {
    transform: scale(1.05);
}

/* Dodatkowe style dla niebieskiego motywu korporacyjnego */
.corporate-blue-header {
    background: linear-gradient(135deg, #1e3a8a 0%, #1d4ed8 50%, #2563eb 100%);
    background-size: 200% 200%;
    animation: gradientShift 10s ease infinite;
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* Style dla przycisków w niebieskim motywie */
.btn-corporate-blue {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: all 0.2s ease;
}

.btn-corporate-blue:hover {
    background: linear-gradient(135deg, #1d4ed8, #1e40af);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

/* Hover effects dla kart */
.card-hover {
    transition: all 0.3s ease;
}

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

/* Loading indicator */
.loading {
    position: relative;
}

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

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

/* Responsive improvements - Enhanced for better mobile/tablet support */

/* Large tablets and small desktops */
@media (max-width: 1200px) {
    .container {
        padding: 0 1rem;
    }

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

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

/* Standard tablets (768px - 1024px) */
@media (max-width: 1024px) {
    .container {
        padding: 0 1rem;
    }

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

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

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

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

    /* Better spacing for tablets */
    .space-x-4 > * + * {
        margin-left: 0.5rem;
    }

    .space-y-4 > * + * {
        margin-top: 1rem;
    }

    /* Touch-friendly buttons */
    button, .btn {
        min-height: 44px;
        padding: 0.75rem 1rem;
    }
}

/* Large mobile and small tablets (600px - 768px) */
@media (max-width: 768px) {
    .container {
        padding: 0 0.75rem;
    }

    /* Grid layouts for tablets */
    .grid-responsive {
        grid-template-columns: 1fr;
    }

    .flex-responsive {
        flex-direction: column;
        gap: 1rem;
    }

    .grid-cols-2 {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }

    .grid-cols-3,
    .grid-cols-4,
    .grid-cols-5,
    .grid-cols-6 {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }

    /* Form styles for tablets */
    .form-grid {
        display: grid;
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    /* Modal adjustments for tablets */
    .modal-content {
        margin: 2rem;
        max-height: calc(100vh - 4rem);
        width: calc(100% - 4rem);
    }

    .fixed.inset-0 .bg-white.rounded-xl {
        width: 85vw !important;
        height: 85vh !important;
        max-width: none !important;
        max-height: none !important;
        margin: 7.5vh auto !important;
    }

    /* Layout adjustments for tablets */
    .fixed.inset-0 .lg\:grid-cols-2 {
        grid-template-columns: 1fr;
    }

    .fixed.inset-0 .lg\:grid-cols-3 {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Logo for tablets */
    .logo-header {
        height: 2.5rem;
        max-width: 20rem;
    }

    /* Specific modal styles for tablets */
    #detalPreviewModal .bg-white,
    #detalModal .bg-white,
    #protocolPreviewModal .bg-white,
    #maszynaModal .bg-white,
    #testNarzedziModal .bg-white,
    #importOsprzetModal .bg-white {
        width: 85vw !important;
        height: 85vh !important;
    }

    /* Responsive tables */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: 0.5rem;
        border: 1px solid #e2e8f0;
    }

    table {
        min-width: 650px;
        font-size: 0.875rem;
    }

    table th,
    table td {
        padding: 0.75rem 0.5rem;
    }

    /* Button group improvements */
    .btn-group {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
        width: 100%;
    }

    .btn-group.vertical {
        grid-template-columns: 1fr;
    }

    /* Enhanced touch targets */
    button, .btn, a[role="button"] {
        min-height: 48px;
        min-width: 48px;
        padding: 0.75rem 1rem;
        touch-action: manipulation;
    }

    /* Navigation improvements */
    .nav-tablet {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .nav-tablet > * {
        flex: 1;
        min-width: 120px;
    }
}

/* Standard mobile phones (480px - 640px) */
@media (max-width: 640px) {
    body {
        font-size: 14px;
        -webkit-text-size-adjust: 100%;
        -ms-text-size-adjust: 100%;
    }

    .container {
        padding: 0 0.5rem;
    }

    /* Typography adjustments for mobile */
    h1 {
        font-size: 1.5rem;
        line-height: 1.3;
    }

    h2 {
        font-size: 1.25rem;
        line-height: 1.3;
    }

    h3 {
        font-size: 1.125rem;
        line-height: 1.3;
    }

    /* Grid layouts for mobile */
    .grid-cols-2,
    .grid-cols-3,
    .grid-cols-4,
    .grid-cols-5,
    .grid-cols-6 {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

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

    /* Card adjustments for mobile */
    .card {
        margin-bottom: 1rem;
        padding: 1rem;
        border-radius: 0.75rem;
    }

    /* Form elements - prevent zoom on iOS and ensure visibility */
    input, select, textarea {
        font-size: 16px !important; /* Prevent zoom on iOS */
        padding: 1rem !important;
        border-radius: 0.5rem !important;
        width: 100% !important;
        box-sizing: border-box !important;
        color: #1f2937 !important; /* Dark gray text */
        background-color: #ffffff !important; /* White background */
        border: 1px solid #d1d5db !important; /* Light gray border */
    }

    input:focus, select:focus, textarea:focus {
        outline: none !important;
        border-color: #3b82f6 !important;
        box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1) !important;
        background-color: #ffffff !important;
    }

    input::placeholder, textarea::placeholder {
        color: #9ca3af !important; /* Light gray placeholder */
        opacity: 1;
    }

    /* Enhanced mobile navigation */
    .nav-mobile {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(10px);
        border-top: 1px solid #e2e8f0;
        padding: 0.75rem;
        z-index: 50;
        box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.1);
    }

    .nav-mobile-item {
        flex: 1;
        text-align: center;
        padding: 0.75rem 0.5rem;
        font-size: 0.75rem;
        transition: all 0.2s ease;
    }

    .nav-mobile-item:active {
        transform: scale(0.95);
    }

    /* Modal improvements for mobile */
    .modal-mobile-responsive {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        margin: 0;
        border-radius: 0;
        max-width: none;
        max-height: none;
        height: 100vh;
        width: 100vw;
        overflow-y: auto;
    }

    .fixed.inset-0 .bg-white.rounded-xl {
        width: 95vw !important;
        height: 90vh !important;
        margin: 5vh auto;
        border-radius: 1rem !important;
        overflow: hidden;
    }

    /* Grid layout adjustments in modals */
    .fixed.inset-0 .grid-cols-2,
    .fixed.inset-0 .md\:grid-cols-2,
    .fixed.inset-0 .lg\:grid-cols-2,
    .fixed.inset-0 .lg\:grid-cols-3 {
        grid-template-columns: 1fr !important;
        gap: 1rem;
    }

    /* Enhanced search for mobile */
    .search-mobile {
        position: sticky;
        top: 0;
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(10px);
        z-index: 20;
        padding: 1rem;
        border-bottom: 1px solid #e2e8f0;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    }

    .search-mobile input {
        width: 100%;
        padding: 0.75rem 1rem;
        border: 1px solid #e2e8f0;
        border-radius: 0.75rem;
        font-size: 16px;
        background: white;
    }

    /* Floating action button with better positioning */
    .fab {
        position: fixed;
        bottom: 90px;
        right: 1rem;
        width: 60px;
        height: 60px;
        border-radius: 50%;
        background: linear-gradient(135deg, #3b82f6, #1d4ed8);
        color: white;
        border: none;
        box-shadow: 0 8px 25px rgba(59, 130, 246, 0.4);
        z-index: 40;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 24px;
        transition: all 0.3s ease;
    }

    .fab:active {
        transform: scale(0.9);
    }

    /* Better spacing for mobile content */
    .mobile-content {
        padding-bottom: 120px; /* Account for fixed navigation */
    }

    /* Swipe gestures support */
    .swipe-container {
        touch-action: pan-x;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Pull to refresh visual feedback */
    .pull-to-refresh {
        transform: translateY(-50px);
        opacity: 0;
        transition: all 0.3s ease;
    }

    .pull-to-refresh.active {
        transform: translateY(0);
        opacity: 1;
    }
}

@media (max-width: 480px) {
    /* Extra small mobile */
    .container {
        padding: 0 0.25rem;
    }

    /* Smaller text */
    .text-sm {
        font-size: 0.75rem;
    }

    /* Compact spacing */
    .space-y-4 > * + * {
        margin-top: 0.75rem;
    }

    .space-y-2 > * + * {
        margin-top: 0.375rem;
    }

    /* Image adjustments */
    img {
        max-width: 100%;
        height: auto;
    }

    /* Table mobile scroll */
    .table-mobile-scroll {
        display: block;
        white-space: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Modal adjustments dla bardzo małych ekranów */
    .fixed.inset-0 .bg-white.rounded-xl {
        width: 95vw !important;
        height: 95vh !important;
        margin: 2.5vh auto;
        border-radius: 8px !important;
    }

    /* Mniejsze padding w modalach na małych ekranach */
    .fixed.inset-0 .bg-white.rounded-xl .p-6 {
        padding: 1rem !important;
    }

    .fixed.inset-0 .bg-white.rounded-xl .p-4 {
        padding: 0.75rem !important;
    }

    /* Logo na bardzo małych ekranach */
    .logo-header {
        height: 1.75rem; /* 28px na bardzo małych ekranach */
        max-width: 1.75rem;
    }

    /* Modalne bazy technologów na bardzo małych ekranach */
    #detalPreviewModal .bg-white,
    #detalModal .bg-white,
    #protocolPreviewModal .bg-white,
    #maszynaModal .bg-white,
    #testNarzedziModal .bg-white,
    #importOsprzetModal .bg-white {
        width: 95vw !important;
        height: 95vh !important;
        margin: 2.5vh auto !important;
        border-radius: 8px !important;
    }

    /* Mniejsze padding w modalach technologów na małych ekranach */
    #detalPreviewModal .p-6,
    #detalModal .p-6,
    #protocolPreviewModal .px-6,
    #maszynaModal .p-6,
    #testNarzedziModal .p-6,
    #importOsprzetModal .p-6 {
        padding: 1rem !important;
    }

    /* Extra small screen form elements */
    input, select, textarea {
        color: #1f2937 !important; /* Dark gray text */
        background-color: #ffffff !important; /* White background */
        border: 1px solid #d1d5db !important; /* Light gray border */
        font-size: 16px !important; /* Prevent zoom on iOS */
    }

    input:focus, select:focus, textarea:focus {
        border-color: #3b82f6 !important;
        background-color: #ffffff !important;
    }
}

/* Camera modal styles */
#cameraModal {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

#cameraVideo {
    -webkit-transform: scaleX(-1);
    transform: scaleX(-1); /* Mirror effect for front camera */
}

#cameraModal video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Camera controls */
.camera-controls {
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.camera-btn {
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: all 0.2s ease;
}

.camera-btn:active {
    transform: scale(0.95);
}

/* Prevent scrolling when camera is open */
body.camera-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
}

/* Desktop - reset mobile classes */
@media (min-width: 768px) {
    .mobile-nav-grid {
        display: flex !important;
        gap: 1rem !important;
    }

    .mobile-nav-btn {
        display: inline-flex !important;
        align-items: center !important;
        padding: 0.5rem 1rem !important;
        font-size: 0.875rem !important;
        font-weight: 500 !important;
        min-height: auto !important;
        min-width: auto !important;
    }

    .mobile-nav-btn svg {
        width: 1rem !important;
        height: 1rem !important;
        margin-right: 0.25rem !important;
    }

    .logout-btn {
        grid-column: auto !important;
    }
}

/* Navigation mobile improvements */
@media (max-width: 767px) {
    /* Mobile navigation buttons */
    .mobile-nav-btn {
        min-height: 48px !important;
        padding: 0.75rem !important;
        font-size: 0.875rem !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 0.5rem !important;
    }

    .mobile-nav-btn svg {
        width: 1.25rem !important;
        height: 1.25rem !important;
        flex-shrink: 0;
    }

    /* Grid buttons for mobile navigation */
    .mobile-nav-grid {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.5rem !important;
        width: 100% !important;
    }

    .mobile-nav-grid.has-admin {
        grid-template-columns: 1fr 1fr 1fr !important;
    }

    .mobile-nav-grid .logout-btn {
        grid-column: span 2 !important;
    }

    .mobile-nav-grid.has-admin .logout-btn {
        grid-column: span 1 !important;
    }

    /* Hide text on very small screens, show icons only */
    @media (max-width: 480px) {
        .mobile-nav-btn span {
            display: none !important;
        }

        .mobile-nav-btn {
            min-width: 60px !important;
            padding: 0.75rem 0.5rem !important;
        }
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    /* Remove hover effects on touch devices */
    .hover\:bg-gray-50:hover,
    .hover\:bg-blue-50:hover,
    .hover\:shadow-lg:hover {
        background-color: initial;
        box-shadow: initial;
    }

    /* Enhanced touch targets - Apple HIG recommendations */
    button, .btn, a[role="button"], input[type="button"] {
        min-height: 44px !important;
        min-width: 44px !important;
        padding: 0.75rem 1rem;
        touch-action: manipulation;
    }

    /* Remove hover transforms on touch devices */
    .card-hover:hover,
    .btn-corporate-blue:hover {
        transform: none;
        box-shadow: initial;
    }

    /* Touch-friendly navigation */
    .mobile-nav-btn {
        min-height: 48px !important;
        min-width: 48px !important;
        padding: 1rem 0.75rem !important;
        font-size: 1rem !important;
    }

    /* Enhanced touch areas for small controls */
    .touch-target-large {
        min-height: 48px;
        min-width: 48px;
        padding: 0.75rem;
    }

    /* Touch scrolling improvements */
    .touch-action-pan-y {
        touch-action: pan-y;
        -webkit-overflow-scrolling: touch;
    }

    .touch-action-pan-x {
        touch-action: pan-x;
        -webkit-overflow-scrolling: touch;
    }

    /* Camera specific touch improvements */
    #cameraModal button {
        min-height: 52px;
        min-width: 52px;
        border-radius: 50%;
    }

    .camera-controls button {
        min-height: 60px;
        min-width: 60px;
        margin: 0.5rem;
    }

    /* Form elements touch optimization */
    input, select, textarea {
        min-height: 44px !important;
        padding: 1rem 0.75rem !important;
        border-radius: 0.5rem !important;
        font-size: 16px !important; /* Prevent zoom on iOS */
        color: #1f2937 !important; /* Dark gray text */
        background-color: #ffffff !important; /* White background */
        border: 1px solid #d1d5db !important; /* Light gray border */
    }

    /* Tab navigation touch optimization */
    .tab-button {
        min-height: 48px;
        padding: 0.75rem 1rem;
        border-radius: 0.5rem;
    }
}

/* Additional responsive utilities and components */

/* Responsive flex utilities */
.flex-mobile {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

@media (min-width: 768px) {
    .flex-mobile {
        flex-direction: row;
        align-items: center;
    }
}

/* Responsive grid system */
.grid-responsive-auto {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
}

@media (max-width: 640px) {
    .grid-responsive-auto {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
}

/* Mobile-first navigation system */
.mobile-nav {
    display: none;
}

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

    .desktop-nav {
        display: none;
    }
}

/* Responsive image handling */
.img-responsive {
    width: 100%;
    height: auto;
    max-width: 100%;
    object-fit: cover;
    border-radius: 0.5rem;
}

@media (max-width: 640px) {
    .img-responsive {
        max-height: 200px;
    }
}

/* Responsive text sizes */
.text-responsive-lg {
    font-size: 1.5rem;
    line-height: 1.3;
}

.text-responsive-md {
    font-size: 1.25rem;
    line-height: 1.3;
}

.text-responsive-sm {
    font-size: 1rem;
    line-height: 1.4;
}

@media (max-width: 640px) {
    .text-responsive-lg {
        font-size: 1.25rem;
    }

    .text-responsive-md {
        font-size: 1.125rem;
    }

    .text-responsive-sm {
        font-size: 0.875rem;
    }
}

/* Responsive spacing system */
.space-responsive-x > * + * {
    margin-left: 1rem;
}

.space-responsive-y > * + * {
    margin-top: 1rem;
}

@media (max-width: 640px) {
    .space-responsive-x {
        flex-direction: column;
    }

    .space-responsive-x > * + * {
        margin-left: 0;
        margin-top: 0.5rem;
    }
}

/* Container query support preparation */
.container-responsive {
    container-type: inline-size;
    width: 100%;
}

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

/* High contrast mode support */
@media (prefers-contrast: high) {
    .bg-gray-50 {
        background-color: #ffffff;
        border: 1px solid #000000;
    }

    .text-gray-600 {
        color: #000000;
    }

    button, .btn {
        border: 2px solid #000000;
    }
}

/* Dark mode preparation - but force light forms */
@media (prefers-color-scheme: dark) {
    /* Base dark mode styles - ready for implementation */
    body {
        background-color: #1a1a1a;
        color: #ffffff;
    }

    .bg-white {
        background-color: #2d2d2d;
    }

    .bg-gray-50 {
        background-color: #3d3d3d;
    }

    .bg-gray-100 {
        background-color: #4d4d4d;
    }

    .text-gray-900 {
        color: #ffffff;
    }

    .text-gray-700 {
        color: #e0e0e0;
    }

    .text-gray-500 {
        color: #a0a0a0;
    }

    .border-gray-200 {
        border-color: #4d4d4d;
    }

    .border-gray-300 {
        border-color: #6d6d6d;
    }

    /* Force form elements to stay light for visibility */
    input, select, textarea {
        color: #1f2937 !important; /* Dark text on light background */
        background-color: #ffffff !important; /* Force white background */
        border: 1px solid #d1d5db !important; /* Light border */
    }

    input:focus, select:focus, textarea:focus {
        border-color: #3b82f6 !important;
        background-color: #ffffff !important;
    }

    .modal-container input,
    .modal-container select,
    .modal-container textarea {
        color: #1f2937 !important;
        background-color: #ffffff !important;
        border: 1px solid #d1d5db !important;
    }

    .autocomplete-input {
        color: #1f2937 !important;
        background-color: #ffffff !important;
        border: 1px solid #d1d5db !important;
    }
}

/* Print styles */
@media print {
    .no-print {
        display: none !important;
    }

    body {
        background: white !important;
        color: black !important;
        font-size: 12pt;
        line-height: 1.4;
    }

    .shadow-lg,
    .shadow-xl {
        box-shadow: none !important;
    }

    /* Print styles dla modala podglądu detalu */
    #detailPreviewModal {
        position: static !important;
        background: transparent !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    #detailPreviewModal .bg-white {
        box-shadow: none !important;
        border-radius: 0 !important;
        max-width: none !important;
        max-height: none !important;
        overflow: visible !important;
    }

    /* Popraw kolory dla druku */
    .bg-slate-50,
    .bg-slate-100,
    .bg-blue-50 {
        background: #f8f9fa !important;
        border: 1px solid #dee2e6 !important;
    }

    .text-slate-700,
    .text-slate-800,
    .text-blue-800 {
        color: #212529 !important;
    }

    .text-slate-500,
    .text-slate-600 {
        color: #6c757d !important;
    }

    /* Layout adjustments dla druku */
    .grid {
        display: block !important;
    }

    .grid > div {
        margin-bottom: 20px;
    }

    .flex {
        display: block !important;
    }

    /* Obrazy w druku */
    img {
        max-width: 100% !important;
        height: auto !important;
        break-inside: avoid;
    }

    /* Zakładki w druku */
    .tab-content.hidden {
        display: block !important;
    }

    .border-b button {
        display: inline-block;
        margin-right: 10px;
        padding: 5px 10px;
        border: 1px solid #dee2e6;
        background: #f8f9fa;
        font-weight: bold;
    }
}
