@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

body {
    font-family: 'Inter', sans-serif;
    background-color: #f3f4f6;
}

/* Custom scrollbar for webkit */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

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

::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Sidebar background override */
.bg-gray-900 {
    background-color: #161616 !important;
}

/* Active sidebar menu item */
--sidebar-active-bg: #2d2d2d;

/* dark gray for active item */
.sidebar-active {
    background-color: var(--sidebar-active-bg) !important;
}

/* ============================================
   Image Loading Optimization
   ============================================ */

/* All images inside img-placeholder containers start invisible */
.img-placeholder img {
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

/* When image is loaded, show it */
.img-placeholder img.loaded,
img.loaded {
    opacity: 1 !important;
}

/* Placeholder shimmer animation for image containers */
.img-placeholder {
    background: linear-gradient(110deg, #e5e7eb 8%, #f3f4f6 18%, #e5e7eb 33%);
    background-size: 200% 100%;
    animation: shimmer 1.5s linear infinite;
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* ============================================
   Drag & Drop Price Rows
   ============================================ */

.price-row {
    transition: all 0.2s ease;
    position: relative;
}

.price-row.dragging {
    opacity: 0.5;
    background: #fef3c7 !important; /* amber-100 */
    border: 2px dashed #f97316 !important; /* orange-500 */
    box-shadow: none;
    transform: scale(0.98);
}

/* Drop indicator - visual line showing where item will be placed */
.price-row::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #f97316, #fb923c, #f97316);
    background-size: 200% 100%;
    border-radius: 2px;
    opacity: 0;
    transition: opacity 0.15s ease;
    pointer-events: none;
    z-index: 10;
    box-shadow: 0 0 8px rgba(249, 115, 22, 0.6);
}

.price-row::after {
    content: '↓';
    position: absolute;
    width: 20px;
    height: 20px;
    background: #f97316;
    color: white;
    font-size: 12px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.15s ease;
    pointer-events: none;
    z-index: 11;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

/* Drop target - TOP */
.price-row.drag-over-top::before {
    top: -8px;
    opacity: 1;
    animation: dropIndicatorPulse 1s ease-in-out infinite;
}

.price-row.drag-over-top::after {
    content: '↑';
    top: -16px;
    left: 50%;
    transform: translateX(-50%);
    opacity: 1;
    animation: dropIndicatorBounce 0.5s ease-in-out infinite;
}

/* Drop target - BOTTOM */
.price-row.drag-over-bottom::before {
    bottom: -8px;
    opacity: 1;
    animation: dropIndicatorPulse 1s ease-in-out infinite;
}

.price-row.drag-over-bottom::after {
    content: '↓';
    bottom: -16px;
    left: 50%;
    transform: translateX(-50%);
    opacity: 1;
    animation: dropIndicatorBounce 0.5s ease-in-out infinite;
}

/* Pulse animation for the line */
@keyframes dropIndicatorPulse {
    0%, 100% {
        background-position: 0% 50%;
        box-shadow: 0 0 8px rgba(249, 115, 22, 0.6);
    }
    50% {
        background-position: 100% 50%;
        box-shadow: 0 0 16px rgba(249, 115, 22, 0.9);
    }
}

/* Bounce animation for the arrow indicator */
@keyframes dropIndicatorBounce {
    0%, 100% {
        transform: translateX(-50%) translateY(0);
    }
    50% {
        transform: translateX(-50%) translateY(-3px);
    }
}

/* Drag handle styles */
.price-row .drag-handle {
    cursor: grab;
    touch-action: none;
    position: relative;
}

.price-row .drag-handle:active {
    cursor: grabbing;
}

/* Grip pattern (dots) for drag handle */
.price-row .drag-handle .grip-dots {
    display: flex;
    flex-direction: column;
    gap: 3px;
    align-items: center;
}

.price-row .drag-handle .grip-dots span {
    display: flex;
    gap: 3px;
}

.price-row .drag-handle .grip-dots span::before,
.price-row .drag-handle .grip-dots span::after {
    content: '';
    width: 4px;
    height: 4px;
    background: #9ca3af;
    border-radius: 50%;
    transition: background 0.2s ease;
}

.price-row .drag-handle:hover .grip-dots span::before,
.price-row .drag-handle:hover .grip-dots span::after {
    background: #f97316;
}

/* Drag handle hover effect */
.price-row .drag-handle:hover {
    background: #fff7ed !important; /* orange-50 */
}

/* Drag tooltip */
.drag-handle-tooltip {
    position: absolute;
    bottom: -24px;
    left: 50%;
    transform: translateX(-50%);
    background: #1f2937;
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
}

.price-row .drag-handle:hover .drag-handle-tooltip {
    opacity: 1;
}

/* Prevent text selection during drag */
.price-row[draggable="true"] * {
    user-select: none;
}

/* Re-enable text selection for inputs */
.price-row input {
    user-select: text;
}

/* Prices container - add spacing for drop indicators */
#pricesContainer {
    padding-top: 8px;
    padding-bottom: 8px;
}

#pricesContainer .price-row {
    margin-bottom: 12px;
}

/* Order badge styling */
.price-order-badge {
    transition: transform 0.2s ease, background-color 0.2s ease;
}

.price-order-badge.scale-110 {
    transform: scale(1.2);
    background-color: #ea580c; /* orange-600 */
}

/* First price badge highlight */
#pricesContainer .price-row:first-child .price-order-badge {
    background-color: #16a34a; /* green-600 - first/main price */
}

