/**
 * Responsive styles for FA Calculator
 * Media queries for different screen sizes
 */

/* Help pane and sidebar styles */
.help-pane {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 260px;
    max-height: calc(100vh - 40px);
    background: linear-gradient(135deg, rgba(255,255,255,0.95) 0%, rgba(248,250,252,0.95) 100%);
    border-radius: 15px;
    box-shadow: 
        0 10px 30px rgba(0,0,0,0.15),
        inset 0 1px 0 rgba(255,255,255,0.6);
    padding: 20px;
    overflow-y: auto;
    z-index: 100;
    backdrop-filter: blur(15px);
    border: 1px solid rgba(102, 126, 234, 0.3);
}


.help-pane h3 {
    color: #4a5568;
    margin: 0 0 15px 0;
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Help close button - Blue style matching main buttons */
.help-close-btn {
    background: #007bff !important;
    border: 1px solid #0056b3 !important;
    color: white !important;
    font-size: 1.1rem !important;
    cursor: pointer !important;
    padding: 6px !important;
    border-radius: 6px !important;
    transition: all 0.2s ease !important;
    min-width: 32px !important;
    min-height: 32px !important;
    display: none !important; /* Hidden by default */
    align-items: center !important;
    justify-content: center !important;
    box-shadow: 0 2px 4px rgba(0, 123, 255, 0.2) !important;
}

.help-close-btn:hover {
    background: #0056b3 !important;
    border-color: #004085 !important;
    color: white !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 4px 8px rgba(0, 123, 255, 0.3) !important;
}

/* Override the display:flex for non-mobile */
@media (min-width: 769px) {
    .help-close-btn {
        display: none !important;
    }
}

/* Mobile Help Close Button - External to help panel for true fixed positioning */
.mobile-help-close-btn {
    position: fixed;
    top: 25px;
    right: 25px;
    z-index: 1003; /* Above everything */
    background: #007bff;
    border: 1px solid #0056b3;
    color: white;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    transition: all 0.2s ease;
    min-width: 32px;
    min-height: 32px;
    display: none; /* Hidden by default */
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0, 123, 255, 0.2);
}

.mobile-help-close-btn:hover {
    background: #0056b3;
    border-color: #004085;
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 123, 255, 0.3);
}

/* Hide on desktop */
@media (min-width: 769px) {
    .mobile-help-close-btn {
        display: none !important;
    }
}

.help-close-btn:hover {
    color: #e53e3e;
    background-color: #fed7d7;
}

.help-close-btn:active {
    transform: scale(0.95);
}

