/* Root Variables */
:root {
    /* Color variables */
    --primary-color: #2c3e50;
    --secondary-color: #34495e;
    --accent-color: #3498db;
    --text-light: #ecf0f1;
    --text-dark: #2c3e50;
    --success-color: #27ae60;
    --warning-color: #f1c40f;
    --danger-color: #e74c3c;
    --background-color: #f5f6fa;
    --border-color: #ddd;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --hover-color: #2980b9;
    
    /* Layout variables */
    --ipad-header-height: 60px;
    --ipad-footer-height: 50px;
    --ipad-content-padding: 16px;
    --map-height: 400px;
    --map-height-tablet: 500px;
    
    /* Touch-specific variables */
    --touch-target-size: 44px;
    --touch-spacing: 8px;
    --touch-padding: 12px 20px;

    /* Map marker colors */
    --marker-complete: #44FF44;
    --marker-incomplete: #FF4444;
    --marker-stroke: #FFFFFF;
}

/* Base Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    line-height: 1.6;
    background-color: var(--background-color);
    color: var(--text-dark);
    -webkit-text-size-adjust: 100%;
    padding-bottom: env(safe-area-inset-bottom);
}

/* Layout Components */
.container {
    max-width: 1024px;
    margin: 0 auto;
    padding: var(--ipad-content-padding);
    min-height: calc(100vh - var(--ipad-header-height) - var(--ipad-footer-height));
}

/* Header Styles */
.header {
    background-color: var(--primary-color);
    color: var(--text-light);
    padding: 1rem;
    text-align: center;
    box-shadow: 0 2px 4px var(--shadow-color);
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--ipad-header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.user-info {
    background-color: var(--secondary-color);
    color: var(--text-light);
    padding: 0.5rem 1rem;
    text-align: right;
    font-size: 0.9rem;
}

.user-info a {
    color: var(--text-light);
    text-decoration: none;
    margin-left: 1rem;
}

/* Form Styles */
.edit-form {
    max-width: 1024px;
    margin: var(--ipad-content-padding) auto;
    padding: var(--ipad-content-padding);
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px var(--shadow-color);
}

/* Records Info Styles */
.records-info {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 12px 16px;
    margin-bottom: 16px;
    font-size: 14px;
}

.records-info p {
    margin: 0;
    line-height: 1.4;
}

.records-info p:first-child {
    font-weight: 600;
    color: var(--text-dark);
}

.records-info p em {
    color: #6c757d;
    font-style: italic;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-dark);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: var(--touch-padding);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 16px;
    min-height: var(--touch-target-size);
    background-color: white;
}

.form-group .field-hint {
    font-size: 0.875rem;
    color: var(--secondary-color);
    margin-top: 0.25rem;
}

