/* 🎯 Drei-Punkte Dropdown-Menü für Rechnungen */
/* Elegante Alternative zu vielen Buttons */

/* Import FontAwesome for icons */
@import url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css');

/* Dropdown Container */
.dropdown-menu-container {
    position: relative;
    display: inline-block;
}

/* Drei-Punkte Button */
.dropdown-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    border-radius: 6px;
    background: #f8fafc;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 16px;
    line-height: 1;
    position: relative;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.dropdown-toggle:hover {
    background: #f1f5f9;
    color: #475569;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

.dropdown-toggle:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.dropdown-toggle.active {
    background: #3b82f6;
    color: white;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

/* Drei-Punkte Icon - using FontAwesome instead of pseudo-element */
/* Removed ::before pseudo-element to prevent duplicate icons */
.dropdown-toggle i {
    font-size: 16px;
    line-height: 1;
}

/* Dropdown Menu */
.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    z-index: 1000;
    min-width: 200px;
    margin-top: 4px;
    padding: 6px 0;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 
        0 10px 25px -5px rgba(0, 0, 0, 0.1),
        0 4px 6px -2px rgba(0, 0, 0, 0.05);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(8px);
}

/* Dropdown Menu - Open Upward when space is limited */
.dropdown-menu.dropup {
    top: auto;
    bottom: 100%;
    margin-top: 0;
    margin-bottom: 4px;
    transform: translateY(8px);
}

.dropdown-menu.dropup.show {
    transform: translateY(0);
}

.dropdown-menu.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Arrow pointer */
.dropdown-menu::before {
    content: '';
    position: absolute;
    top: -6px;
    right: 12px;
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 6px solid white;
    filter: drop-shadow(0 -2px 2px rgba(0, 0, 0, 0.1));
}

/* Arrow pointer for dropup */
.dropdown-menu.dropup::before {
    top: auto;
    bottom: -6px;
    border-bottom: none;
    border-top: 6px solid white;
    filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.1));
}

/* Menu Items */
.dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 16px;
    border: none;
    background: none;
    color: #374151;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.15s ease;
    border-radius: 0;
}

.dropdown-item:hover {
    background: #f8fafc;
    color: #1e293b;
    transform: none;
}

.dropdown-item:active {
    background: #f1f5f9;
}

/* Item Icons */
.dropdown-item i {
    flex-shrink: 0;
    width: 16px;
    text-align: center;
    font-size: 14px;
    opacity: 0.7;
}

/* Item Text */
.dropdown-item-text {
    flex: 1;
}

/* Color Variants für verschiedene Aktionen */
.dropdown-item.primary {
    color: #3b82f6;
}

.dropdown-item.primary:hover {
    background: #eff6ff;
    color: #2563eb;
}

.dropdown-item.primary i {
    color: #3b82f6;
    opacity: 0.8;
}

.dropdown-item.success {
    color: #10b981;
}

.dropdown-item.success:hover {
    background: #ecfdf5;
    color: #059669;
}

.dropdown-item.success i {
    color: #10b981;
    opacity: 0.8;
}

.dropdown-item.warning {
    color: #f59e0b;
}

.dropdown-item.warning:hover {
    background: #fffbeb;
    color: #d97706;
}

.dropdown-item.warning i {
    color: #f59e0b;
    opacity: 0.8;
}

.dropdown-item.danger {
    color: #ef4444;
}

.dropdown-item.danger:hover {
    background: #fef2f2;
    color: #dc2626;
}

.dropdown-item.danger i {
    color: #ef4444;
    opacity: 0.8;
}

.dropdown-item.info {
    color: #06b6d4;
}

.dropdown-item.info:hover {
    background: #f0fdfa;
    color: #0891b2;
}

.dropdown-item.info i {
    color: #06b6d4;
    opacity: 0.8;
}

.dropdown-item.orange {
    color: #f97316;
}

.dropdown-item.orange:hover {
    background: #fff7ed;
    color: #ea580c;
}

.dropdown-item.orange i {
    color: #f97316;
    opacity: 0.8;
}

/* Divider */
.dropdown-divider {
    height: 1px;
    margin: 6px 0;
    background: #e2e8f0;
    border: none;
}

/* Disabled State */
.dropdown-item:disabled,
.dropdown-item.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* Mobile Optimierungen */
@media (max-width: 768px) {
    .dropdown-toggle {
        width: 36px;
        height: 36px;
        font-size: 18px;
    }
    
    .dropdown-toggle i {
        font-size: 18px;
    }
    
    .dropdown-menu {
        min-width: 180px;
        right: -8px;
    }
    
    .dropdown-item {
        padding: 12px 16px;
        font-size: 15px;
    }
    
    .dropdown-item i {
        font-size: 15px;
        width: 18px;
    }
}

