/* iPhone Toolbar Adjustments */

/* Hide sidebar button when modal is open */
.modal-overlay.active ~ * .sidebar-button,
.modal-overlay.active .sidebar-button,
body:has(.modal-overlay.active) .sidebar-button {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

/* Toolbar Analysis Settings für Mobile */
@media screen and (max-width: 768px) {
    /* Zeige Toolbar Analysis Settings auf Mobile */
    .toolbar-analysis-settings {
        display: flex !important;
        position: fixed;
        left: 60px;
        top: 15px;
        transition: all 0.25s cubic-bezier(0.4, 0, 1, 1);
        opacity: 1;
        transform: translateY(0);
    }
    
    /* Verstecke Toolbar im Chat-Modus mit schneller Animation */
    body:has(#chat-container) .toolbar-analysis-settings {
        opacity: 0;
        transform: translateY(-20px);
        pointer-events: none;
    }
    
    /* Verstecke die Analysis Settings Capsule auf Mobile */
    .contract-type-capsule-container {
        display: none !important;
    }
    
    /* Verstecke auch die Desktop-Capsule im Chat-Modus falls sichtbar */
    body:has(#chat-container) .contract-type-capsule-container {
        opacity: 0;
        transform: translateY(-20px);
        pointer-events: none;
    }
    
    /* Kleinere Buttons für Mobile */
    .toolbar-setting-btn {
        padding: 5px 12px;
        height: 32px;
        min-width: auto;
    }
    
    .toolbar-setting-text {
        font-size: 13px;
        max-width: 150px;
        white-space: nowrap;
    }
}

:root {
    /* Phone Size Variables */
    --phone-ui-btn-size: 40px;
    --phone-ui-btn-icon-size: 20px;
    --phone-toolbar-capsule-height: 40px;
    --phone-toolbar-capsule-padding: 6px;
    --phone-toolbar-capsule-gap: 4px;
    --phone-toolbar-icon-size: 20px;
    --phone-toolbar-icon-btn-size: 28px;
    --phone-plus-btn-size: 40px;
    --phone-plus-btn-icon-size: 20px;
    
    /* iPhone SE Size Variables */
    --phone-se-ui-btn-size: 37px;
    --phone-se-ui-btn-icon-size: 18px;
    --phone-se-toolbar-capsule-height: 37px;
    --phone-se-toolbar-capsule-padding: 5px;
    --phone-se-toolbar-capsule-gap: 3px;
    --phone-se-toolbar-icon-size: 18px;
    --phone-se-toolbar-icon-btn-size: 27px;
    --phone-se-plus-btn-size: 37px;
    --phone-se-plus-btn-icon-size: 18px;
}

@media screen and (max-width: 428px) and (max-height: 926px) {
    :root {
        /* Smaller Toolbar Variables for iPhone */
        --ui-btn-size: var(--phone-ui-btn-size);
        --ui-btn-icon-size: var(--phone-ui-btn-icon-size);
        
        /* Toolbar Variables */
        --toolbar-carsule-height: var(--phone-toolbar-capsule-height);
        --toolbar-capsule-padding: var(--phone-toolbar-capsule-padding);
        --toolbar-capsule-gap: var(--phone-toolbar-capsule-gap);
        --toolbar-icon-size: var(--phone-toolbar-icon-size);
        --toolbar-icon-btn-size: var(--phone-toolbar-icon-btn-size);
        
        /* Plus Button Variables */
        --plus-btn-size: var(--phone-plus-btn-size);
    }
    
    /* Profile Username adjustments for iPhone */
    .profile-username {
        font-size: 12px;
        max-width: 60px;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    /* Adjust Plus Button Icon Size */
    .plus-button .btn-icon {
        width: var(--phone-plus-btn-icon-size);
        height: var(--phone-plus-btn-icon-size);
    }
    
    /* Adjust Toolbar Position for iPhone */
    .toolbar {
        top: 15px;
        right: 15px;
        gap: 6px;
    }
    
    /* Adjust Sidebar Button Position for iPhone */
    .sidebar-button {
        top: 15px;
        left: 15px;
    }
    
    .sidebar-button.sidebar-open {
        top: 5px !important;
        left: calc(100vw - 15px - var(--ui-btn-size));
    }
    
    /* Adjust Toolbar Analysis Settings for iPhone */
    .toolbar-analysis-settings {
        gap: 4px;
        left: 60px;
        top: 15px;
    }
    
    .toolbar-setting-btn {
        height: 28px;
        padding: 4px 10px;
    }
    
    .toolbar-setting-text {
        font-size: 11px;
        max-width: 120px;
        white-space: nowrap;
    }
}

/* iPhone Pro specific adjustments */
@media screen and (min-width: 376px) and (max-width: 393px) and (max-height: 852px) {
    .sidebar-button {
        top: 20px;
    }
    
    .sidebar-button.sidebar-open {
        top: 5px !important;
        left: calc(100vw - 15px - var(--ui-btn-size));
    }
    
    .toolbar {
        top: 20px;
    }
}

/* iPhone Pro Max specific adjustments */
@media screen and (min-width: 429px) and (max-width: 450px) and (max-height: 960px) {
    .sidebar-button {
        top: 15px;
    }
    
    .sidebar-button.sidebar-open {
        top: 5px !important;
        left: calc(100vw - 15px - var(--ui-btn-size));
    }
    
    .toolbar {
        top: 15px;
    }
    
    /* Mehr Abstand von links für Pro Max */
    .toolbar-analysis-settings {
        left: 75px;
    }
}

/* iPhone SE specific adjustments */
@media screen and (max-width: 375px) and (max-height: 667px) {
    :root {
        /* Even smaller for iPhone SE */
        --ui-btn-size: var(--phone-se-ui-btn-size);
        --ui-btn-icon-size: var(--phone-se-ui-btn-icon-size);
        
        /* Toolbar Variables */
        --toolbar-capsule-height: var(--phone-se-toolbar-capsule-height);
        --toolbar-capsule-padding: var(--phone-se-toolbar-capsule-padding);
        --toolbar-capsule-gap: var(--phone-se-toolbar-capsule-gap);
        --toolbar-icon-size: var(--phone-se-toolbar-icon-size);
        --toolbar-icon-btn-size: var(--phone-se-toolbar-icon-btn-size);
        
        /* Plus Button Variables */
        --plus-btn-size: var(--phone-se-plus-btn-size);
    }
    
    /* Profile Username adjustments for iPhone SE */
    .profile-username {
        font-size: 11px;
        max-width: 50px;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    /* Adjust Plus Button Icon Size for iPhone SE */
    .plus-button .btn-icon {
        width: var(--phone-se-plus-btn-icon-size);
        height: var(--phone-se-plus-btn-icon-size);
    }
    
    /* Adjust Toolbar Position for iPhone SE */
    .toolbar {
        top: 12px;
        right: 12px;
        gap: 5px;
    }
    
    /* Adjust Sidebar Button Position for iPhone SE */
    .sidebar-button {
        top: 12px;
        left: 12px;
    }
    
    .sidebar-button.sidebar-open {
        top: 5px !important;
        left: calc(100vw - 12px - var(--ui-btn-size));
    }
    
    /* Adjust Toolbar Analysis Settings for iPhone SE */
    .toolbar-analysis-settings {
        gap: 3px;
        left: 54px;
        top: 12px;
    }
    
    .toolbar-setting-btn {
        height: 26px;
        padding: 3px 8px;
    }
    
    .toolbar-setting-text {
        font-size: 10px;
        max-width: 100px;
        white-space: nowrap;
    }
}