.form-group .error-hint {
    display: none;
    color: var(--danger-color);
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

.required {
    color: var(--danger-color);
    margin-left: 0.25rem;
}

.input-error {
    border-color: var(--danger-color);
    background-color: #fff9f9;
}

.form-textarea {
    min-height: 100px;
    resize: vertical;
}

/* Alert and Debug Styles */
.alert {
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: 8px;
    font-weight: 500;
}

.alert-success {
    background-color: var(--success-color);
    color: var(--text-light);
}

.alert-error {
    background-color: var(--danger-color);
    color: var(--text-light);
}

.debug-info {
    background: #f8f9fa;
    padding: 1rem;
    margin: 1rem 0;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.debug-info pre {
    white-space: pre-wrap;
    word-wrap: break-word;
}

.button-group {
    margin-top: 2rem;
    display: flex;
    gap: 1rem;
    align-items: center;
}

/* Button Styles */
.button,
.action-button {
    background-color: var(--accent-color);
    color: var(--text-light);
    border: none;
    min-height: var(--touch-target-size);
    padding: var(--touch-padding);
    font-size: 16px;
    border-radius: 8px;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    margin: 8px 0;
    width: auto;
    min-width: var(--touch-target-size);
    touch-action: manipulation;
    transition: transform 0.1s ease, background-color 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    font-weight: 500;
}

.button:hover,
.action-button:hover {
    background-color: var(--hover-color);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

/* Action Button Specific Styles */
.action-button {
    background-color: var(--accent-color);
    color: white;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: 2px solid var(--accent-color);
}

.action-button:hover {
    background-color: var(--hover-color);
    border-color: var(--hover-color);
}

/* Export Button */
.export-button {
    background-color: var(--success-color);
}

.export-button:hover {
    background-color: #219a52;
}

/* Tab Navigation */
.tabs {
    margin: 2rem 0;
    background: white;
    padding: 0.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px var(--shadow-color);
}

.tab-list {
    display: flex;
    list-style: none;
    padding: 0;
    margin: 0;
    border-bottom: 1px solid var(--border-color);
}

.tab-button {
    flex: 1;
    padding: 1rem;
    border: none;
    background: none;
    font-size: 1.1rem;
    color: var(--text-dark);
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.3s ease;
    min-height: var(--touch-target-size);
}

.tab-button:hover {
    background-color: var(--background-color);
}

.tab-button.active {
    border-bottom-color: var(--accent-color);
    color: var(--accent-color);
}

/* Table Styles */
.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 16px 0;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px var(--shadow-color);
}

.properties-table {
    width: 100%;
    border-collapse: collapse;
}

.properties-table th,
.properties-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    min-height: var(--touch-target-size);
}

.properties-table th {
    background-color: #f8f9fa;
    color: var(--text-dark);
    font-weight: 600;
    border-bottom: 2px solid var(--accent-color);
}

.properties-table tr:hover {
    background-color: var(--background-color);
}

/* Sort Links */
.sort-link {
    color: var(--primary-color);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: color 0.3s ease;
    font-weight: 600;
}

.sort-link:hover {
    color: var(--accent-color);
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 1.5rem 0;
    gap: 0.5rem;
}

.pagination button {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    background-color: white;
    border-radius: 4px;
    cursor: pointer;
    touch-action: manipulation;
    min-height: var(--touch-target-size);
}

.pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination span {
    padding: 0.5rem;
}

/* System Messages and Overlays */
.timeout-warning {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: rgba(231, 76, 60, 0.95);
    color: white;
    padding: 1rem;
    text-align: center;
    z-index: 1000;
    display: none;
}

/* Media Queries for iPad */
@media (min-width: 768px) and (max-width: 1024px) {
    .container {
        padding: 12px;
    }

    .button-container {
        grid-template-columns: repeat(2, 1fr);
    }

    #map {
        height: 50vh;
    }

    .dashboard-section {
        padding: 16px;
    }

    .quote-type-buttons {
        flex-direction: column;
    }

    .quote-button {
        width: 100%;
    }
}

/* iPad Portrait Mode */
@media (min-width: 768px) and (max-width: 1024px) and (orientation: portrait) {
    .button-container {
        grid-template-columns: 1fr;
    }

    .dashboard-section {
        padding: 12px;
    }

    .tab-button {
        padding: 0.75rem 0.5rem;
        font-size: 0.9rem;
    }

    .properties-table {
        font-size: 0.9rem;
    }

    .properties-table th,
    .properties-table td {
        padding: 0.75rem 0.5rem;
    }
}

/* Mobile and Small Tablet Styles */
@media (max-width: 768px) {
    .container {
        padding: 8px;
    }

    .edit-form {
        padding: 1rem;
        margin: 1rem;
    }
    
    .button-group {
        flex-direction: column;
        width: 100%;
    }
    
    .button-group .button {
        width: 100%;
    }

    .properties-table th,
    .properties-table td {
        padding: var(--touch-padding);
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 16px; /* Prevents iOS zoom */
    }
}

/* Touch Device Optimizations */
@media (hover: none) {
    .button:active,
    .action-button:active,
    .quote-button:active,
    .tab-button:active {
        transform: scale(0.98);
    }

    .button,
    .action-button,
    .quote-button,
    .tab-button {
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        user-select: none;
    }
}