/* Highlight when hovering over drag handle */
.price-row .drag-handle:hover .price-order-badge {
    background-color: #c2410c; /* orange-700 */
}

/* ============================================
   Drag & Drop Gallery Images
   ============================================ */

.gallery-item {
    transition: all 0.2s ease;
    position: relative;
}

.gallery-item.dragging {
    opacity: 0.5;
    background: #fef3c7 !important; /* amber-100 */
    border: 2px dashed #f97316 !important; /* orange-500 */
    box-shadow: none;
    transform: scale(0.95);
}

/* Drop indicator - visual line showing where item will be placed */
.gallery-item::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    width: 4px;
    background: linear-gradient(180deg, #f97316, #fb923c, #f97316);
    background-size: 100% 200%;
    border-radius: 2px;
    opacity: 0;
    transition: opacity 0.15s ease;
    pointer-events: none;
    z-index: 10;
    box-shadow: 0 0 8px rgba(249, 115, 22, 0.6);
}

/* Drop target - LEFT */
.gallery-item.drag-over-left::before {
    left: -6px;
    opacity: 1;
    animation: dropIndicatorPulseVertical 1s ease-in-out infinite;
}

/* Drop target - RIGHT */
.gallery-item.drag-over-right::before {
    right: -6px;
    opacity: 1;
    animation: dropIndicatorPulseVertical 1s ease-in-out infinite;
}

/* Pulse animation for the vertical line */
@keyframes dropIndicatorPulseVertical {
    0%, 100% {
        background-position: 50% 0%;
        box-shadow: 0 0 8px rgba(249, 115, 22, 0.6);
    }
    50% {
        background-position: 50% 100%;
        box-shadow: 0 0 16px rgba(249, 115, 22, 0.9);
    }
}

/* Gallery item order badge */
.gallery-order-badge {
    position: absolute;
    top: -6px;
    left: -6px;
    width: 22px;
    height: 22px;
    background: #f97316;
    color: white;
    font-size: 11px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s ease, background-color 0.2s ease;
    z-index: 5;
}

.gallery-order-badge.scale-110 {
    transform: scale(1.2);
    background-color: #ea580c; /* orange-600 */
}

/* First gallery image badge highlight */
#galleryContainer .gallery-item:first-child .gallery-order-badge {
    background-color: #16a34a; /* green-600 - first/main image */
}

/* Gallery item drag handle overlay */
.gallery-item .gallery-drag-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    transition: background 0.2s ease;
    border-radius: 0.5rem;
}

.gallery-item .gallery-drag-overlay:active {
    cursor: grabbing;
}

