/* ==========================================
   Mobile Touch Feedback Styles
   ========================================== */

/* Touch Ripple-Effekt */
.touch-ripple {
    position: fixed;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(59, 130, 246, 0.4) 0%, rgba(59, 130, 246, 0) 70%);
    pointer-events: none;
    transform: translate(-50%, -50%) scale(0);
    animation: ripple-animation 0.6s ease-out;
    z-index: 9999;
}

@keyframes ripple-animation {
    0% {
        transform: translate(-50%, -50%) scale(0);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(2);
        opacity: 0;
    }
}

/* Touch Active States für Buttons */
@media (hover: none) and (pointer: coarse) {
    /* Nur auf Touch-Geräten */
    
    .btn:active,
    .tool-btn:active {
        transform: scale(0.95);
        transition: transform 0.1s ease;
    }
    
    .btn-primary:active {
        background: #2563eb;
    }
    
    .btn-secondary:active {
        background: #4b5563;
    }
    
    .btn-danger:active {
        background: #dc2626;
    }
}

/* Touch Highlight Prevention (verhindert grauen Overlay auf Mobile) */
* {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}

/* Touch-optimierte Input-Felder (verhindert Auto-Zoom auf iOS) */
@media (max-width: 768px) {
    input[type="text"],
    input[type="email"],
    input[type="number"],
    input[type="search"],
    textarea,
    select {
        font-size: 16px !important; /* Verhindert Auto-Zoom auf iOS */
    }
}