/* Print Styles */
@media print {
    .button-container,
    .quote-type-buttons,
    .tabs {
        display: none;
    }

    .container {
        padding: 0;
        max-width: none;
    }

    .dashboard-section {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid var(--border-color);
    }

    .property-info .button-group {
        display: none;
    }

    .legend {
        break-inside: avoid;
        position: static;
        margin: 20px 0;
        max-width: none;
        box-shadow: none;
        border: 1px solid var(--border-color);
    }
}

/* Add these map-specific styles to your styles.css */
.map {
    height: 600px;
    width: 100%;
    margin: 20px 0;
    border-radius: 8px;
    box-shadow: 0 2px 4px var(--shadow-color);
}

.loading-indicator {
    text-align: center;
    padding: 20px;
    font-weight: bold;
}

.loading-indicator.active {
    display: block;
}

.loading-indicator.error {
    color: var(--danger-color);
}

/* Add these to the end of your existing styles.css */

/* Condition Check and Task Grid */
.task-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    padding: 1rem;
    margin-top: 1rem;
}

.task-card {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px var(--shadow-color);
    padding: 1.5rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border-left: 4px solid var(--accent-color);
}

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

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

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

.task-card.completed {
    opacity: 0.7;
    transform: scale(0.98);
}

.task-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.task-header h3 {
    margin: 0;
    color: var(--text-dark);
    font-size: 1.2rem;
}

.territory-badge {
    background-color: var(--accent-color);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.9rem;
}

.task-details {
    margin-top: 1rem;
}

.time-info {
    margin-bottom: 1rem;
}

.time-info p {
    margin: 0.5rem 0;
    font-size: 0.95rem;
}

.label {
    font-weight: 600;
    color: var(--text-dark);
    margin-right: 0.5rem;
}

/* Status Badges */
.status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.85rem;
    font-weight: 500;
}

.status-badge.pending_decision {
    background-color: var(--warning-color);
    color: var(--text-dark);
}

.status-badge.scheduled {
    background-color: var(--accent-color);
    color: white;
}

.status-badge.en_route {
    background-color: #3498db;
    color: white;
}

.status-badge.arrived {
    background-color: #9b59b6;
    color: white;
}

.status-badge.in_progress {
    background-color: #f1c40f;
    color: var(--text-dark);
}

.status-badge.completed {
    background-color: var(--success-color);
    color: white;
}

.status-badge.cancelled {
    background-color: var(--danger-color);
    color: white;
}


.status-badge.approved {
    background-color: #ffffaa; /* Light yellow */
    color: #333;
}

.status-badge.refused {
    background-color: #ff4d4d; /* Red */
    color: white;
}



/* Task Actions */
.task-actions {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.condition-form {
    margin: 0;
}

.button-group {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.button-group .button {
    flex: 1;
    min-width: 120px;
    text-align: center;
    margin: 0;
}

.success-button {
    background-color: var(--success-color);
}

.success-button:hover {
    background-color: #219a52;
}

.danger-button {
    background-color: var(--danger-color);
}

.danger-button:hover {
    background-color: #c0392b;
}

/* Time and Priority Indicators */
.deadline {
    color: var(--danger-color);
    font-weight: 600;
}

.urgency-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 0.5rem;
}

.urgency-indicator.high {
    background-color: var(--danger-color);
}

.urgency-indicator.medium {
    background-color: var(--warning-color);
}

.urgency-indicator.low {
    background-color: var(--success-color);
}

/* Task Progress */
.progress-steps {
    display: flex;
    justify-content: space-between;
    margin: 1rem 0;
    padding: 0;
    list-style: none;
}

.progress-step {
    flex: 1;
    text-align: center;
    position: relative;
    padding-top: 20px;
}

.progress-step::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background-color: var(--border-color);
}

.progress-step.completed::before {
    background-color: var(--success-color);
}

.progress-step.current::before {
    background-color: var(--accent-color);
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .task-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
        padding: 0.5rem;
    }

    .button-group {
        flex-direction: column;
    }

    .button-group .button {
        width: 100%;
    }

    .task-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .progress-steps {
        flex-direction: column;
        gap: 1rem;
    }

    .progress-step {
        text-align: left;
        padding-left: 24px;
    }

    .progress-step::before {
        left: 0;
        top: 50%;
        transform: translateY(-50%);
    }
}

