/**
 * B2B Outreach CRM - Deal Dashboard CSS
 * 
 * Kanban-Board Styling für Frontend Dashboard
 * Mobile-First Responsive Design
 * Material Design inspiriert
 */

/* ==========================================================================
   GRUNDEINSTELLUNGEN & VARIABLEN
   ========================================================================== */

:root {
    /* Farbschema */
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --success-color: #059669;
    --warning-color: #d97706;
    --danger-color: #dc2626;
    --info-color: #0891b2;
    
    /* Status-Farben */
    --status-cold: #6b7280;
    --status-warm: #f59e0b;
    --status-hot: #ef4444;
    --status-sale: #059669;
    --status-paid: #10b981;
    --status-lost: #6b7280;
    
    /* Grautöne */
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    
    /* Schatten */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    
    /* Border Radius */
    --radius-sm: 0.25rem;
    --radius-md: 0.375rem;
    --radius-lg: 0.5rem;
    --radius-xl: 0.75rem;
    
    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;
    
    /* Typography */
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    
    /* Transitions */
    --transition-fast: 150ms ease-in-out;
    --transition-base: 250ms ease-in-out;
    --transition-slow: 350ms ease-in-out;
}

/* ==========================================================================
   RESET & BASE STYLES
   ========================================================================== */

.b2b-deal-dashboard * {
    box-sizing: border-box;
}

.b2b-deal-dashboard {
    font-family: var(--font-sans);
    color: var(--gray-700);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ==========================================================================
   DASHBOARD HEADER - KORRIGIERT
   ========================================================================== */

.dashboard-header {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-xl);
    padding: var(--spacing-lg);
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
}

.dashboard-header h2 {
    margin: 0;
    font-size: var(--font-size-2xl);
    font-weight: 700;
    color: var(--gray-900);
    text-align: center;
}

.dashboard-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
}

.contact-search-wrapper {
    flex: 1;
    max-width: 400px;
}

.contact-search {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
    transition: border-color var(--transition-fast);
}

.contact-search:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Dashboard-Statistiken - Nicht mehr absolut positioniert */
.dashboard-stats {
    display: flex;
    gap: var(--spacing-lg);
    justify-content: space-around;
    background: var(--gray-50);
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    border: 1px solid var(--gray-200);
    flex-wrap: wrap;
}

.stat-item {
    text-align: center;
    min-width: 100px;
    flex: 1;
}

.stat-number {
    font-size: var(--font-size-xl);
    font-weight: 700;
    color: var(--gray-900);
    line-height: 1;
}

.stat-label {
    font-size: var(--font-size-xs);
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: var(--spacing-xs);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .dashboard-header {
        padding: var(--spacing-md);
    }
    
    .dashboard-header h2 {
        font-size: var(--font-size-xl);
    }
    
    .dashboard-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .contact-search-wrapper {
        max-width: none;
    }
    
    .dashboard-stats {
        flex-direction: column;
        gap: var(--spacing-sm);
    }
    
    .stat-item {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: var(--spacing-xs) 0;
        border-bottom: 1px solid var(--gray-200);
    }
    
    .stat-item:last-child {
        border-bottom: none;
    }
    
    .stat-number {
        font-size: var(--font-size-lg);
    }
    
    .stat-label {
        margin-top: 0;
        text-transform: none;
    }
}


/* ==========================================================================
   DASHBOARD STATISTIKEN - RESPONSIVE CARDS (KORRIGIERT)
   ========================================================================== */

.dashboard-stats {
    /* ENTFERNT: position: absolute; top: 20px; right: 20px; */
    display: flex;
    gap: 15px;
    background: white;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    border: 1px solid #ddd;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    flex-wrap: wrap;
    justify-content: space-around;
}

.stat-item {
    text-align: center;
    min-width: 100px;
    flex: 1;
}

.stat-number {
    font-size: 24px;
    font-weight: bold;
    color: #333;
    line-height: 1;
}

.stat-label {
    font-size: 12px;
    color: #666;
    margin-top: 5px;
}

/* Mobile Responsive - Korrigiert */
@media (max-width: 768px) {
    .dashboard-header {
        flex-direction: column;
        gap: var(--spacing-md);
        align-items: stretch;
    }
    
    .dashboard-controls {
        order: 1; /* Suchfeld zuerst */
        justify-content: center;
        margin-bottom: 15px;
    }
    
    .dashboard-stats {
        order: 2; /* Statistiken danach */
        margin-bottom: 20px;
        flex-direction: column;
        gap: 10px;
    }

    .stat-item {
        margin-bottom: 0;
    }

    .stat-number {
        font-size: 18px;
    }
}

