/* My Dexy - Custom Styles
 * Bootstrap 5 responsive contact management application
 * 
 * Component Reference Guide:
 * 
 * Layout Zones (By Screen Size):
 * - Main Header: Top navigation bar (includes app name + "Ask the AI" link)
 * - AZ Nav Panel: A–Z alphabetical navigation list (Left column on desktop / Tab 1 on mobile)
 * - Contact List Panel: List of contacts for selected letter (Middle column on desktop / Tab 2 on mobile)
 * - Contact Detail Panel: Selected contact's full profile (Right column on desktop / Tab 3 on mobile)
 * - Mobile Tab Bar: Horizontal tab switcher for mobile view (Mobile only)
 * 
 * Component Names:
 * - AZ Dropdown: Mobile version of the A–Z selector (dropdown or horizontal scroll pills)
 * - Contact Card: Clickable item in Contact List showing name, email, company, last note date
 * - Contact Profile Header: Top section of contact's profile (name, company, email, phone, tags, social links)
 * - Contact Edit Form: Editable version of the Contact Profile Header
 * - Meeting Note Card: Single note entry shown in profile panel (collapsed or expanded)
 * - Note Edit Modal: UI for editing or adding a note
 * - AI Insights Page: Separate screen linked from top nav — "Ask the AI"
 * - Floating Action Button (FAB): Optional fixed-position "+" button for adding contacts or notes (especially on mobile)
 */

/* Root variables for consistent design */
:root {
    --header-height: 60px;
    --touch-target-min: 44px;
    --gap-small: 0.5rem;
    --gap-medium: 1rem;
    --gap-large: 1.5rem;
}

/* Header styling */
header nav.navbar {
    min-height: var(--header-height);
}

/* Main layout container */
main.container-fluid {
    padding-left: var(--gap-medium);
    padding-right: var(--gap-medium);
}

/* Fixed height layout for desktop */
.contact-list-panel,
.profile-panel,
.alphabet-sidebar {
    max-height: calc(100vh - var(--header-height) - 2rem);
    overflow-y: auto;
}

/* Ensure minimum touch targets for accessibility */
.btn-contact-action,
.btn-contact-add,
.contact-item,
.alphabet-sidebar .btn {
    min-height: var(--touch-target-min);
    min-width: var(--touch-target-min);
}

/* Contact list item styling */
.contact-item {
    cursor: pointer;
    transition: background-color 0.15s ease;
    border-radius: 0.375rem;
    margin-bottom: 0.125rem;
}

.contact-item:hover {
    background-color: var(--bs-light);
}

.contact-item:focus {
    outline: 2px solid var(--bs-primary);
    outline-offset: 2px;
}

.contact-item.active {
    background-color: var(--bs-primary);
    color: white;
    border-color: var(--bs-primary);
}

.contact-item.active .text-muted {
    color: rgba(255, 255, 255, 0.8) !important;
}

/* Text wrapping and overflow handling */
.text-break {
    word-wrap: break-word;
    word-break: break-word;
    hyphens: auto;
}

/* Custom scrollbar styling for webkit browsers */
.contact-list-panel::-webkit-scrollbar,
.profile-panel::-webkit-scrollbar,
.alphabet-sidebar::-webkit-scrollbar {
    width: 6px;
}

.contact-list-panel::-webkit-scrollbar-track,
.profile-panel::-webkit-scrollbar-track,
.alphabet-sidebar::-webkit-scrollbar-track {
    background: #f8f9fa;
}

.contact-list-panel::-webkit-scrollbar-thumb,
.profile-panel::-webkit-scrollbar-thumb,
.alphabet-sidebar::-webkit-scrollbar-thumb {
    background: #dee2e6;
    border-radius: 3px;
}

.contact-list-panel::-webkit-scrollbar-thumb:hover,
.profile-panel::-webkit-scrollbar-thumb:hover,
.alphabet-sidebar::-webkit-scrollbar-thumb:hover {
    background: #adb5bd;
}

/* Alphabet sidebar specific styling */
.alphabet-sidebar .btn {
    font-weight: 600;
    border-radius: 0.25rem;
}

/* Empty state styling */
.empty-state {
    padding: var(--gap-large);
}

/* Card body overflow for mobile */
.card-body {
    overflow-x: hidden;
}

/* Mobile tabs styling */
.mobile-tabs-container {
    padding: 0;
}