/* Print Styles */
@media print {
    .task-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid var(--border-color);
    }

    .button-group,
    .condition-form {
        display: none;
    }
}

.task-info {
    padding: 10px;
}

.task-info h3 {
    margin: 0 0 10px 0;
    color: var(--text-dark);
}

.task-info p {
    margin: 5px 0;
    font-size: 14px;
}

.task-info strong {
    color: var(--primary-color);
}

.loading-indicator.error {
    color: var(--danger-color);
    font-weight: bold;
}

/* ======================
   STRIPE PAYMENT STYLES
   ====================== */

/* Payment Methods Section */
.payment-section {
    margin-top: 2rem;
}

.payment-methods-list {
    margin-bottom: 20px;
}

.payment-card {
    display: flex;
    align-items: flex-start;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 10px;
    transition: all 0.3s;
    background-color: white;
}

.payment-card.default {
    border-color: var(--accent-color);
    background-color: #f0f7ff;
    box-shadow: 0 2px 5px var(--shadow-color);
}

.payment-details {
    flex-grow: 1;
    position: relative;
}

.card-nickname {
    font-size: 1.2em;
    margin-bottom: 5px;
    color: var(--accent-color);
    font-weight: bold;
}

.card-info {
    font-size: 1.1em;
    margin-bottom: 5px;
}

.card-type {
    font-weight: bold;
    color: var(--text-dark);
    text-transform: capitalize;
}

.billing-address {
    font-size: 0.9em;
    color: var(--secondary-color);
}

.default-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background-color: var(--accent-color);
    color: white;
    font-size: 0.8em;
    padding: 2px 8px;
    border-radius: 10px;
}

.card-actions {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.inline-form {
    display: inline-block;
}

.secondary-button {
    background-color: var(--secondary-color);
    color: white;
}

.secondary-button:hover {
    background-color: #2c3e50;
}

.danger-button {
    background-color: var(--danger-color);
    color: white;
}

.danger-button:hover {
    background-color: #c0392b;
}

/* Nickname Form Styling */
.nickname-form {
    background-color: #f8f9fa;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 15px;
    margin-top: 10px;
    margin-bottom: 10px;
}

.nickname-form .form-group {
    margin-bottom: 15px;
}

.nickname-form .button-group {
    margin-bottom: 0;
}

.field-hint {
    font-size: 0.85em;
    color: var(--secondary-color);
    margin-top: 5px;
}

/* Address Card Styling */
.addresses-section {
    margin-bottom: 2rem;
}

.addresses-list {
    margin-bottom: 20px;
}

.address-card {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 10px;
    background-color: white;
    position: relative;
}

.address-card.default {
    border-color: var(--accent-color);
    background-color: #f0f7ff;
    box-shadow: 0 2px 5px var(--shadow-color);
}

.address-details {
    flex-grow: 1;
}

.address-details p {
    margin: 4px 0;
}

/* Test Cards Info Styling */
.test-cards-info {
    background-color: #f0f7ff;
    border: 1px solid var(--accent-color);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
}

.test-cards-info h4 {
    margin: 0 0 10px 0;
    color: var(--accent-color);
    font-size: 16px;
}

.test-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 8px;
    margin-bottom: 10px;
}

.test-card-item {
    font-size: 13px;
    padding: 4px 0;
}

.test-card-note {
    font-size: 12px;
    color: var(--secondary-color);
    margin: 0;
    font-style: italic;
}

/* ======================
   STRIPE ELEMENTS CORE STYLES
   ====================== */

/* Main Stripe Element Container - CRITICAL */
#card-element {
    min-height: 40px !important;
    background-color: white !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 8px !important;
    padding: 10px 12px !important;
    margin-bottom: 15px !important;
    box-sizing: border-box !important;
    transition: border-color 0.2s !important;
    position: relative !important;
    z-index: 1 !important;
    display: block !important;
    visibility: visible !important;
}

#card-element:focus-within {
    border-color: var(--accent-color) !important;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2) !important;
}

/* Stripe iframe - ensure it's visible */
#card-element iframe {
    width: 100% !important;
    height: 100% !important;
    border: none !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Ensure form is visible when shown */