@media (max-width: 480px) {
    .dropdown-toggle {
        width: 40px;
        height: 40px;
    }

    .dropdown-toggle i {
        font-size: 20px;
    }
    
    .dropdown-menu {
        min-width: 160px;
        right: -12px;
    }
    
    .dropdown-item {
        padding: 14px 16px;
        font-size: 16px;
    }
}

/* Accessibility */
.dropdown-toggle:focus {
    outline: none;
    box-shadow: 
        0 0 0 2px rgba(59, 130, 246, 0.2),
        0 2px 4px rgba(0, 0, 0, 0.1);
}

.dropdown-item:focus {
    outline: none;
    background: #f8fafc;
    box-shadow: inset 2px 0 0 #3b82f6;
}

/* Tablet spezifische Anpassungen */
@media (min-width: 768px) and (max-width: 1024px) {
    .dropdown-toggle {
        width: 34px;
        height: 34px;
    }
    
    .dropdown-menu {
        min-width: 190px;
    }
}

/* Animation für bessere UX */
@keyframes dropdown-slide-in {
    from {
        opacity: 0;
        transform: translateY(-12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dropdown-menu.show {
    animation: dropdown-slide-in 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .dropdown-toggle {
        background: #374151;
        color: #d1d5db;
    }
    
    .dropdown-toggle:hover {
        background: #4b5563;
        color: #f3f4f6;
    }
    
    .dropdown-menu {
        background: #374151;
        border-color: #4b5563;
    }
    
    .dropdown-menu::before {
        border-bottom-color: #374151;
    }
    
    .dropdown-menu.dropup::before {
        border-top-color: #374151;
    }
    
    .dropdown-item {
        color: #d1d5db;
    }
    
    .dropdown-item:hover {
        background: #4b5563;
        color: #f3f4f6;
    }
    
    .dropdown-divider {
        background: #4b5563;
    }
}

/* Invoice Modal Styles */
.invoice-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.invoice-modal-overlay.show {
    opacity: 1;
    visibility: visible;
}

.invoice-modal {
    background: white;
    border-radius: 12px;
    box-shadow: 
        0 25px 50px -12px rgba(0, 0, 0, 0.25),
        0 0 0 1px rgba(0, 0, 0, 0.1);
    max-width: 800px;
    width: 90vw;
    max-height: 90vh;
    overflow: hidden;
    transform: scale(0.9) translateY(20px);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.invoice-modal-overlay.show .invoice-modal {
    transform: scale(1) translateY(0);
}

.invoice-modal-header {
    padding: 24px 24px 0;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8fafc;
}

.invoice-modal-header h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: #1e293b;
}

.invoice-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    font-weight: bold;
    color: #64748b;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: all 0.2s ease;
    line-height: 1;
}

.invoice-modal-close:hover {
    background: #e2e8f0;
    color: #374151;
}

.invoice-modal-body {
    padding: 24px;
    max-height: calc(90vh - 140px);
    overflow-y: auto;
}

.invoice-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 24px;
    margin-bottom: 24px;
}

.invoice-info-section {
    background: #f8fafc;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.invoice-info-section h3 {
    margin: 0 0 16px 0;
    font-size: 16px;
    font-weight: 600;
    color: #374151;
    border-bottom: 2px solid #3b82f6;
    padding-bottom: 8px;
}

.invoice-info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #e2e8f0;
}

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

.invoice-info-item.total {
    font-weight: 600;
    font-size: 16px;
    padding-top: 12px;
    border-top: 2px solid #3b82f6;
    margin-top: 8px;
}

.invoice-info-item .label {
    font-weight: 500;
    color: #64748b;
    flex-shrink: 0;
    margin-right: 12px;
}

.invoice-info-item .value {
    color: #1e293b;
    text-align: right;
}