.gallery-item:hover .gallery-drag-overlay {
    background: rgba(0, 0, 0, 0.3);
}

.gallery-item .gallery-drag-icon {
    opacity: 0;
    color: white;
    transition: opacity 0.2s ease;
}

.gallery-item:hover .gallery-drag-icon {
    opacity: 1;
}

/* Prevent text selection during drag */
.gallery-item[draggable="true"] * {
    user-select: none;
}

/* Gallery container - add spacing for drop indicators */
#galleryContainer {
    padding: 8px;
}

#galleryContainer .gallery-item {
    margin: 4px;
}

/* ============================================
   Wizard Steps with Connected Lines
   ============================================ */

.wizard-steps {
    padding: 0 20px;
}

.wizard-steps-container {
    display: flex;
    align-items: flex-start;
    justify-content: center;
}

.wizard-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    z-index: 2;
}

.wizard-step-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #e5e7eb; /* gray-200 */
    color: #6b7280; /* gray-500 */
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    transition: all 0.3s ease;
    border: 3px solid #e5e7eb;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.wizard-step-circle.active {
    background: #f97316; /* orange-500 */
    color: white;
    border-color: #f97316;
    box-shadow: 0 0 0 4px rgba(249, 115, 22, 0.2), 0 4px 8px rgba(249, 115, 22, 0.3);
    transform: scale(1.05);
}

.wizard-step-circle.completed {
    background: #22c55e; /* green-500 */
    color: white;
    border-color: #22c55e;
    box-shadow: 0 2px 6px rgba(34, 197, 94, 0.3);
}

.wizard-step-label {
    margin-top: 8px;
    font-size: 12px;
    font-weight: 500;
    color: #9ca3af; /* gray-400 */
    text-align: center;
    transition: color 0.3s ease;
    white-space: nowrap;
}

.wizard-step-circle.active + .wizard-step-label,
.wizard-step:has(.wizard-step-circle.active) .wizard-step-label {
    color: #f97316;
    font-weight: 600;
}

.wizard-step-circle.completed + .wizard-step-label,
.wizard-step:has(.wizard-step-circle.completed) .wizard-step-label {
    color: #22c55e;
    font-weight: 600;
}

/* Connector line between steps */
.wizard-connector {
    flex: 1;
    height: 4px;
    background: #e5e7eb; /* gray-200 */
    margin: 18px 8px 0 8px; /* Align with circle center */
    border-radius: 2px;
    position: relative;
    overflow: hidden;
    min-width: 60px;
    max-width: 120px;
}

.wizard-connector-progress {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    background: linear-gradient(90deg, #22c55e, #4ade80); /* green gradient */
    border-radius: 2px;
    transition: width 0.4s ease;
}

/* Animation for connector fill */
.wizard-connector-progress.animating {
    animation: connectorFill 0.4s ease forwards;
}

@keyframes connectorFill {
    from {
        width: 0%;
    }
    to {
        width: 100%;
    }
}

/* Pulse animation for active step */
@keyframes wizardPulse {
    0%, 100% {
        box-shadow: 0 0 0 4px rgba(249, 115, 22, 0.2), 0 4px 8px rgba(249, 115, 22, 0.3);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(249, 115, 22, 0.1), 0 4px 12px rgba(249, 115, 22, 0.4);
    }
}

.wizard-step-circle.active {
    animation: wizardPulse 2s ease-in-out infinite;
}

/* Check icon in completed steps */
.wizard-step-circle.completed svg {
    width: 18px;
    height: 18px;
    stroke-width: 3;
}

/* ============================================
   Responsive Table Scrolling
   ============================================ */

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

/* Ensure tables don't shrink below their content */
.table-container table {
    min-width: 100%;
}

/* Main content scrollable area */
main {
    overflow-x: hidden;
}

/* Cards grid container - allow wrapping */
.cards-grid {
    overflow-x: auto;
}

/* Responsive scroll indicator shadow */
.table-container {
    position: relative;
}

.table-container::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 30px;
    background: linear-gradient(to right, transparent, rgba(255,255,255,0.8));
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
}