#addPaymentForm[style*="block"] {
    visibility: visible !important;
    opacity: 1 !important;
    display: block !important;
}

/* Stripe's own element styling */
.StripeElement {
    box-sizing: border-box !important;
    height: 40px !important;
    padding: 10px 12px !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 8px !important;
    background-color: white !important;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1) !important;
    transition: box-shadow 150ms ease !important;
}

.StripeElement--focus {
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.2) !important;
    border-color: var(--accent-color) !important;
}

.StripeElement--invalid {
    border-color: var(--danger-color) !important;
}

.StripeElement--webkit-autofill {
    background-color: #fefde5 !important;
}

/* Card Errors */
.card-errors {
    color: var(--danger-color) !important;
    margin-top: 5px !important;
    font-size: 14px !important;
    min-height: 20px !important;
    display: block !important;
}

/* Loading State */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Form Row Layout */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

/* Enhanced Form Styles for Payment */
.form {
    background-color: #f8f9fa;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    margin-top: 15px;
}

/* Override any conflicting form-group styles */
.form .form-group {
    margin-bottom: 20px;
}

.form .form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: var(--text-dark);
}

.form .form-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 16px; /* Prevents iOS zoom */
    transition: border-color 0.2s;
    box-sizing: border-box;
    background-color: white;
}

.form .form-input:focus {
    border-color: var(--accent-color);
    outline: none;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

/* Button group for payment forms */
.form .button-group {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

/* Responsive Design for Payment Forms */
@media (max-width: 768px) {
    .payment-card {
        flex-direction: column;
    }
    
    .card-actions {
        margin-top: 15px;
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    .address-card {
        flex-direction: column;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .test-cards-grid {
        grid-template-columns: 1fr;
    }

    .form .button-group {
        flex-direction: column;
    }

    .form .button-group .button {
        width: 100%;
    }
}

/* Alert Enhancements */
.alert-error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 20px;
}

.alert-success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 20px;
}

.alert-info {
    background-color: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 20px;
}

/* Required field indicator */
.required {
    color: var(--danger-color);
}

/* Debug styles for troubleshooting */
.stripe-debug {
    border: 2px dashed red !important;
    background: yellow !important;
    min-height: 60px !important;
}

/* Ensure no global styles interfere with Stripe */
#card-element * {
    box-sizing: border-box !important;
}

/* Prevent any margin/padding resets from affecting Stripe */
#card-element,
#card-element * {
    margin: 0 !important;
    padding: 0 !important;
}

#card-element {
    padding: 10px 12px !important; /* Re-apply the padding we want */
}

/* ======================
   ENHANCED CUSTOMER NAVIGATION STYLES
   ====================== */

/* Hide default header navigation on customer pages */
.customer-page .main-header .user-nav,
[data-page^="customer-"] .main-header .user-nav {
    display: none;
}

/* Enhanced Dashboard Navigation Bar */
.dashboard-nav {
    background: linear-gradient(135deg, #4c7daf 0%, #3a6491 100%);
    padding: 0;
    margin: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    border-bottom: 3px solid #2a5480;
    position: sticky;
    top: 0;
    z-index: 100;
    overflow-x: auto;
    white-space: nowrap;
}

.dashboard-nav .nav-container {
    display: flex;
    align-items: center;
    min-width: fit-content;
    padding: 0 20px;
}

.dashboard-nav .nav-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 15px 20px;
    background: none;
    border: none;
    color: white;
    text-decoration: none;
    font-weight: 500;
    font-size: 14px;
    transition: all 0.3s ease;
    border-radius: 0;
    white-space: nowrap;
    position: relative;
    min-height: 50px;
    cursor: pointer;
}

.dashboard-nav .nav-button:hover {
    background-color: rgba(255, 255, 255, 0.15);
    color: white;
    text-decoration: none;
    transform: translateY(-1px);
}

.dashboard-nav .nav-button:active {
    transform: translateY(0);
}