@media (max-width: 480px) {
    .dashboard-stats {
        padding: 10px;
    }
    
    .stat-number {
        font-size: 16px;
    }
}



/* ==========================================================================
   KANBAN BOARD LAYOUT
   ========================================================================== */

.kanban-board {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: var(--spacing-lg);
    margin-bottom: var(--spacing-xl);
    overflow-x: auto;
    padding: var(--spacing-sm);
}

/* Mobile: Horizontal Scroll */
@media (max-width: 768px) {
    .kanban-board {
        display: flex;
        gap: var(--spacing-md);
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
        padding-bottom: var(--spacing-lg);
    }
    
    .kanban-column {
        flex: 0 0 280px;
        scroll-snap-align: start;
    }
}

/* ==========================================================================
   KANBAN SPALTEN
   ========================================================================== */

.kanban-column {
    background: var(--gray-50);
    border-radius: var(--radius-lg);
    border: 1px solid var(--gray-200);
    min-height: 500px;
    transition: box-shadow var(--transition-base);
}

.kanban-column:hover {
    box-shadow: var(--shadow-md);
}

/* Spalten-spezifische Farben */
.kanban-column[data-status="cold"] {
    border-top: 4px solid var(--status-cold);
}

.kanban-column[data-status="warm"] {
    border-top: 4px solid var(--status-warm);
}

.kanban-column[data-status="hot"] {
    border-top: 4px solid var(--status-hot);
}

.kanban-column[data-status="sale"] {
    border-top: 4px solid var(--status-sale);
}

.kanban-column[data-status="paid"] {
    border-top: 4px solid var(--status-paid);
}

.kanban-column[data-status="lost"] {
    border-top: 4px solid var(--status-lost);
    opacity: 0.8;
}

/* ==========================================================================
   SPALTEN HEADER
   ========================================================================== */

.column-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-lg);
    border-bottom: 1px solid var(--gray-200);
    background: white;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.column-header h3 {
    margin: 0;
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--gray-900);
}

.contact-count {
    background: var(--gray-100);
    color: var(--gray-600);
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--radius-xl);
    font-size: var(--font-size-xs);
    font-weight: 500;
    min-width: 24px;
    text-align: center;
}

/* ==========================================================================
   KONTAKT LISTEN
   ========================================================================== */

.contact-list {
    padding: var(--spacing-md);
    min-height: 400px;
    position: relative;
}

.empty-column {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: var(--gray-400);
    font-style: italic;
}

/* ==========================================================================
   KONTAKT KARTEN
   ========================================================================== */

.contact-card {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-md);
    box-shadow: var(--shadow-sm);
    cursor: grab;
    transition: all var(--transition-fast);
    position: relative;
    user-select: none;
}

.contact-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.contact-card:active {
    cursor: grabbing;
}

.contact-card.dragging {
    opacity: 0.6;
    transform: rotate(5deg);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
}

.contact-card.drag-over {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

/* Verlorene Kontakte */
.contact-card.lost-contact {
    opacity: 0.7;
    background: var(--gray-50);
}

.contact-card.lost-contact .contact-info h4 {
    text-decoration: line-through;
    color: var(--gray-500);
}

/* ==========================================================================
   KONTAKT HEADER
   ========================================================================== */

.contact-header {
    display: flex;
    align-items: flex-start;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
}

.contact-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: var(--font-size-sm);
    flex-shrink: 0;
}

.contact-info {
    flex: 1;
    min-width: 0;
}

