/**
 * BidAnchor Custom Styles
 */

:root {
    --primary-color: #0d6efd;
    --secondary-color: #6c757d;
    --success-color: #198754;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #0dcaf0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1;
}

/* Authentication Pages */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 1rem;
}

.auth-card {
    background: white;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    padding: 2rem;
    width: 100%;
    max-width: 450px;
}

/* Mobile keyboard fixes for auth pages */
@media (max-width: 767px) {
    .auth-container {
        /* Use fixed height instead of viewport units to prevent resize on keyboard open */
        min-height: 100vh;
        height: 100%;
        align-items: flex-start;
        padding-top: 2rem;
        padding-bottom: 2rem;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Fix for iOS Safari keyboard issues */
    html {
        height: 100%;
        overflow: hidden;
    }

    body {
        height: 100%;
        overflow: auto;
        position: relative;
    }

    .auth-card {
        margin: 0 auto;
        padding: 1.5rem;
        position: relative;
        /* Ensure card doesn't get pushed off screen by keyboard */
        max-height: none;
    }

    /* Prevent input zoom on iOS */
    .auth-card input[type="email"],
    .auth-card input[type="password"],
    .auth-card input[type="text"] {
        font-size: 16px !important;
        /* Prevents iOS auto-zoom on input focus */
    }
}

.auth-logo {
    font-size: 3rem;
    color: var(--primary-color);
}

/* Dashboard */
.dashboard-card {
    transition: transform 0.2s;
}

.dashboard-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}

.stat-card {
    border-left: 4px solid var(--primary-color);
}

.stat-card.success {
    border-left-color: var(--success-color);
}

.stat-card.warning {
    border-left-color: var(--warning-color);
}

.stat-card.danger {
    border-left-color: var(--danger-color);
}

/* Tables */
.table-responsive {
    border-radius: 8px;
    overflow: hidden;
}

.table thead {
    background-color: #f8f9fa;
}

.table-hover tbody tr:hover {
    background-color: #f8f9fa;
    cursor: pointer;
}

/* Buttons */
.btn {
    border-radius: 6px;
    padding: 0.5rem 1.25rem;
    font-weight: 500;
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

/* Forms */
.form-label {
    font-weight: 600;
    margin-bottom: 0.5rem;
}



/* Cards */
.card {
    border-radius: 8px;
    border: 1px solid #e9ecef;
    margin-bottom: 1.5rem;
}

.card-header {
    background-color: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    font-weight: 600;
}

/* Client Cards */
.client-card {
    transition: all 0.2s ease-in-out;
    border: 1px solid #e3e6f0;
}

.client-card:hover {
    transform: translateY(-2px);
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(13, 110, 253, 0.15);
}

.client-card .card-title {
    color: #2e384d;
    font-weight: 600;
    font-size: 1.1rem;
}

.client-card .client-details {
    min-height: 80px;
}

.client-card .client-details i {
    width: 16px;
    text-align: center;
}

.client-list-item {
    transition: background-color 0.2s ease-in-out;
}

.client-list-item:hover {
    background-color: #f8f9fa;
}

/* Quote Cards */
.quote-card {
    transition: all 0.2s ease-in-out;
    border: 1px solid #e3e6f0;
}

.quote-card:hover {
    transform: translateY(-2px);
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(13, 110, 253, 0.15);
}

.quote-card .card-title {
    color: #2e384d;
    font-weight: 600;
    font-size: 1.1rem;
}

.quote-card .quote-stat {
    padding: 0.5rem;
    border-radius: 6px;
    background-color: #f8f9fa;
}

.quote-card .badge-lg {
    font-size: 0.75rem;
    padding: 0.5em 0.75em;
}

.quote-list-item {
    transition: background-color 0.2s ease-in-out;
}

.quote-list-item:hover {
    background-color: #f8f9fa;
}

/* Invoice Cards */
.invoice-card {
    transition: all 0.2s ease-in-out;
    border: 1px solid #e3e6f0;
}

.invoice-card:hover {
    transform: translateY(-2px);
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(13, 110, 253, 0.15);
}

.invoice-card.border-danger {
    border-color: var(--danger-color) !important;
}

.invoice-card.border-danger:hover {
    border-color: var(--danger-color) !important;
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.15);
}