.invoice-modal-footer {
    padding: 24px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.invoice-modal-footer .btn-secondary,
.invoice-modal-footer .btn-primary {
    padding: 10px 20px;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

.invoice-modal-footer .btn-secondary {
    background: #f1f5f9;
    color: #475569;
}

.invoice-modal-footer .btn-secondary:hover {
    background: #e2e8f0;
}

.invoice-modal-footer .btn-primary {
    background: #3b82f6;
    color: white;
}

.invoice-modal-footer .btn-primary:hover {
    background: #2563eb;
}

/* Status badges in modal */
.invoice-modal .status-badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.invoice-modal .status-success {
    background: #d1fae5;
    color: #065f46;
}

.invoice-modal .status-warning {
    background: #fef3c7;
    color: #92400e;
}

.invoice-modal .status-info {
    background: #dbeafe;
    color: #1e40af;
}

.invoice-modal .status-secondary {
    background: #f1f5f9;
    color: #475569;
}

/* Mobile optimizations */
@media (max-width: 768px) {
    .invoice-modal {
        width: 95vw;
        max-height: 95vh;
        margin: 20px;
    }
    
    .invoice-info-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .invoice-modal-header,
    .invoice-modal-body,
    .invoice-modal-footer {
        padding: 16px;
    }
    
    .invoice-modal-footer {
        flex-direction: column;
    }
    
    .invoice-modal-footer .btn-secondary,
    .invoice-modal-footer .btn-primary {
        width: 100%;
        justify-content: center;
    }
}

/* Email Modal Styles */
.email-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.email-modal-overlay.show {
    opacity: 1;
    visibility: visible;
}

.email-modal {
    background: white;
    border-radius: 12px;
    box-shadow: 
        0 25px 50px -12px rgba(0, 0, 0, 0.25),
        0 0 0 1px rgba(0, 0, 0, 0.1);
    max-width: 500px;
    width: 90vw;
    max-height: 90vh;
    overflow: hidden;
    transform: scale(0.9) translateY(20px);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.email-modal-overlay.show .email-modal {
    transform: scale(1) translateY(0);
}

.email-modal-header {
    padding: 24px 24px 0;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8fafc;
}

.email-modal-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #1e293b;
}

.email-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    font-weight: bold;
    color: #64748b;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: all 0.2s ease;
    line-height: 1;
}

.email-modal-close:hover {
    background: #e2e8f0;
    color: #374151;
}

.email-modal-body {
    padding: 24px;
    max-height: calc(90vh - 140px);
    overflow-y: auto;
}

.email-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-weight: 600;
    color: #374151;
    font-size: 14px;
}

.email-input,
.pdf-type-select {
    padding: 12px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 16px;
    transition: all 0.2s ease;
    background: white;
}

.email-input:focus,
.pdf-type-select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.email-input:invalid {
    border-color: #ef4444;
}

.email-help,
.pdf-help {
    font-size: 12px;
    color: #64748b;
    margin-top: 4px;
}