.table-container.has-scroll::after {
    opacity: 1;
}

/* Mobile-friendly scroll hint */
@media (max-width: 1024px) {
    .table-container {
        margin: 0 -1rem;
        padding: 0 1rem;
    }
    
    .scroll-hint {
        display: block;
        text-align: center;
        font-size: 0.75rem;
        color: #9ca3af;
        padding: 0.5rem;
    }
    
    .scroll-hint::before {
        content: '← Görgess oldalra →';
    }
}

/* ============================================
   Sidebar Navigation Scrolling
   ============================================ */

/* Sidebar nav should scroll when too many items */
aside nav {
    max-height: calc(100vh - 10rem);
    overflow-y: auto;
    overflow-x: hidden;
}

/* Custom scrollbar for sidebar */
aside nav::-webkit-scrollbar {
    width: 4px;
}

aside nav::-webkit-scrollbar-track {
    background: transparent;
}

aside nav::-webkit-scrollbar-thumb {
    background: #4b5563;
    border-radius: 2px;
}

aside nav::-webkit-scrollbar-thumb:hover {
    background: #6b7280;
}

/* ============================================
   Modal Content Scrolling
   ============================================ */

/* Ensure modal content areas can scroll */
.modal-content-scroll {
    max-height: calc(90vh - 8rem);
    overflow-y: auto;
}

/* ============================================
   Grid Container Overflow
   ============================================ */

/* Stats cards and grid items should wrap properly */
@media (max-width: 640px) {
    .grid {
        overflow-x: visible;
    }
}

/* ============================================
   Search Results Dropdown
   ============================================ */

#offerSearchResults {
    scrollbar-width: thin;
    scrollbar-color: #d1d5db transparent;
}

#offerSearchResults::-webkit-scrollbar {
    width: 6px;
}

#offerSearchResults::-webkit-scrollbar-track {
    background: transparent;
}

#offerSearchResults::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

#offerSearchResults::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Featured badge animation */
.featured-badge {
    animation: featuredPulse 2s ease-in-out infinite;
}

@keyframes featuredPulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(249, 115, 22, 0.4);
    }
    50% {
        box-shadow: 0 0 0 6px rgba(249, 115, 22, 0);
    }
}

/* ============================================
   Read-Only Mode for Partner Admin
   ============================================ */

/* Visual indicator that the modal is in read-only mode */
.read-only-mode .bg-white {
    background-color: #fafafa !important;
}

/* Add a subtle banner/indicator for read-only mode */
.read-only-mode #modalTitle::after {
    content: ' (Csak megtekintés)';
    font-size: 0.75rem;
    font-weight: normal;
    color: #f97316;
    margin-left: 8px;
    padding: 2px 8px;
    background-color: #fff7ed;
    border-radius: 4px;
}

/* Disabled inputs visual style enhancement */
.read-only-mode input:disabled,
.read-only-mode select:disabled,
.read-only-mode textarea:disabled {
    background-color: #f3f4f6 !important;
    color: #4b5563 !important;
    cursor: not-allowed !important;
    border-color: #e5e7eb !important;
}

/* Hide action buttons in read-only mode */
.read-only-mode button[onclick*="addPriceRow"],
.read-only-mode button[onclick*="removePriceRow"],
.read-only-mode button[onclick*="removeGalleryImage"] {
    display: none !important;
}

/* Hide dropzones in read-only mode */
.read-only-mode #coverImageDropzone,
.read-only-mode #galleryDropzone {
    pointer-events: none;
    opacity: 0.7;
}

.read-only-mode #coverImagePlaceholder,
.read-only-mode #galleryDropzone {
    display: none !important;
}

/* Disable drag handles in read-only mode */
.read-only-mode .drag-handle {
    pointer-events: none;
    opacity: 0.5;
}

.read-only-mode .gallery-drag-overlay {
    display: none !important;
}

/* ============================================
   Mobile Responsive Design
   ============================================ */