.invoice-card .card-title {
    color: #2e384d;
    font-weight: 600;
    font-size: 1.1rem;
}

.invoice-card .card-title a {
    color: inherit;
}

.invoice-card .card-title a:hover {
    color: var(--primary-color);
}

.invoice-card .invoice-stat {
    padding: 0.5rem;
    border-radius: 6px;
    background-color: #f8f9fa;
}

.invoice-card .badge-lg {
    font-size: 0.75rem;
    padding: 0.5em 0.75em;
}

.invoice-list-item {
    transition: background-color 0.2s ease-in-out;
}

.invoice-list-item:hover {
    background-color: #f8f9fa;
}

/* Status Badges */
.badge {
    padding: 0.4em 0.8em;
    font-weight: 500;
}

.status-draft {
    background-color: #6c757d;
}

.status-sent {
    background-color: #0dcaf0;
}

.status-approved {
    background-color: #198754;
}

.status-rejected {
    background-color: #dc3545;
}

.status-paid {
    background-color: #198754;
}

.status-overdue {
    background-color: #dc3545;
}

/* Activity Timeline */
.activity-item {
    border-left: 2px solid #dee2e6;
    padding-left: 1rem;
    padding-bottom: 1rem;
    position: relative;
}

.activity-item::before {
    content: '';
    position: absolute;
    left: -6px;
    top: 0;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: var(--primary-color);
}

.activity-item:last-child {
    border-left-color: transparent;
}

.activity-item .activity-icon {
    position: absolute;
    left: -12px;
    top: 0;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background-color: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
}

.activity-item .activity-icon.bg-success {
    background-color: var(--success-color);
}

.activity-item .activity-icon.bg-warning {
    background-color: var(--warning-color);
}

.activity-item .activity-icon.bg-danger {
    background-color: var(--danger-color);
}

.activity-item .activity-icon.bg-info {
    background-color: var(--info-color);
}

/* Quote/Invoice Items Table */
.line-items-table {
    margin-bottom: 1rem;
}

.line-items-table input {
    font-size: 0.9rem;
}