/* Active state for current page */
.dashboard-nav .nav-button.active {
    background-color: rgba(255, 255, 255, 0.25);
    color: #ffffff;
    font-weight: 600;
    border-bottom: 3px solid #ffffff;
    cursor: default;
}

.dashboard-nav .nav-button.active:hover {
    background-color: rgba(255, 255, 255, 0.25);
    transform: none;
}

/* Logout button styling */
.dashboard-nav .logout-button {
    margin-left: auto;
    background-color: rgba(220, 53, 69, 0.8);
    border-radius: 4px;
    margin-right: 0;
}

.dashboard-nav .logout-button:hover {
    background-color: rgba(220, 53, 69, 1);
    transform: translateY(-1px);
}

.dashboard-nav .logout-button.active {
    background-color: rgba(220, 53, 69, 1);
    border-bottom: 3px solid #ffffff;
}

/* Responsive design for mobile */
@media (max-width: 768px) {
    .dashboard-nav {
        overflow-x: scroll;
        -webkit-overflow-scrolling: touch;
    }
    
    .dashboard-nav .nav-container {
        padding: 0 10px;
    }
    
    .dashboard-nav .nav-button {
        padding: 12px 16px;
        font-size: 13px;
        min-width: 80px;
    }
    
    .dashboard-nav .logout-button {
        margin-left: 20px;
        margin-right: 10px;
    }
}

@media (max-width: 480px) {
    .dashboard-nav .nav-button {
        padding: 10px 12px;
        font-size: 12px;
        min-width: 70px;
    }
    
    .dashboard-nav .logout-button {
        margin-left: 15px;
        margin-right: 5px;
    }
}

/* Ensure smooth scrolling on mobile */
.dashboard-nav::-webkit-scrollbar {
    height: 3px;
}

.dashboard-nav::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
}

.dashboard-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
}

.dashboard-nav::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

/* ======================
   FRANCHISEE NAVIGATION STYLES
   Applied only to pages with data-page="franchisee-*" or .franchisee-page class
   Reserved for future franchisee navigation implementation
   ====================== */

/* Placeholder for franchisee navigation - can be expanded later */
.franchisee-page .main-header .user-nav,
[data-page^="franchisee-"] .main-header .user-nav {
    /* Keep default navigation visible for franchisee pages */
    display: flex;
}

/* Future franchisee-specific navigation styles can go here */

/* Cart count badge in navigation */
.cart-nav-button {
    position: relative;
}

.cart-count-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background-color: var(--danger-color);
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
    line-height: 1.2;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* Hide badge when count is 0 */
.cart-count-badge:empty {
    display: none;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .cart-count-badge {
        top: -6px;
        right: -6px;
        font-size: 0.7rem;
        padding: 1px 4px;
        min-width: 16px;
    }
}

/* Contact Management Page Styles */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.stat-card {
    background: #f8f9fa;
    padding: 1.5rem;
    border-radius: 8px;
    text-align: center;
    border: 2px solid #e9ecef;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.stat-card.active { 
    border-color: #28a745; 
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
}

.stat-card.inactive { 
    border-color: #ffc107; 
    background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
}

.stat-card.suspended { 
    border-color: #dc3545; 
    background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
}

.stat-card:not(.active):not(.inactive):not(.suspended) {
    border-color: #6c757d;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
}

.stat-number {
    font-size: 2.5rem;
    font-weight: bold;
    color: #2c3e50;
    display: block;
    margin-bottom: 0.5rem;
    line-height: 1;
}

.stat-label {
    color: #495057;
    font-size: 0.9rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0;
}

.role-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
}

.role-stat {
    background: white;
    padding: 1.25rem;
    border-radius: 8px;
    text-align: center;
    border: 2px solid #e9ecef;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.role-stat:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    border-color: #007bff;
}

.role-name {
    font-weight: 600;
    color: #495057;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
}

.role-count {
    font-size: 1.75rem;
    font-weight: bold;
    color: #007bff;
    margin: 0;
    line-height: 1;
}

.header-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

.no-data {
    text-align: center;
    color: #666;
    font-style: italic;
    padding: 2rem;
}

/* Search and Filter Styles */
.search-section {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 2rem;
}

.search-form {
    margin-bottom: 0;
}