/* Sidebar Overlay */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 25;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* Hamburger Button - hidden on desktop */
.hamburger-btn {
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    border-radius: 0.5rem;
    color: #374151;
    transition: background-color 0.2s;
}

.hamburger-btn:hover {
    background-color: #f3f4f6;
}

.hamburger-btn:active {
    background-color: #e5e7eb;
}

/* Mobile styles - 640px and below */
@media (max-width: 640px) {
    /* Show hamburger button on mobile */
    .hamburger-btn {
        display: flex;
    }
    
    /* Sidebar - hidden by default on mobile, slides in when open */
    #sidebar {
        transform: translateX(-100%);
    }
    
    #sidebar.open {
        transform: translateX(0);
    }
    
    /* Main content - no left margin on mobile */
    main {
        margin-left: 0 !important;
        padding: 1rem !important;
    }
    
    /* Header adjustments */
    header {
        flex-wrap: wrap;
    }
    
    header h2 {
        font-size: 1.5rem !important;
    }
    
    /* Stats cards - single column on mobile */
    .stats-grid {
        grid-template-columns: 1fr !important;
    }
    
    /* Wizard steps - smaller on mobile */
    .wizard-steps {
        padding: 0 8px;
    }
    
    .wizard-step-circle {
        width: 28px;
        height: 28px;
        font-size: 11px;
    }
    
    .wizard-step-label {
        font-size: 9px;
    }
    
    .wizard-connector {
        min-width: 20px;
        max-width: 40px;
        margin: 12px 3px 0 3px;
    }
    
    /* Tabs - scrollable on mobile */
    .tabs-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .tabs-container::-webkit-scrollbar {
        display: none;
    }
    
    /* Form grid - single column on mobile */
    .form-grid-2 {
        grid-template-columns: 1fr !important;
    }
    
    /* Modal adjustments for mobile */
    .modal-content {
        margin: 0 !important;
        max-height: 100vh !important;
        border-radius: 0 !important;
    }
    
    /* Touch-friendly button sizes */
    button, 
    .btn,
    [role="button"] {
        min-height: 44px;
    }
    
    /* Touch-friendly input sizes */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="tel"],
    input[type="url"],
    input[type="number"],
    input[type="date"],
    input[type="datetime-local"],
    select,
    textarea {
        min-height: 44px;
        font-size: 16px; /* Prevents iOS zoom on focus */
    }
    
    /* Cards responsive padding */
    .card-padding {
        padding: 1rem !important;
    }
    
    /* Table to card view */
    .table-responsive-cards thead {
        display: none;
    }
    
    .table-responsive-cards tbody {
        display: block;
    }
    
    .table-responsive-cards tr {
        display: block;
        margin-bottom: 1rem;
        background: white;
        border-radius: 0.5rem;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
        padding: 1rem;
    }
    
    .table-responsive-cards td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.5rem 0;
        border: none !important;
        border-bottom: 1px solid #f3f4f6 !important;
    }
    
    .table-responsive-cards td:last-child {
        border-bottom: none !important;
    }
    
    .table-responsive-cards td::before {
        content: attr(data-label);
        font-weight: 600;
        font-size: 0.75rem;
        color: #6b7280;
        text-transform: uppercase;
        margin-right: 1rem;
    }
}

/* Mobile Card View for Tables - Compact */
.mobile-card {
    background: white;
    border-radius: 0.5rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
    padding: 0.625rem;
    margin-bottom: 0.5rem;
}

.mobile-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.375rem;
    padding-bottom: 0.375rem;
    border-bottom: 1px solid #f3f4f6;
}

.mobile-card-title {
    font-weight: 600;
    color: #1f2937;
    font-size: 0.875rem;
    line-height: 1.2;
}

.mobile-card-subtitle {
    font-size: 0.75rem;
    color: #6b7280;
    margin-top: 0;
    line-height: 1.2;
}

.mobile-card-body {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.mobile-card-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8125rem;
    padding: 0.125rem 0;
}

.mobile-card-label {
    color: #6b7280;
    font-size: 0.75rem;
}