/* Mobile Responsiveness */
@media (max-width: 767px) {
    .navbar-brand {
        font-size: 1.1rem;
    }

    .auth-card {
        margin: 1rem;
        padding: 1.5rem;
    }

    .table {
        font-size: 0.875rem;
    }

    .btn {
        font-size: 0.875rem;
        padding: 0.4rem 1rem;
    }

    /* Hide button text on mobile, show only icons */
    .quote-action-btn .btn-text,
    .invoice-action-btn .btn-text,
    .service-action-btn .btn-text,
    .client-action-btn .btn-text {
        display: none;
    }

    /* Bottom Navigation Bar for Mobile */
    .bottom-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: white;
        border-top: 1px solid #dee2e6;
        display: flex;
        justify-content: space-around;
        padding: 0.5rem 0;
        z-index: 1000;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    }

    .bottom-nav-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        text-decoration: none;
        color: #6c757d;
        font-size: 0.75rem;
        padding: 0.5rem;
        transition: color 0.2s;
    }

    .bottom-nav-item i {
        font-size: 1.5rem;
        margin-bottom: 0.25rem;
    }

    .bottom-nav-item.active {
        color: #0d6efd;
        font-weight: 600;
    }

    .bottom-nav-item:hover {
        color: #0d6efd;
        text-decoration: none;
    }

    /* Add padding to main content to prevent bottom nav overlap */
    main {
        padding-bottom: 80px !important;
    }

    /* Hide top navbar on mobile when bottom nav is visible */
    .navbar {
        display: none;
    }

    /* CRITICAL: Prevent horizontal overflow on mobile */
    body {
        overflow-x: hidden !important;
    }

    .container-fluid {
        overflow-x: hidden !important;
        padding-left: 12px !important;
        padding-right: 12px !important;
        max-width: 100vw !important;
    }

    .row {
        margin-left: 0 !important;
        margin-right: 0 !important;
        max-width: 100% !important;
    }

    .alert {
        margin-left: 0 !important;
        margin-right: 0 !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    /* Force alert action buttons to stack vertically on mobile */
    .alert .d-flex {
        flex-direction: column !important;
    }

    /* Make buttons full width on mobile */
    .alert .btn {
        width: 100% !important;
        margin-top: 0.5rem !important;
        display: block !important;
        box-sizing: border-box !important;
    }

    .alert form {
        width: 100% !important;
        max-width: 100% !important;
    }

    /* Ensure flex containers don't overflow */
    .flex-shrink-0 {
        flex-shrink: 1 !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    /* Stack header buttons vertically */
    .d-grid {
        width: 100% !important;
        max-width: 100% !important;
    }

    .d-grid .btn {
        width: 100% !important;
        margin-bottom: 0.5rem !important;
    }

    /* Fix column padding on mobile */
    [class*="col-"] {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }

    /* Client cards on mobile */
    .client-list-item {
        padding: 1rem !important;
    }
}

/* Tablet Responsiveness */
@media (min-width: 768px) and (max-width: 991px) {
    .client-action-btn .btn-text {
        display: inline;
    }
}

/* Responsive Table for Invoices/Quotes */
@media (max-width: 991.98px) {
    .table-responsive>.table>thead {
        display: none;
    }

    .table-responsive>.table>tbody>tr {
        display: block;
        border: 1px solid #dee2e6;
        border-radius: 0.5rem;
        margin-bottom: 1rem;
        padding: 1rem;
    }

    .table-responsive>.table>tbody>tr>td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        border: none;
        padding: 0.5rem 0;
    }

    .table-responsive>.table>tbody>tr>td::before {
        content: attr(data-label);
        font-weight: bold;
        margin-right: 1rem;
    }

    .table-responsive>.table>tbody>tr>td:last-child {
        justify-content: flex-end;
    }

    .table-responsive>.table>tbody>tr>td:last-child .btn-group {
        width: 100%;
        display: flex;
    }

    .table-responsive>.table>tbody>tr>td:last-child .btn-group .btn {
        flex: 1;
    }
}


/* Loading Spinner */
.spinner-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

/* Print Styles */
@media print {

    .navbar,
    .btn,
    footer {
        display: none !important;
    }

    .card {
        border: none;
        box-shadow: none;
    }
}

/* Floating Action Button (FAB) */
.fab {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    z-index: 999;
    cursor: pointer;
    transition: all 0.3s ease;
}

.fab:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.5);
}

.fab:active {
    transform: scale(0.95);
}

/* FAB Menu (when clicked) */
.fab-menu {
    position: fixed;
    bottom: 90px;
    right: 20px;
    z-index: 998;
    display: none;
}

.fab-menu.active {
    display: block;
}

.fab-menu-item {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    margin-bottom: 1rem;
    opacity: 0;
    transform: translateY(20px);
    animation: fabSlideIn 0.3s forwards;
}

.fab-menu-item:nth-child(1) {
    animation-delay: 0.05s;
}

.fab-menu-item:nth-child(2) {
    animation-delay: 0.1s;
}

.fab-menu-item:nth-child(3) {
    animation-delay: 0.15s;
}

@keyframes fabSlideIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fab-menu-label {
    background: white;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    margin-right: 0.75rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    font-size: 0.875rem;
    font-weight: 500;
    white-space: nowrap;
}