.contact-info h4 {
    margin: 0 0 var(--spacing-xs) 0;
    font-size: var(--font-size-base);
    font-weight: 600;
    color: var(--gray-900);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.contact-info .company {
    font-size: var(--font-size-sm);
    color: var(--gray-600);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.contact-actions {
    display: flex;
    gap: var(--spacing-xs);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.contact-card:hover .contact-actions {
    opacity: 1;
}

.btn-edit,
.btn-delete {
    background: none;
    border: none;
    padding: var(--spacing-xs);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: var(--font-size-sm);
    transition: background var(--transition-fast);
}

.btn-edit:hover {
    background: var(--gray-100);
}

.btn-delete:hover {
    background: rgba(220, 38, 38, 0.1);
}

/* ==========================================================================
   KONTAKT DETAILS
   ========================================================================== */

.contact-details {
    margin-bottom: var(--spacing-md);
}

.contact-email,
.contact-position,
.contact-phone {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-xs);
    font-size: var(--font-size-sm);
}

.contact-email .icon,
.contact-position .icon,
.contact-phone .icon {
    font-size: var(--font-size-xs);
    width: 16px;
    text-align: center;
    flex-shrink: 0;
}

.contact-email a,
.contact-phone a {
    color: var(--primary-color);
    text-decoration: none;
}

.contact-email a:hover,
.contact-phone a:hover {
    text-decoration: underline;
}

/* ==========================================================================
   TAGS
   ========================================================================== */

.contact-tags {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-xs);
    margin-bottom: var(--spacing-md);
}

.tag {
    background: var(--gray-100);
    color: var(--gray-700);
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--radius-xl);
    font-size: var(--font-size-xs);
    font-weight: 500;
    border: 1px solid var(--gray-200);
}

/* Tag-Farben basierend auf Inhalt (optional) */
.tag:nth-child(1) { background: rgba(239, 68, 68, 0.1); color: #dc2626; border-color: rgba(239, 68, 68, 0.2); }
.tag:nth-child(2) { background: rgba(245, 158, 11, 0.1); color: #d97706; border-color: rgba(245, 158, 11, 0.2); }
.tag:nth-child(3) { background: rgba(5, 150, 105, 0.1); color: #059669; border-color: rgba(5, 150, 105, 0.2); }
.tag:nth-child(4) { background: rgba(37, 99, 235, 0.1); color: #2563eb; border-color: rgba(37, 99, 235, 0.2); }

/* ==========================================================================
   KONTAKT FOOTER
   ========================================================================== */

.contact-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: var(--spacing-sm);
    border-top: 1px solid var(--gray-100);
    font-size: var(--font-size-xs);
}

.contact-status {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    color: var(--gray-600);
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-indicator.status-cold { background: var(--status-cold); }
.status-indicator.status-warm { background: var(--status-warm); }
.status-indicator.status-hot { background: var(--status-hot); }
.status-indicator.status-sale { background: var(--status-sale); }
.status-indicator.status-paid { background: var(--status-paid); }
.status-indicator.status-lost { background: var(--status-lost); }

.contact-date {
    color: var(--gray-500);
}

/* ==========================================================================
   NOTIZEN
   ========================================================================== */

.contact-notes {
    margin-top: var(--spacing-sm);
    border-top: 1px solid var(--gray-100);
    padding-top: var(--spacing-sm);
}

.toggle-notes {
    background: none;
    border: none;
    color: var(--primary-color);
    font-size: var(--font-size-xs);
    cursor: pointer;
    padding: 0;
    text-decoration: underline;
}

.notes-content {
    margin-top: var(--spacing-sm);
    padding: var(--spacing-sm);
    background: var(--gray-50);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-sm);
    color: var(--gray-700);
    display: none;
}

.contact-notes:not(.collapsed) .notes-content {
    display: block;
}

.contact-notes.collapsed .toggle-notes::after {
    content: " ▼";
}

.contact-notes:not(.collapsed) .toggle-notes::after {
    content: " ▲";
}

/* ==========================================================================
   DROP ZONES
   ========================================================================== */

.drop-zone {
    min-height: 60px;
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-400);
    font-size: var(--font-size-sm);
    margin-top: var(--spacing-md);
    transition: all var(--transition-fast);
    opacity: 0;
}

.drop-zone.active {
    opacity: 1;
    border-color: var(--primary-color);
    background: rgba(37, 99, 235, 0.05);
    color: var(--primary-color);
}

/* ==========================================================================
   LOST SECTION
   ========================================================================== */

.lost-section {
    margin-top: var(--spacing-2xl);
    padding-top: var(--spacing-xl);
    border-top: 2px solid var(--gray-200);
}

.lost-column {
    max-height: 300px;
    overflow-y: auto;
}

.lost-column .contact-list {
    max-height: 200px;
    overflow-y: auto;
}

/* ==========================================================================
   LOADING & STATES
   ========================================================================== */

.b2b-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--gray-200);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.b2b-loading-overlay p {
    color: white;
    margin-top: var(--spacing-md);
    font-weight: 500;
}

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

/* Lokale Loading-States */
.contact-card.loading {
    opacity: 0.6;
    pointer-events: none;
}

.contact-card.loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid var(--gray-300);
    border-top: 2px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ==========================================================================
   ERROR & SUCCESS STATES
   ========================================================================== */

.b2b-error {
    background: rgba(220, 38, 38, 0.1);
    border: 1px solid rgba(220, 38, 38, 0.2);
    color: #991b1b;
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    margin-bottom: var(--spacing-lg);
}

.success-message {
    background: rgba(5, 150, 105, 0.1);
    border: 1px solid rgba(5, 150, 105, 0.2);
    color: #047857;
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius-md);
    margin-bottom: var(--spacing-md);
    font-size: var(--font-size-sm);
}