.email-preview {
    background: #f8fafc;
    padding: 16px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.email-preview h3 {
    margin: 0 0 8px 0;
    font-size: 16px;
    font-weight: 600;
    color: #1e293b;
}

.email-preview p {
    margin: 0;
    color: #64748b;
    font-size: 14px;
}

.email-modal-footer {
    padding: 24px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.email-modal-footer .btn-secondary,
.email-modal-footer .btn-primary {
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    font-size: 14px;
}

.email-modal-footer .btn-secondary {
    background: #f1f5f9;
    color: #475569;
}

.email-modal-footer .btn-secondary:hover {
    background: #e2e8f0;
}

.email-modal-footer .btn-primary {
    background: #3b82f6;
    color: white;
}

.email-modal-footer .btn-primary:hover {
    background: #2563eb;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(59, 130, 246, 0.3);
}

/* Mobile optimizations */
@media (max-width: 768px) {
    .email-modal {
        width: 95vw;
        max-height: 95vh;
        margin: 20px;
    }
    
    .email-modal-header,
    .email-modal-body,
    .email-modal-footer {
        padding: 16px;
    }
    
    .email-modal-footer {
        flex-direction: column;
    }
    
    .email-modal-footer .btn-secondary,
    .email-modal-footer .btn-primary {
        width: 100%;
        justify-content: center;
    }
    
    .email-input,
    .pdf-type-select {
        font-size: 16px; /* Prevent zoom on iOS */
    }
}

/* Print Styles */
@media print {
    .dropdown-menu-container {
        display: none !important;
    }
    
    .invoice-modal-overlay {
        display: none !important;
    }
    
    .email-modal-overlay {
        display: none !important;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .dropdown-toggle {
        border: 2px solid currentColor;
    }

    .dropdown-menu {
        border: 2px solid currentColor;
    }

    .dropdown-item {
        border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    }
}

/* ======================================
   NAVIGATION SUBMENU STYLES
   ====================================== */

/* Sidebar item with submenu */
.sidebar-item-with-submenu {
    position: relative;
}

/* Link container with dropdown toggle */
.sidebar-link-with-dropdown {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0;
    cursor: pointer;
    border-radius: 8px;
    transition: background-color 0.2s ease;
}

.sidebar-link-with-dropdown:hover {
    background-color: #f8fafc;
}

.sidebar-link-with-dropdown.active {
    background-color: #eff6ff;
}

/* Main sidebar link inside dropdown container */
.sidebar-link-main {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    text-decoration: none;
    color: #374151;
    font-weight: 500;
    transition: color 0.2s ease;
}

.sidebar-link-main:hover {
    color: #1f2937;
}

.sidebar-link-with-dropdown.active .sidebar-link-main {
    color: #3b82f6;
}

/* Dropdown toggle button */
.sidebar-dropdown-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    margin-right: 12px;
    background: transparent;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sidebar-dropdown-toggle:hover {
    background-color: #e2e8f0;
}

.sidebar-dropdown-toggle:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

/* Dropdown arrow */
.dropdown-arrow {
    transition: transform 0.2s ease;
}

.sidebar-dropdown-toggle.open .dropdown-arrow {
    transform: rotate(180deg);
}

/* Submenu container */
.sidebar-submenu {
    margin: 0;
    padding: 4px 0 8px 0;
    list-style: none;
    background-color: #f8fafc;
    border-radius: 0 0 8px 8px;
    overflow: hidden;
    transition: all 0.3s ease;
}

/* HOVER-BASED SUBMENU */
.sidebar-submenu-hover {
    display: none;
    opacity: 0;
    max-height: 0;
    transition: opacity 0.3s ease, max-height 0.3s ease;
}

.sidebar-item-with-submenu:hover .sidebar-submenu-hover {
    display: block;
    opacity: 1;
    max-height: 500px;
}

/* ALWAYS VISIBLE SUBMENU - For fixed submenu items */
.sidebar-submenu-always-visible {
    display: block !important;
    opacity: 1 !important;
    max-height: none !important;
}

/* Hover trigger styling */
.sidebar-link-hover-trigger {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: default;
    border-radius: 8px;
    transition: background-color 0.2s ease;
}

.sidebar-item-with-submenu:hover .sidebar-link-hover-trigger {
    background-color: #f8fafc;
}

.sidebar-item-with-submenu:hover .dropdown-arrow {
    transform: rotate(180deg);
}

.sidebar-submenu-item {
    margin: 0;
    padding: 0;
}

/* Submenu links */
.sidebar-submenu-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px 10px 48px; /* Increased left padding for indentation */
    text-decoration: none;
    color: #64748b;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    border-radius: 6px;
    margin: 2px 8px;
}

.sidebar-submenu-link:hover {
    background-color: #e2e8f0;
    color: #374151;
    padding-left: 52px; /* Slight indent on hover for better UX */
}

.sidebar-submenu-link.active {
    background-color: #dbeafe;
    color: #3b82f6;
    font-weight: 600;
}

.sidebar-submenu-link .sidebar-icon {
    font-size: 14px;
    opacity: 0.8;
}

.sidebar-submenu-link.active .sidebar-icon {
    opacity: 1;
}

/* Mobile optimizations for submenu */
@media (max-width: 768px) {
    .sidebar-dropdown-toggle {
        width: 36px;
        height: 36px;
    }

    .sidebar-submenu-link {
        padding: 12px 16px 12px 44px;
        font-size: 15px;
    }

    .sidebar-submenu-link:hover {
        padding-left: 48px;
    }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    .dropdown-arrow,
    .sidebar-submenu,
    .sidebar-submenu-link {
        transition: none;
    }
}

/* Dark mode support for submenu */
@media (prefers-color-scheme: dark) {
    .sidebar-link-with-dropdown:hover {
        background-color: #374151;
    }

    .sidebar-link-with-dropdown.active {
        background-color: #1e3a8a;
    }

    .sidebar-link-main {
        color: #d1d5db;
    }

    .sidebar-link-main:hover {
        color: #f3f4f6;
    }

    .sidebar-submenu {
        background-color: #1f2937;
    }

    .sidebar-submenu-link {
        color: #9ca3af;
    }

    .sidebar-submenu-link:hover {
        background-color: #374151;
        color: #f3f4f6;
    }

    .sidebar-submenu-link.active {
        background-color: #1e40af;
        color: #93c5fd;
    }
}