.fab-menu-button {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: white;
    color: #667eea;
    border: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    cursor: pointer;
    transition: all 0.2s;
}

.fab-menu-button:hover {
    background: #f8f9fa;
    transform: scale(1.05);
}

/* Hide FAB on desktop */
@media (min-width: 768px) {

    .fab,
    .fab-menu {
        display: none;
    }
}

/* Sticky Form Actions on Mobile */
@media (max-width: 767px) {
    .form-actions-sticky {
        position: sticky;
        bottom: 60px;
        background: white;
        padding: 1rem;
        border-top: 1px solid #dee2e6;
        margin: 0 -12px;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
        z-index: 100;
    }

    .form-actions-sticky .btn {
        width: 100%;
        margin-bottom: 0.5rem;
    }

    .form-actions-sticky .btn:last-child {
        margin-bottom: 0;
    }
}

/* Utility Classes */
.text-muted-light {
    color: #adb5bd;
}

.cursor-pointer {
    cursor: pointer;
}

.hover-shadow {
    transition: box-shadow 0.2s;
}

.hover-shadow:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* ===============================================
   Phase 2 Mobile Enhancements
   =============================================== */

/* Pull-to-Refresh Indicator */
.pull-to-refresh-indicator {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 0 0 20px 20px;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    z-index: 1050;
    opacity: 0;
    transform: translateX(-50%) translateY(-100%);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
    font-size: 0.875rem;
}

.pull-to-refresh-indicator.active {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.pull-to-refresh-indicator .spinner-border {
    width: 1rem;
    height: 1rem;
    border-width: 0.15em;
}

/* Swipe Gesture Container */
.swipeable-item {
    position: relative;
    overflow: hidden;
    touch-action: pan-y;
    transition: transform 0.3s ease;
}

.swipeable-item-content {
    position: relative;
    background: white;
    z-index: 2;
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.swipeable-item-actions {
    position: absolute;
    top: 0;
    right: 0;
    height: 100%;
    display: flex;
    align-items: center;
    z-index: 1;
}

.swipe-action-btn {
    height: 100%;
    padding: 0 1.5rem;
    border: none;
    color: white;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
}

.swipe-action-btn.edit {
    background: #0d6efd;
}

.swipe-action-btn.view {
    background: #0dcaf0;
}

.swipe-action-btn.delete {
    background: #dc3545;
}

.swipe-action-btn.pdf {
    background: #198754;
}

.swipe-action-btn:active {
    filter: brightness(0.9);
}

/* Mobile Card-Based List Layout */
@media (max-width: 767px) {
    .mobile-list-card {
        background: white;
        border: 1px solid #dee2e6;
        border-radius: 0.5rem;
        margin-bottom: 1rem;
        padding: 1rem;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
        transition: all 0.2s;
    }

    .mobile-list-card:active {
        background: #f8f9fa;
        transform: scale(0.98);
    }

    .mobile-list-card-header {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        margin-bottom: 0.75rem;
        padding-bottom: 0.75rem;
        border-bottom: 1px solid #e9ecef;
    }

    .mobile-list-card-title {
        font-weight: 600;
        font-size: 1.05rem;
        color: #2e384d;
        margin-bottom: 0.25rem;
    }

    .mobile-list-card-subtitle {
        font-size: 0.85rem;
        color: #6c757d;
    }

    .mobile-list-card-body {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }

    .mobile-list-card-row {
        display: flex;
        justify-content: space-between;
        align-items: center;
        font-size: 0.875rem;
    }

    .mobile-list-card-label {
        font-weight: 500;
        color: #6c757d;
    }

    .mobile-list-card-value {
        font-weight: 500;
        color: #2e384d;
    }

    .mobile-list-card-actions {
        margin-top: 0.75rem;
        padding-top: 0.75rem;
        border-top: 1px solid #e9ecef;
        display: flex;
        gap: 0.5rem;
    }

    .mobile-list-card-actions .btn {
        flex: 1;
        font-size: 0.875rem;
        padding: 0.5rem;
        min-height: 44px;
        /* Apple's recommended touch target size */
    }

    /* Improved Touch Targets (44px minimum) */
    .btn,
    .form-control,
    .form-select,
    .bottom-nav-item,
    .swipe-action-btn {
        min-height: 44px;
        min-width: 44px;
    }

    /* Larger tap targets for icon-only buttons */
    .btn-sm {
        min-height: 44px;
        min-width: 44px;
        padding: 0.5rem 0.75rem;
    }

    .btn-group .btn {
        min-width: 44px;
    }

    /* Table row touch targets */
    .table tbody tr {
        min-height: 60px;
    }

    .table tbody td {
        padding: 1rem 0.5rem;
    }

    /* FAB touch target */
    .fab {
        width: 56px;
        height: 56px;
        min-height: 56px;
        min-width: 56px;
    }

    .fab-menu-button {
        width: 48px;
        height: 48px;
        min-height: 48px;
        min-width: 48px;
    }
}



/* Skeleton Loading for List Items */
.skeleton-item {
    background: #f8f9fa;
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 1rem;
    animation: skeleton-pulse 1.5s ease-in-out infinite;
}

.skeleton-line {
    height: 12px;
    background: linear-gradient(90deg, #e9ecef 25%, #dee2e6 50%, #e9ecef 75%);
    background-size: 200% 100%;
    border-radius: 4px;
    margin-bottom: 0.5rem;
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
}

.skeleton-line.short {
    width: 60%;
}

.skeleton-line.medium {
    width: 80%;
}

@keyframes skeleton-pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }
}

@keyframes skeleton-shimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* ===============================================
   Modern UI System (Added for Dashboard & Clients)
   =============================================== */

/* Gradient Header */
.bg-gradient-header {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-bottom: 1px solid #dee2e6;
}

/* Page Header Modern */
.page-header-modern {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    padding: 1.5rem 0;
    margin-bottom: 2rem;
    border-bottom: 1px solid #e9ecef;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}

/* Modern Card */
.card-modern {
    background: white;
    border: 1px solid #f0f0f0;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
    transition: transform 0.2s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.2s;
    overflow: hidden;
    height: 100%;
}

.card-modern:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.06);
    border-color: #e0e0e0;
}