/* ==========================================================================
   TOOLTIPS
   ========================================================================== */

[title]:hover::after {
    content: attr(title);
    position: absolute;
    background: var(--gray-900);
    color: white;
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-xs);
    white-space: nowrap;
    z-index: 1000;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: var(--spacing-xs);
}

/* ==========================================================================
   RESPONSIVE BREAKPOINTS
   ========================================================================== */

/* Tablet */
@media (max-width: 1024px) {
    .dashboard-header {
        flex-direction: column;
        gap: var(--spacing-md);
        align-items: stretch;
    }
    
    .dashboard-controls {
        justify-content: center;
    }
    
    .contact-search {
        min-width: auto;
        flex: 1;
    }
}

/* Mobile */
@media (max-width: 768px) {
    .b2b-deal-dashboard {
        padding: var(--spacing-sm);
    }
    
    .dashboard-header {
        padding: var(--spacing-md);
        margin-bottom: var(--spacing-lg);
    }
    
    .dashboard-header h2 {
        font-size: var(--font-size-xl);
        text-align: center;
    }
    
    .dashboard-controls {
        flex-direction: column;
        gap: var(--spacing-sm);
    }
    
    .contact-search {
        width: 100%;
    }
    
    .kanban-column {
        min-height: 400px;
    }
    
    .contact-card {
        padding: var(--spacing-sm);
    }
    
    .contact-header {
        flex-direction: row;
        align-items: center;
    }
    
    .contact-avatar {
        width: 32px;
        height: 32px;
        font-size: var(--font-size-xs);
    }
    
    .contact-actions {
        opacity: 1; /* Immer sichtbar auf Mobile */
    }
}

/* Extra small screens */
@media (max-width: 480px) {
    :root {
        --spacing-md: 0.75rem;
        --spacing-lg: 1rem;
        --spacing-xl: 1.5rem;
    }
    
    .kanban-column {
        flex: 0 0 260px;
    }
    
    .contact-card {
        margin-bottom: var(--spacing-sm);
    }
    
    .contact-details {
        margin-bottom: var(--spacing-sm);
    }
    
    .contact-tags {
        margin-bottom: var(--spacing-sm);
    }
    
    .tag {
        font-size: 10px;
        padding: 2px 6px;
    }
}

/* ==========================================================================
   ACCESSIBILITY
   ========================================================================== */

/* Focus States */
.contact-card:focus,
.btn-edit:focus,
.btn-delete:focus,
.btn-add-contact:focus,
.btn-refresh:focus,
.contact-search:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Reduce Motion */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .contact-card:hover {
        transform: none;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    :root {
        --gray-100: #ffffff;
        --gray-200: #e0e0e0;
        --gray-300: #c0c0c0;
        --gray-400: #808080;
        --gray-500: #606060;
        --gray-600: #404040;
        --gray-700: #202020;
        --gray-800: #101010;
        --gray-900: #000000;
    }
    
    .contact-card {
        border-width: 2px;
    }
}

/* ==========================================================================
   PRINT STYLES
   ========================================================================== */

@media print {
    .dashboard-controls,
    .contact-actions,
    .drop-zone,
    .b2b-loading-overlay {
        display: none !important;
    }
    
    .kanban-board {
        display: block;
    }
    
    .kanban-column {
        break-inside: avoid;
        margin-bottom: var(--spacing-lg);
    }
    
    .contact-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid var(--gray-400);
    }
}