.mobile-card-value {
    color: #1f2937;
    font-weight: 500;
    text-align: right;
    font-size: 0.8125rem;
}

.mobile-card-actions {
    display: flex;
    gap: 0.375rem;
    margin-top: 0.375rem;
    padding-top: 0.375rem;
    border-top: 1px solid #f3f4f6;
}

.mobile-card-actions button {
    flex: 1;
    justify-content: center;
    min-height: 36px;
    font-size: 0.8125rem;
}

/* Status badges in mobile cards */
.mobile-card .status-badge {
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.6875rem;
    font-weight: 500;
}

/* Compact status badges in card headers */
.mobile-card-header .rounded-full {
    padding: 0.125rem 0.5rem !important;
    font-size: 0.6875rem !important;
}

/* Tablet adjustments - 641px to 1024px */
@media (min-width: 641px) and (max-width: 1024px) {
    /* Slightly smaller sidebar margin for tablets */
    main {
        padding: 1.5rem !important;
    }
    
    /* 2 column grid for cards */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* Ensure smooth transitions */
#sidebar {
    transition: transform 0.3s ease-in-out;
}

/* Hide desktop-only elements on mobile */
@media (max-width: 640px) {
    .desktop-only {
        display: none !important;
    }
}

/* Hide mobile-only elements on desktop */
@media (min-width: 641px) {
    .mobile-only {
        display: none !important;
    }
}

/* Mobile search bar full width */
@media (max-width: 640px) {
    .search-container {
        width: 100% !important;
    }
    
    .search-container input {
        width: 100%;
    }
}

/* Mobile toolbar stacking */
@media (max-width: 640px) {
    .toolbar-container {
        flex-direction: column !important;
        gap: 1rem !important;
    }
    
    .toolbar-actions {
        width: 100%;
        justify-content: space-between !important;
    }
}

/* Safe area for notched devices */
@supports (padding-top: env(safe-area-inset-top)) {
    .mobile-safe-area {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
}

/* ============================================
   Mobile Modal Optimization
   ============================================ */

@media (max-width: 640px) {
    /* Modal takes full screen on mobile */
    .fixed.inset-0.z-50 > div:last-child {
        margin: 0 !important;
        max-width: 100% !important;
        width: 100% !important;
        max-height: 100vh !important;
        height: 100% !important;
        border-radius: 0 !important;
    }
    
    /* Modal content area */
    .fixed.inset-0.z-50 .bg-white.rounded-lg {
        border-radius: 0 !important;
    }
    
    /* Modal buttons - stack on mobile */
    .fixed.inset-0.z-50 .bg-gray-50.px-4.py-3 {
        flex-direction: column-reverse !important;
        gap: 0.5rem !important;
    }
    
    .fixed.inset-0.z-50 .bg-gray-50.px-4.py-3 button {
        width: 100% !important;
        margin: 0 !important;
        min-height: 48px;
    }
    
    /* Form sections - single column */
    .fixed.inset-0.z-50 .grid.grid-cols-2,
    .fixed.inset-0.z-50 .grid.md\:grid-cols-2,
    .fixed.inset-0.z-50 .grid.lg\:grid-cols-2 {
        grid-template-columns: 1fr !important;
    }
    
    /* Date inputs - single column on mobile too */
    .fixed.inset-0.z-50 .grid.grid-cols-2.gap-3 {
        grid-template-columns: 1fr !important;
        gap: 0.5rem !important;
    }
    
    /* Modal wrapper - reduced padding on mobile */
    #offerModal > div:first-child {
        padding-left: 0 !important;
        padding-right: 0 !important;
        padding-top: 0 !important;
        padding-bottom: 0 !important;
    }
    
    /* Modal content - reduced padding on mobile */
    .fixed.inset-0.z-50 .bg-white.px-4,
    #offerModal .bg-white.px-4 {
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
    }
    
    /* Modal inner container - remove margin */
    .fixed.inset-0.z-50 .sm\:ml-4,
    #offerModal .sm\:ml-4 {
        margin-left: 0 !important;
    }
    
    /* Wizard modal - prevent horizontal overflow */
    #offerModal .step-content {
        overflow-x: hidden;
        max-width: 100%;
    }
    
    /* Date/time inputs - smaller text on mobile */
    #offerModal input[type="datetime-local"],
    #offerModal input[type="date"] {
        font-size: 13px !important;
        padding: 0.375rem 0.5rem !important;
    }
    
    /* Gray box in form - reduce padding */
    #offerModal .bg-gray-50.p-4 {
        padding: 0.75rem !important;
    }
    
    /* Section headers - smaller on mobile */
    #offerModal .text-sm.font-semibold.uppercase {
        font-size: 0.7rem !important;
    }
}