.card-modern .card-header {
    background: transparent;
    border-bottom: 1px solid #f0f0f0;
    padding: 1.25rem 1.5rem;
}

/* Icon Wrapper */
.icon-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    transition: all 0.2s;
}

/* Modern Action Button (Large Tile) */
.btn-modern-action {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 16px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.02);
    position: relative;
    overflow: hidden;
}

.btn-modern-action:hover {
    transform: translateY(-4px);
    border-color: var(--primary-color);
    box-shadow: 0 8px 15px rgba(13, 110, 253, 0.1);
}

.btn-modern-action:hover i {
    transform: scale(1.1);
    transition: transform 0.2s;
}

/* Modern Timeline */
.timeline-modern {
    position: relative;
    border-left: 2px solid #e9ecef;
    margin-left: 1.5rem;
    /* Space for dot */
    padding-left: 2rem;
    padding-top: 1rem;
    padding-bottom: 1rem;
}

.timeline-item-modern {
    position: relative;
    margin-bottom: 1.5rem;
}

.timeline-dot {
    position: absolute;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    z-index: 2;
    background: white;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    /* Positioning handled inline or via modifier */
    left: -2.6rem;
    /* Adjust based on padding/size */
    top: 0;
}

/* Hover effects for timeline items */
.timeline-item-modern:hover .timeline-dot {
    transform: scale(1.1);
    transition: transform 0.2s;
}

.hover-danger:hover {
    color: var(--danger-color) !important;
}

.hover-primary:hover {
    color: var(--primary-color) !important;
}