/* Touch-optimierte Canvas-Interaktion */
.editor-canvas {
    touch-action: none; /* Verhindert Browser-Zoom/Scroll */
    user-select: none; /* Verhindert Text-Selektion */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* Loading-Feedback für Touch-Aktionen */
.touch-loading {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 16px 24px;
    border-radius: 12px;
    font-size: 14px;
    z-index: 10000;
    pointer-events: none;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translate(-50%, -50%) scale(0.9); }
    to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* Touch-optimierte Toolbar */
@media (max-width: 768px) {
    .editor-toolbar {
        padding: 12px 8px;
        gap: 8px;
    }
    
    .tool-btn {
        min-width: 44px !important;
        min-height: 44px !important;
        padding: 10px;
        font-size: 16px;
    }
    
    .tool-group {
        gap: 8px;
    }
}

/* Touch-optimierte Properties Panel */
@media (max-width: 768px) {
    .properties-toolbar {
        padding: 12px;
        min-height: 60px;
    }
    
    .property-group {
        padding: 8px 12px;
        min-height: 44px;
    }
    
    .property-label {
        font-size: 12px;
        min-width: 60px;
    }
    
    /* Größere Touch-Targets für Inputs */
    .properties-toolbar input[type="color"] {
        width: 44px;
        height: 44px;
        cursor: pointer;
    }
    
    .properties-toolbar input[type="range"] {
        min-height: 44px;
        cursor: pointer;
    }
    
    .properties-toolbar select {
        min-height: 44px;
        font-size: 14px;
        padding: 8px 12px;
        cursor: pointer;
    }
}

/* Touch-optimierte Resize-Handles */
@media (hover: none) and (pointer: coarse) {
    .resize-handle {
        width: 20px !important;
        height: 20px !important;
        background: #3b82f6;
        border: 3px solid white;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    }
    
    .rotate-handle {
        width: 24px !important;
        height: 24px !important;
        background: #10b981;
        border: 3px solid white;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    }
}

/* Touch-Feedback für Annotation-Selektion */
.annotation-selected-touch {
    animation: pulse-selection 0.3s ease-out;
}

@keyframes pulse-selection {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* Toast-Benachrichtigungen für Touch (größer, besser lesbar) */
@media (max-width: 768px) {
    .notification {
        font-size: 16px !important;
        padding: 14px 20px !important;
        min-width: 280px;
        border-radius: 12px;
    }
}

/* Safe Area Insets für iPhone X und neuer */
@supports (padding: env(safe-area-inset-top)) {
    .editor-container {
        padding-top: max(8px, env(safe-area-inset-top));
        padding-bottom: max(8px, env(safe-area-inset-bottom));
        padding-left: max(8px, env(safe-area-inset-left));
        padding-right: max(8px, env(safe-area-inset-right));
    }
    
    .modal-content {
        padding-top: max(16px, env(safe-area-inset-top));
        padding-bottom: max(16px, env(safe-area-inset-bottom));
    }
}

/* Verhindere Overscroll (Bounce-Effekt) auf iOS */
@media (max-width: 768px) {
    body {
        overscroll-behavior: none;
        -webkit-overflow-scrolling: touch;
    }
    
    .modal-content {
        overscroll-behavior: contain;
    }
}

/* Touch-optimierte Scrollbars (nur wenn nötig) */
@media (hover: none) and (pointer: coarse) {
    ::-webkit-scrollbar {
        width: 8px;
        height: 8px;
    }
    
    ::-webkit-scrollbar-track {
        background: transparent;
    }
    
    ::-webkit-scrollbar-thumb {
        background: rgba(0, 0, 0, 0.2);
        border-radius: 4px;
    }
    
    ::-webkit-scrollbar-thumb:active {
        background: rgba(0, 0, 0, 0.4);
    }
}

/* ==========================================
   Phase 2: Mobile Editor Layout (V3)
   ========================================== */

/* Fullscreen Editor auf Mobile */
@media (max-width: 768px) {
    /* Editor Container */
    .editor-container-v3 {
        width: 100vw !important;
        height: 100vh !important;
    }
    
    /* Canvas Area */
    .canvas-area {
        padding: 60px 10px 90px 10px !important;
    }
    
    /* Toolbar OBEN statt links - horizontal scrollbar */
    .toolbar-floating {
        position: fixed !important;
        top: 8px !important;
        left: 8px !important;
        right: 8px !important;
        transform: none !important;
        flex-direction: row !important;
        width: calc(100vw - 16px) !important;
        max-width: calc(100vw - 16px) !important;
        height: auto !important;
        max-height: 60px !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        -webkit-overflow-scrolling: touch;
        padding: 6px !important;
        gap: 4px !important;
    }
    
    /* Tool-Buttons größer für Touch */
    .tool-btn {
        min-width: 44px !important;
        min-height: 44px !important;
        width: 44px !important;
        height: 44px !important;
        flex-shrink: 0 !important;
        font-size: 18px !important;
    }
    
    /* Tool-Divider horizontal */
    .tool-divider {
        width: 2px !important;
        height: 32px !important;
        margin: 0 2px !important;
        flex-shrink: 0 !important;
    }
    
    /* Properties Panel als Bottom-Drawer - KLEIN! */
    .properties-panel {
        position: fixed !important;
        bottom: 60px !important;
        left: 0 !important;
        right: 0 !important;
        top: auto !important;
        transform: none !important;
        width: 100% !important;
        max-width: 100% !important;
        max-height: 56px !important; /* Sehr klein - wie Toolbar! */
        border-radius: 16px 16px 0 0 !important;
        padding: 6px 8px !important;
        transition: bottom 0.3s ease;
        overflow-x: auto !important; /* Horizontal scrollbar! */
        overflow-y: hidden !important;
        -webkit-overflow-scrolling: touch;
        display: flex !important;
        flex-direction: row !important; /* Horizontal statt vertikal! */
        gap: 8px !important;
        white-space: nowrap;
    }
    
    /* Property Groups horizontal nebeneinander */
    .property-group {
        flex-shrink: 0 !important;
        flex-direction: row !important;
        align-items: center !important;
        gap: 8px !important;
        padding: 4px 8px !important;
        min-width: auto !important;
    }
    
    /* WICHTIG: display wird von PropertiesManager kontrolliert */
    .property-group[style*="display: none"] {
        display: none !important;
    }
    
    /* Nur sichtbare Groups als inline-flex */
    .property-group:not([style*="display: none"]) {
        display: inline-flex !important;
    }
    
    .property-label {
        white-space: nowrap !important;
        font-size: 11px !important;
        min-width: auto !important;
    }
    
    .property-input {
        max-width: 80px !important;
        min-width: 60px !important;
    }
    
    /* Properties Panel versteckt */
    .properties-panel:not(.open) {
        bottom: -200px !important;
    }
    
    /* Properties Toggle Button oben */
    .properties-toggle {
        position: absolute !important;
        top: -36px !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        border-radius: 8px 8px 0 0 !important;
        width: 80px !important;
        height: 36px !important;
    }
    
    /* Action Buttons unten rechts - GENAU WIE DESKTOP */
    .action-buttons {
        position: fixed !important;
        bottom: 12px !important;
        top: auto !important; /* Wichtig: überschreibt V3 default */
        right: 12px !important;
        left: auto !important;
    }
    
    /* Schließen-Button normal wie Desktop - KEINE Anpassungen! */
    /* Alle Mobile-Overrides entfernen */
    
    /* Zoom Controls */
    .zoom-controls {
        bottom: 12px !important;
        left: 12px !important;
        right: auto !important;
        transform: none !important;
    }
}

/* Extra kleine Geräte (< 375px) */
@media (max-width: 375px) {
    .tool-btn {
        min-width: 40px !important;
        min-height: 40px !important;
        font-size: 16px !important;
    }
    
    .editor-toolbar {
        padding: 6px !important;
    }
}

/* Landscape-Modus auf Mobile */
@media (max-width: 896px) and (orientation: landscape) {
    /* Toolbar OBEN horizontal */
    .toolbar-floating {
        position: fixed !important;
        top: 8px !important;
        left: 8px !important;
        right: 8px !important;
        transform: none !important;
        flex-direction: row !important;
        width: calc(100vw - 16px) !important;
        max-width: calc(100vw - 16px) !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        height: auto !important;
        max-height: 56px !important;
    }
    
    .tool-btn {
        min-width: 44px !important;
        min-height: 44px !important;
        width: 44px !important;
        height: 44px !important;
        flex-shrink: 0 !important;
    }
    
    .tool-divider {
        width: 2px !important;
        height: 32px !important;
        flex-shrink: 0 !important;
    }
    
    /* Properties Panel unten - noch kleiner */
    .properties-panel {
        position: fixed !important;
        bottom: 56px !important;
        left: 0 !important;
        right: 0 !important;
        top: auto !important;
        width: 100% !important;
        max-height: 52px !important; /* Noch kleiner! */
        border-radius: 12px 12px 0 0 !important;
        padding: 6px 8px !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        display: flex !important;
        flex-direction: row !important;
        gap: 8px !important;
    }
    
    .property-group {
        flex-shrink: 0 !important;
        flex-direction: row !important;
        align-items: center !important;
        gap: 6px !important;
        padding: 4px 6px !important;
    }
    
    .property-group[style*="display: none"] {
        display: none !important;
    }
    
    .property-group:not([style*="display: none"]) {
        display: inline-flex !important;
    }
    
    .property-label {
        font-size: 10px !important;
        white-space: nowrap !important;
    }
    
    .property-input {
        max-width: 70px !important;
        min-width: 50px !important;
    }
    
    .properties-panel:not(.open) {
        bottom: -200px !important;
    }
    
    /* Canvas mehr Platz */
    .canvas-area {
        padding: 70px 10px 80px 10px !important;
    }
    
    /* Action Buttons UNTEN rechts */
    .action-buttons {
        bottom: 12px !important;
        top: auto !important;
        right: 12px !important;
        left: auto !important;
    }
}

/* Tablet-Optimierung (768px - 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
    /* Toolbar OBEN horizontal auf Tablet Hochformat */
    .toolbar-floating {
        position: fixed !important;
        top: 10px !important;
        left: 10px !important;
        right: 10px !important;
        transform: none !important;
        flex-direction: row !important;
        width: calc(100vw - 20px) !important;
        max-width: calc(100vw - 20px) !important;
        overflow-x: auto !important;
        height: auto !important;
        max-height: 60px !important;
    }
    
    .tool-btn {
        min-width: 48px !important;
        min-height: 48px !important;
        width: 48px !important;
        height: 48px !important;
        flex-shrink: 0 !important;
    }
    
    .tool-divider {
        width: 2px !important;
        height: 36px !important;
        flex-shrink: 0 !important;
    }
    
    /* Properties Panel unten */
    .properties-panel {
        position: fixed !important;
        bottom: 60px !important;
        left: 0 !important;
        right: 0 !important;
        top: auto !important;
        width: 100% !important;
        max-height: 56px !important; /* Wie Toolbar! */
        border-radius: 16px 16px 0 0 !important;
        padding: 6px 8px !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        display: flex !important;
        flex-direction: row !important;
        gap: 8px !important;
    }
    
    .property-group {
        flex-shrink: 0 !important;
        flex-direction: row !important;
        align-items: center !important;
        gap: 8px !important;
        padding: 4px 8px !important;
    }
    
    .property-group[style*="display: none"] {
        display: none !important;
    }
    
    .property-group:not([style*="display: none"]) {
        display: inline-flex !important;
    }
    
    .property-label {
        font-size: 11px !important;
        white-space: nowrap !important;
    }
    
    .property-input {
        max-width: 80px !important;
        min-width: 60px !important;
    }
    
    .properties-panel:not(.open) {
        bottom: -250px !important;
    }
    
    /* Canvas Padding anpassen */
    .canvas-area {
        padding: 80px 15px 100px 15px !important;
    }
    
    /* Action Buttons UNTEN rechts */
    .action-buttons {
        bottom: 12px !important;
        top: auto !important;
        right: 12px !important;
        left: auto !important;
    }
}