/* Modal scroll behavior */
.fixed.inset-0.z-50 .overflow-y-auto {
    -webkit-overflow-scrolling: touch;
}

/* Ensure modal header stays visible */
@media (max-width: 640px) {
    .fixed.inset-0.z-50 [role="dialog"] {
        display: flex;
        flex-direction: column;
    }
    
    .fixed.inset-0.z-50 [role="dialog"] > .bg-white {
        flex: 1;
        overflow-y: auto;
    }
    
    .fixed.inset-0.z-50 [role="dialog"] > .bg-gray-50 {
        flex-shrink: 0;
        position: sticky;
        bottom: 0;
        border-top: 1px solid #e5e7eb;
    }
}

/* Larger touch targets for form elements in modals */
@media (max-width: 640px) {
    .fixed.inset-0.z-50 input,
    .fixed.inset-0.z-50 select,
    .fixed.inset-0.z-50 textarea {
        min-height: 48px !important;
        font-size: 16px !important; /* Prevents iOS zoom */
    }
    
    .fixed.inset-0.z-50 label {
        font-size: 0.875rem;
        margin-bottom: 0.5rem;
        display: block;
    }
}

/* Finances page tabs - scrollable on mobile */
@media (max-width: 640px) {
    .flex.border-b.border-gray-200 {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    
    .flex.border-b.border-gray-200::-webkit-scrollbar {
        display: none;
    }
    
    .flex.border-b.border-gray-200 button {
        flex-shrink: 0;
        white-space: nowrap;
        padding-left: 1rem;
        padding-right: 1rem;
    }
}

/* Partner statistics filters - stack on mobile */
@media (max-width: 640px) {
    .grid.grid-cols-1.md\:grid-cols-4 {
        gap: 1rem !important;
    }
    
    .grid.grid-cols-1.md\:grid-cols-4 > div {
        margin-bottom: 0;
    }
}

/* Charts responsive */
@media (max-width: 640px) {
    .relative.h-80 {
        height: 250px !important;
    }
}

/* ============================================
   Extra Small Screens (below 400px)
   ============================================ */

@media (max-width: 400px) {
    /* Wizard - hide labels on very small screens */
    .wizard-step-label {
        display: none;
    }
    
    /* Wizard - even smaller circles */
    .wizard-step-circle {
        width: 24px;
        height: 24px;
        font-size: 10px;
        border-width: 2px;
    }
    
    /* Wizard - smaller connectors */
    .wizard-connector {
        min-width: 16px;
        max-width: 32px;
        height: 3px;
        margin: 10px 2px 0 2px;
    }
    
    /* Wizard steps container - minimal padding */
    .wizard-steps {
        padding: 0 4px;
    }
    
    /* Modal - minimal padding */
    #offerModal .bg-white.px-4 {
        padding-left: 0.375rem !important;
        padding-right: 0.375rem !important;
    }
    
    /* Form labels - smaller */
    #offerModal label {
        font-size: 0.75rem !important;
    }
    
    /* Date/time inputs - even smaller */
    #offerModal input[type="datetime-local"],
    #offerModal input[type="date"] {
        font-size: 12px !important;
        padding: 0.25rem 0.375rem !important;
    }
    
    /* Gray box - minimal padding */
    #offerModal .bg-gray-50.p-4 {
        padding: 0.5rem !important;
    }
}