.help-pane h4 {
    color: #667eea;
    margin: 20px 0 10px 0;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.help-pane p, .help-pane li {
    color: #4a5568;
    line-height: 1.6;
    margin-bottom: 8px;
    font-size: 0.95rem;
}

.help-pane ul {
    margin: 0 0 15px 20px;
    padding: 0;
}

.help-pane .help-section {
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px solid #e2e8f0;
}

.help-pane .help-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.help-tip {
    background: #f0fff4;
    border-left: 4px solid #48bb78;
    padding: 12px 15px;
    margin: 15px 0;
    border-radius: 0 8px 8px 0;
    font-size: 0.9rem;
}

.help-warning {
    background: #fffbf0;
    border-left: 4px solid #ed8936;
    padding: 12px 15px;
    margin: 15px 0;
    border-radius: 0 8px 8px 0;
    font-size: 0.9rem;
}

.help-toggle {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
    z-index: 1000;
    transition: all 0.3s ease;
}

.help-toggle:hover {
    background: #5a67d8;
    transform: scale(1.1);
}

/* LinkedIn sidebar */
.linkedin-sidebar {
    position: fixed;
    top: 50%;
    transform: translateY(-50%) rotate(-90deg);
    z-index: 1000;
    background: linear-gradient(135deg, #0077b5, #005885);
    border-radius: 25px;
    padding: 12px 20px;
    box-shadow: 0 4px 15px rgba(0, 119, 181, 0.3);
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.linkedin-center {
    right: 270px;
}

.linkedin-sidebar a {
    color: white;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.linkedin-sidebar:hover {
    transform: translateY(-50%) rotate(-90deg) scale(1.05);
    box-shadow: 0 6px 20px rgba(0, 119, 181, 0.4);
}

.header .linkedin-link {
    display: none;
}

/* Tooltips removed for better performance and cleaner UI */

/* Mobile disclaimer modal adjustments */
@media (max-width: 768px) {
    .disclaimer-modal-content {
        width: 95%;
        margin: 5% auto;
    }
    
    .disclaimer-body {
        padding: 20px;
    }
    
    .disclaimer-buttons {
        flex-direction: column;
        gap: 10px;
    }
    
    .btn-decline,
    .btn-accept {
        width: 100%;
        padding: 15px;
    }
}

/* Large screen optimization (1601px+) */
@media (min-width: 1601px) {
    .help-pane {
        width: 220px;
        right: 20px;
    }
    
    .main-layout {
        margin-right: 240px;
    }
    
    .header {
        margin-right: 240px;
    }
    
    .linkedin-center {
        right: 250px;
    }
}

/* Ultra-wide screen optimization (2001px-2399px) */
@media (min-width: 2001px) and (max-width: 2399px) {
    .help-pane {
        width: 200px;
        right: 20px;
    }
    
    .main-layout {
        margin-right: 220px;
    }
    
    .header {
        margin-right: 220px;
    }
    
    .linkedin-center {
        right: 230px;
    }
    
    .container {
        max-width: calc(100vw - 240px);
        margin-left: 20px;
        margin-right: 0;
    }
}

/* Maximum efficiency for extremely large screens (2400px+) */
@media (min-width: 2400px) {
    .help-pane {
        width: 180px;
        right: 20px;
    }
    
    .main-layout {
        margin-right: 200px;
    }
    
    .header {
        margin-right: 200px;
    }
    
    .linkedin-center {
        right: 210px;
    }
    
    .container {
        max-width: none;
        width: calc(100vw - 220px);
        margin: 0;
        margin-left: 20px;
        padding: 20px 0 20px 20px;
    }
}

/* Large desktop breakpoint (max-width: 2200px) */
@media (max-width: 2200px) {
    .container {
        max-width: 100%;
        padding: 15px;
    }
    
    .main-layout {
        gap: 15px;
    }
    
    .help-pane {
        flex: 0 0 260px;
        width: 260px;
        padding: 15px;
    }
    
    .content-area {
        max-width: calc(100% - 240px);
    }
}

/* Desktop breakpoint (max-width: 1200px) */
@media (max-width: 1200px) {
    .help-pane {
        flex: 0 0 250px;
        width: 250px;
        padding: 15px;
    }
    
    .content-area {
        max-width: calc(100% - 250px);
    }
}

/* Laptop breakpoint (max-width: 1600px) - Optimize layout and calendar icon */
@media (max-width: 1600px) {
    /* Reduce margins for better space utilization - keep help panel width */
    .main-layout {
        margin-right: 180px !important; /* Much smaller margin = much more space for table */
    }
    
    .header {
        margin-right: 180px !important; /* Much smaller margin = much more space for table */
    }
    
    /* Calendar icon fixes */
    .main-card table td:nth-child(5) {
        padding-left: 5px !important; /* Minimal container padding */
        min-width: 180px !important; /* Wider for calendar icon on laptops */
    }
    
    /* Just ensure minimum width - no custom padding or styling */
    .main-card table td:nth-child(5) input[type="date"] {
        min-width: 170px; /* Much wider to prevent date text overlap */
    }
    
    /* Ensure all table inputs have proper width on laptops */
    .table-input {
        min-width: 100px !important; /* Restore minimum width for all inputs */
    }
}

/* Tablet breakpoint (max-width: 1024px) */
@media (max-width: 1024px) {
    .main-layout {
        margin-right: 0;
    }
    
    /* Further reduce sell date container padding on tablets */
    .main-card table td:nth-child(5) {
        padding-left: 15px !important;
    }
    
    .header {
        margin-right: 0;
        padding-right: 0;
    }
    
    .help-pane {
        position: relative;
        top: auto;
        right: auto;
        width: 100%;
        max-height: 400px;
        margin-bottom: 20px;
        order: -1;
    }
    
    .linkedin-sidebar {
        display: none;
    }
    
    .header .linkedin-link {
        display: block;
        margin-top: 15px;
    }
    
    .header .linkedin-link a {
        color: white;
        text-decoration: none;
        padding: 8px 16px;
        background: rgba(0, 119, 181, 0.8);
        border-radius: 20px;
        display: inline-flex;
        align-items: center;
        gap: 8px;
        transition: all 0.3s ease;
        backdrop-filter: blur(10px);
    }
    
    .header .linkedin-link a:hover {
        background: rgba(0, 119, 181, 1);
        transform: translateY(-2px);
    }
}

/* Mobile breakpoint (max-width: 768px) */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .main-layout {
        margin-right: 0;
    }
    
    .header {
        margin-right: 0;
        padding-right: 0;
    }
    
    .help-pane {
        display: none;
        max-height: none;
    }
    
    .help-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .help-pane.mobile-visible {
        display: block;
        position: fixed;
        top: 10px;
        right: 10px;
        left: 10px;
        bottom: 10px;
        width: auto;
        z-index: 1001;
        height: calc(100vh - 20px);
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
        border-radius: 10px;
        padding: 20px;
        box-sizing: border-box;
    }
    
    /* Show close button only on mobile when help is visible - back to blue */
    .help-pane.mobile-visible .help-close-btn {
        display: flex !important;
        position: fixed !important;
        top: 25px !important;
        right: 25px !important;
        z-index: 1002 !important; /* Above the help panel */
        transform: none !important; /* Prevent any transforms */
        background: #007bff !important;
        border: 1px solid #0056b3 !important;
        color: white !important;
    }
    
    .main-card {
        padding: 20px;
    }
    
    .linkedin-center {
        display: none;
    }
}

/* Small mobile breakpoint (max-width: 480px) - FORCE MOBILE LAYOUT */
@media (max-width: 480px) {
    /* NUCLEAR OPTION: Override everything */
    html, body {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        overflow-x: hidden !important;
    }
    .header h1 {
        font-size: 2rem;
    }
    
    .header h1::before,
    .header h1::after {
        display: none;
    }
    
    .header p {
        font-size: 1rem;
    }
    
    .help-pane.mobile-visible {
        top: 5px;
        right: 5px;
        left: 5px;
        bottom: 5px;
        height: calc(100vh - 10px);
        padding: 15px;
        border-radius: 8px;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
        box-sizing: border-box;
    }
    
    /* Ensure close button is visible on small mobile too - back to blue */
    .help-pane.mobile-visible .help-close-btn {
        display: flex !important;
        position: fixed !important;
        top: 20px !important;
        right: 20px !important;
        z-index: 1002 !important; /* Above the help panel */
        transform: none !important; /* Prevent any transforms */
        background: #007bff !important;
        border: 1px solid #0056b3 !important;
        color: white !important;
    }
    
    .main-card {
        padding: 15px;
    }
    
    /* Mobile responsive table disabled message */
    .table-disabled-calculation::before {
        font-size: 0.85rem !important;
        padding: 10px 15px !important;
        white-space: normal !important;
        max-width: 90% !important;
        line-height: 1.3 !important;
    }
    
    /* Fix main layout to use full width on mobile */
    .main-layout {
        margin-right: 0 !important;
        width: 100% !important;
    }
    
    .header {
        margin-right: 0 !important;
    }
    
    /* MAXIMUM SPECIFICITY: Force container full width on mobile */
    body .container,
    html body .container {
        max-width: 100% !important;
        width: 100% !important;
        padding: 5px !important;
        margin: 0 !important;
        box-sizing: border-box !important;
    }
    
    body .content-area,
    html body .content-area {
        width: 100% !important;
        max-width: 100% !important;
    }
    
    body .main-card,
    html body .main-card {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        border-radius: 0 !important;
        box-sizing: border-box !important;
    }
    
    /* Fix header section and buttons visibility on mobile */
    .form-section h2 {
        font-size: 1.2rem !important;
        margin-bottom: 10px !important;
    }
    
    /* Make header responsive - stack on very small screens */
    .form-section > div[style*="justify-content: space-between"] {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 10px !important;
    }
    
    .table-header-buttons {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 5px !important;
        justify-content: flex-start !important;
        width: 100% !important;
    }
    
    .table-header-buttons .btn {
        font-size: 0.75rem !important;
        padding: 6px 10px !important;
        white-space: nowrap !important;
        flex: 1 1 auto !important;
        min-width: 90px !important;
    }
    
    /* Mobile table solution: Enable horizontal scrolling with prominent scrollbar */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        width: 100%;
    }
    
    /* Custom scrollbar styling for input table container */
    .table-container::-webkit-scrollbar {
        height: 12px !important; /* Make scrollbar thicker */
    }
    
    .table-container::-webkit-scrollbar-track {
        background: #f1f1f1 !important; /* Light grey track */
        border-radius: 6px !important;
    }
    
    .table-container::-webkit-scrollbar-thumb {
        background: #333 !important; /* Dark grey/black thumb */
        border-radius: 6px !important;
        border: 2px solid #f1f1f1 !important; /* Border for better contrast */
    }
    
    .table-container::-webkit-scrollbar-thumb:hover {
        background: #000 !important; /* Darker on hover */
    }
    
    /* Make table wider than screen and scrollable */
    .main-card table,
    .data-table {
        min-width: 800px; /* Force table to be wider than mobile screen */
        table-layout: auto; /* Allow flexible column sizing */
    }
    
    /* Remove restrictive min-widths on mobile */
    .main-card table th,
    .main-card table td {
        padding: 4px 2px;
        font-size: 0.8rem;
        min-width: unset; /* Remove all min-width constraints */
    }
    
    /* Minimal sell date container padding on mobile */
    .main-card table td:nth-child(5) {
        padding-left: 10px !important;
    }
    
    .table-input {
        padding: 6px;
        font-size: 12px;
        min-width: unset; /* Remove input min-widths */
    }
    
    /* Ensure date inputs keep minimum width for calendar icon on mobile */
    .table-input[type="date"] {
        min-width: 130px !important;
    }
    
    /* Ensure refresh icons are always visible on mobile */
    .refresh-data-icon {
        margin-left: 6px !important;
        font-size: 0.75rem !important;
        min-width: 10px !important;
        flex-shrink: 0 !important;
        color: #1a202c !important; /* Even darker on mobile for better visibility */
        opacity: 0.95 !important;
    }
    
    /* Give extra space to columns with refresh icons on mobile */
    .main-card table th:nth-child(4), 
    .main-card table td:nth-child(4) { 
        min-width: 100px !important; /* Vest price column */
    }
    
    .main-card table th:nth-child(8), 
    .main-card table td:nth-child(8) { 
        min-width: 90px !important; /* Dividend column */
    }
    
    /* Ensure editable fields have proper layout on mobile */
    .editable-field {
        min-height: 28px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
    }
    
    .editable-field .field-display {
        flex: 1 !important;
        min-width: 0 !important;
        margin-right: 2px !important;
        font-size: 0.75rem !important;
    }
    
    /* Mobile results/output table horizontal scrolling with prominent scrollbar */
    .results-table-container {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        width: 100% !important;
    }
    
    /* Custom scrollbar styling for results table container */
    .results-table-container::-webkit-scrollbar {
        height: 12px !important; /* Make scrollbar thicker */
    }
    
    .results-table-container::-webkit-scrollbar-track {
        background: #f1f1f1 !important; /* Light grey track */
        border-radius: 6px !important;
    }
    
    .results-table-container::-webkit-scrollbar-thumb {
        background: #333 !important; /* Dark grey/black thumb */
        border-radius: 6px !important;
        border: 2px solid #f1f1f1 !important; /* Border for better contrast */
    }
    
    .results-table-container::-webkit-scrollbar-thumb:hover {
        background: #000 !important; /* Darker on hover */
    }
    
    .results-table {
        min-width: 1000px !important; /* Force results table to be wider than mobile screen */
        table-layout: auto !important; /* Allow flexible column sizing */
        width: auto !important; /* Override fixed 100% width */
    }
    
    .results-table th,
    .results-table td {
        padding: 6px 4px !important;
        font-size: 0.7rem !important;
        min-width: unset !important; /* Remove restrictive min-widths */
        white-space: nowrap !important; /* Prevent text wrapping */
    }
    
    .btn {
        padding: 10px 20px;
        font-size: 14px;
    }
    
    .results-table th,
    .results-table td {
        padding: 6px 4px;
        font-size: 0.75rem;
    }
    
    .modal-content {
        margin: 10% auto;
        padding: 20px;
        width: 95%;
    }
}

/* Print styles */
@media print {
    .help-pane,
    .help-toggle,
    .linkedin-sidebar,
    .header .linkedin-link,
    .btn,
    .table-actions,
    .progress-bar,
    .status-message {
        display: none !important;
    }
    
    .main-layout {
        margin-right: 0;
    }
    
    .header {
        margin-right: 0;
        color: black;
    }
    
    .main-card {
        box-shadow: none;
        border: 1px solid #ccc;
    }
    
    .results-table {
        font-size: 10px;
    }
    
    .results-table th,
    .results-table td {
        padding: 4px;
        border: 1px solid #ccc;
    }
}