.mobile-tab-btn {
    min-height: var(--touch-target-min);
    padding: 12px 16px;
    font-weight: 500;
    border-radius: 0;
    transition: all 0.15s ease;
}

.mobile-tab-btn:hover:not(.disabled) {
    background-color: var(--bs-light);
}

.mobile-tab-btn.active {
    background-color: var(--bs-primary);
    color: white;
    border-color: var(--bs-primary);
}

.mobile-tab-btn.disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.mobile-tab-content {
    min-height: calc(100vh - var(--header-height) - 120px);
}

.mobile-tab-content .card {
    border-radius: 0.375rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Mobile contact item styling */
.mobile-contact-item {
    border-radius: 0.25rem;
    margin-bottom: 0.25rem;
    transition: all 0.15s ease;
}

.mobile-contact-item:hover {
    background-color: var(--bs-light);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.mobile-contact-item.active {
    background-color: var(--bs-primary);
    color: white;
    box-shadow: 0 2px 8px rgba(13, 110, 253, 0.3);
}

/* Mobile-first responsive design */
@media (max-width: 767.98px) {
    /* Mobile devices - use tabbed interface */
    :root {
        --header-height: 56px;
    }
    
    main.container-fluid {
        padding-left: var(--gap-small);
        padding-right: var(--gap-small);
    }
    
    /* Hide desktop layout completely on mobile */
    .d-none.d-md-flex {
        display: none !important;
    }
    
    /* Show mobile tabs only on mobile */
    .d-md-none {
        display: block !important;
    }
    
    /* Mobile tab content styling */
    .mobile-tab-content .card-body {
        padding: var(--gap-medium);
    }
    
    /* Smaller text on mobile */
    .h4 {
        font-size: 1.1rem;
    }
    
    .h6 {
        font-size: 0.9rem;
    }
    
    /* Mobile letter grid - 6 columns */
    .d-grid[style*="repeat(6, 1fr)"] {
        display: grid !important;
        grid-template-columns: repeat(6, 1fr) !important;
        gap: 0.25rem;
    }
    
    /* Ensure proper touch targets on mobile */
    .mobile-tab-btn,
    .mobile-contact-item,
    .btn-contact-add,
    .btn-contact-action {
        min-height: var(--touch-target-min);
        min-width: var(--touch-target-min);
    }
}

@media (min-width: 576px) and (max-width: 767.98px) {
    /* Small devices (landscape phones) */
    .contact-list-panel,
    .profile-panel,
    .alphabet-sidebar {
        min-height: 400px;
    }
}

@media (min-width: 768px) and (max-width: 991.98px) {
    /* Medium devices (tablets) */
    .contact-list-panel,
    .profile-panel,
    .alphabet-sidebar {
        max-height: calc(100vh - var(--header-height) - 1.5rem);
    }
    
    /* Adjust column proportions for tablets */
    .col-md-3 {
        flex: 0 0 20%;
        max-width: 20%;
    }
    
    .col-md-5 {
        flex: 0 0 35%;
        max-width: 35%;
    }
    
    .col-md-4 {
        flex: 0 0 45%;
        max-width: 45%;
    }
}

@media (min-width: 992px) and (max-width: 1199.98px) {
    /* Large devices (desktops) */
    .contact-list-panel,
    .profile-panel,
    .alphabet-sidebar {
        max-height: calc(100vh - var(--header-height) - 1rem);
    }
}

@media (min-width: 1200px) {
    /* Extra large devices (large desktops) */
    .contact-list-panel,
    .profile-panel,
    .alphabet-sidebar {
        max-height: calc(100vh - var(--header-height) - 1rem);
    }
    
    /* More comfortable spacing on large screens */
    main.container-fluid {
        padding-left: var(--gap-large);
        padding-right: var(--gap-large);
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .contact-item {
        border: 1px solid currentColor;
    }
    
    .contact-item.active {
        border: 2px solid var(--bs-primary);
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .contact-item {
        transition: none;
    }
    
    .accordion-button {
        transition: none;
    }
}

/* Print styles */
@media print {
    .alphabet-sidebar,
    .btn-contact-action,
    .btn-contact-add {
        display: none;
    }
    
    .contact-list-panel,
    .profile-panel {
        max-height: none;
        overflow: visible;
    }
    
    .accordion-collapse {
        display: block !important;
    }
}