.search-filters {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1rem;
}

.filter-row {
    display: flex;
    gap: 1.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.search-row {
    display: flex;
    gap: 1.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.filter-label {
    font-weight: 600;
    color: #495057;
    min-width: 80px;
    font-size: 0.9rem;
}

.filter-select {
    min-width: 200px;
    padding: 0.5rem;
    font-size: 0.9rem;
}

.search-input {
    min-width: 300px;
    padding: 0.5rem;
    font-size: 0.9rem;
}

/* Email Link Styles */
.email-link {
    color: #007bff;
    text-decoration: none;
    cursor: pointer;
    transition: color 0.2s ease;
    font-weight: 500;
}

.email-link:hover {
    color: #0056b3;
    text-decoration: underline;
}

.email-link:active {
    color: #004085;
}

.email-link:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
    border-radius: 3px;
}

/* Phone Link Styles */
.phone-link {
    color: #28a745;
    text-decoration: none;
    cursor: pointer;
    transition: color 0.2s ease;
    font-weight: 500;
}

.phone-link:hover {
    color: #1e7e34;
    text-decoration: underline;
}

.phone-link:active {
    color: #155724;
}

.phone-link:focus {
    outline: 2px solid #28a745;
    outline-offset: 2px;
    border-radius: 3px;
}

.sms-link {
    font-size: 0.85rem;
    color: #6c757d;
    margin-top: 2px;
    display: inline-block;
}

.sms-link:hover {
    color: #495057;
    text-decoration: underline;
}

.search-filters .form-input {
    min-width: 150px;
}

.search-filters .button {
    margin-left: 0.5rem;
}

/* Record Count Styles */
.record-count {
    background: #f8f9fa;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-weight: 500;
    color: #666;
}

/* Table Responsive Styles */
.table-responsive {
    overflow-x: auto;
    margin-bottom: 2rem;
}

/* Radio Cell Styles */
.radio-cell {
    text-align: center;
}

.radio-cell input[type="radio"] {
    margin: 0;
}

/* Button Group Styles */
.button-group {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    justify-content: flex-start;
}

/* Additional Contact Management Styles */
.dashboard-section {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 2rem;
}

.dashboard-section h2 {
    margin-top: 0;
    color: #333;
    border-bottom: 2px solid #eee;
    padding-bottom: 0.5rem;
}

.status-badge {
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.875rem;
    font-weight: 500;
}

.status-active { background: #d4edda; color: #155724; }
.status-inactive { background: #fff3cd; color: #856404; }
.status-suspended { background: #f8d7da; color: #721c24; }

/* Page Header Styles */
.page-header {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.page-header h1 {
    margin: 0;
    color: #333;
    font-size: 1.75rem;
}

/* Pagination Styles */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin: 2rem 0;
    flex-wrap: wrap;
}

.pagination-link {
    padding: 0.5rem 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    text-decoration: none;
    color: #333;
    background: white;
    transition: all 0.2s;
}

.pagination-link:hover {
    background: #f8f9fa;
    border-color: #007bff;
}

.pagination-current {
    padding: 0.5rem 0.75rem;
    border: 1px solid #007bff;
    border-radius: 4px;
    background: #007bff;
    color: white;
    font-weight: 500;
}

.pagination-ellipsis {
    padding: 0.5rem;
    color: #666;
}

.pagination-info {
    text-align: center;
    color: #666;
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .page-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .header-actions {
        justify-content: center;
    }
    
    .search-filters {
        flex-direction: column;
        align-items: stretch;
    }
    
    .search-filters .form-input,
    .search-filters .button {
        width: 100%;
        margin-left: 0;
        margin-top: 0.5rem;
    }
    
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 1rem;
        padding: 1rem;
    }
    
    .stat-card {
        padding: 1rem;
    }
    
    .stat-number {
        font-size: 2rem;
    }
    
    .stat-label {
        font-size: 0.8rem;
    }
    
    .role-stats {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
        gap: 0.75rem;
    }
    
    .role-stat {
        padding: 1rem;
    }
    
    .role-count {
        font-size: 1.5rem;
    }
}