/**
 * WP Invoice Generator Pro - Frontend Styles
 * Scoped styles to prevent theme conflicts
 */

/* Container and Reset */
#wp-invoice-generator-pro {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: #374151;
    padding: 2rem 1rem;
    min-height: 100vh;
    box-sizing: border-box;
    width: 100%;
    overflow-x: hidden;
}

@media (max-width: 768px) {
    #wp-invoice-generator-pro {
        padding: 1rem 0.5rem;
    }
}

@media (max-width: 480px) {
    #wp-invoice-generator-pro {
        padding: 0.5rem 0.25rem;
    }
}

#wp-invoice-generator-pro *,
#wp-invoice-generator-pro *::before,
#wp-invoice-generator-pro *::after {
    box-sizing: border-box;
}

/* Main Container */
.wp-invoice-generator-container {
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
    overflow-x: hidden;
}

@media (max-width: 768px) {
    .wp-invoice-generator-container {
        max-width: 100%;
        margin: 0;
    }
}

.wp-invoice-generator-wrapper {
    border-radius: 8px;
    overflow: hidden;
}

/* Action Buttons */
.wp-invoice-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
    padding: 2rem;
}

@media (max-width: 768px) {
    .wp-invoice-actions {
        padding: 1rem 0.5rem;
        gap: 0.5rem;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .wp-invoice-actions {
        padding: 0.75rem 0.25rem;
    }
}

.wp-invoice-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 6px;
    font-size: 0.915rem;
    font-weight: 400;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    text-transform: none;
    white-space: nowrap;
}

@media (max-width: 768px) {
    .wp-invoice-btn {
        padding: 0.75rem 1.5rem;
        font-size: 0.915rem;
        width: calc(50% - 0.25rem);
        max-width: 280px;
        justify-content: center;
        flex: 0 0 calc(50% - 0.25rem);
    }
}

@media (max-width: 480px) {
    .wp-invoice-btn {
        padding: 0.75rem 1.5rem;
        font-size: 0.915rem;
        width: calc(50% - 0.25rem);
        max-width: 100%;
        flex: 0 0 calc(50% - 0.25rem);
    }
}

.wp-invoice-btn-primary {
    background: #2563eb;
    color: white;
}

.wp-invoice-btn-primary:hover {
    background: #1d4ed8;
    transform: translateY(-1px);
}

.wp-invoice-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.wp-invoice-icon {
    font-size: 1rem;
    display: inline-block;
    line-height: 1;
    vertical-align: middle;
}

/* Themify icon specific styling */
.wp-invoice-icon[class*="ti-"] {
    font-family: 'themify';
    font-style: normal;
    font-weight: normal;
    text-transform: none;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Main Grid Layout */
.wp-invoice-grid {
    display: grid;
    grid-template-columns: 3fr 1fr;
    gap: 2rem;
    max-width: 1400px;
    margin: 0 auto;
    padding: 2px;
}

@media (max-width: 1024px) {
    .wp-invoice-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
        padding: 1rem;
    }
}

@media (max-width: 768px) {
    .wp-invoice-grid {
        gap: 1rem;
        padding: 0.5rem;
    }
}

@media (max-width: 480px) {
    .wp-invoice-grid {
        gap: 0.75rem;
        padding: 0.25rem;
    }
}

/* Main Content */
.wp-invoice-main {
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    padding: 1.5rem;
    overflow-x: hidden;
}

@media (max-width: 768px) {
    .wp-invoice-main {
        padding: 1rem;
        border-radius: 6px;
    }
}

@media (max-width: 480px) {
    .wp-invoice-main {
        padding: 0.75rem;
        border-radius: 4px;
    }
}

/* Form Container */
.wp-invoice-form-container {
    width: 100%;
    max-width: none;
}

/* Header Section */
.wp-invoice-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 2rem;
    gap: 2rem;
}

@media (max-width: 768px) {
    .wp-invoice-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
        margin-bottom: 1.5rem;
        gap: 1.5rem;
    }
}

@media (max-width: 480px) {
    .wp-invoice-header {
        margin-bottom: 1rem;
        gap: 1rem;
    }
}

/* Logo Upload Section */
.wp-invoice-logo-section {
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .wp-invoice-logo-section {
        padding-top: 10px;
    }
}

.wp-invoice-logo-upload {
    width: 150px;
    height: 90px;
    border: 2px dashed #D1D5DB;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    background: transparent;
    position: relative;
    overflow: visible;
}

.wp-invoice-logo-upload:hover {
    border-color: #a0a0a0;
    background: transparent;
    transform: none;
    box-shadow: none;
}

.wp-invoice-logo-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    color: #6b7280;
    text-align: center;
    padding: 0.5rem;
    cursor: pointer;
    user-select: none;
    width: 100%;
    height: 100%;
    justify-content: center;
}

.wp-invoice-logo-icon {
    font-size: 1.2rem;
    opacity: 0.7;
}

.wp-invoice-logo-text {
    font-size: 0.75rem;
    font-weight: 500;
}

.wp-invoice-logo-preview {
    width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wp-invoice-logo-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 4px;
}

.wp-invoice-logo-remove {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #ef4444;
    color: white;
    border: 2px solid white;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: all 0.2s ease;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    z-index: 10;
    font-family: Arial, sans-serif;
    text-align: center;
    padding: 0;
    margin: 0;
    min-width: 24px;
    min-height: 24px;
}

/* Remove button is always visible now */

.wp-invoice-logo-remove:hover {
    background: #dc2626;
    transform: scale(1.1);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2);
}

@media (max-width: 768px) {
    .wp-invoice-logo-upload {
        width: 120px;
        height: 75px;
        overflow: visible;
        border: 2px dashed #c0c0c0;
    }

    .wp-invoice-logo-icon {
        font-size: 1rem;
    }

    .wp-invoice-logo-text {
        font-size: 0.65rem;
    }

    .wp-invoice-logo-remove {
        width: 20px;
        height: 20px;
        font-size: 12px;
        min-width: 20px;
        min-height: 20px;
        top: -8px;
        right: -8px;
    }
}



/* Title Section */
.wp-invoice-title-section {
    text-align: right;
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .wp-invoice-title-section {
        text-align: center;
        width: 100%;
    }
}

.wp-invoice-title {
    font-size: 2.5rem;
    font-weight: bold;
    color: #1f2937;
    margin: 0 0 0.5rem 0;
    cursor: pointer;
    position: relative;
}

.wp-invoice-title:hover::after {
    content: '\e61c';
    font-family: 'themify';
    position: absolute;
    left: -25px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1rem;
    opacity: 0.7;
}

@media (max-width: 768px) {
    .wp-invoice-title {
        font-size: 2rem;
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
    }
    
    .wp-invoice-title:hover::after {
        left: 10px;
        top: 50%;
        transform: translateY(-50%);
        position: absolute;
    }
}

@media (max-width: 480px) {
    .wp-invoice-title {
        font-size: 1.75rem;
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
    }
    
    .wp-invoice-title:hover::after {
        left: 10px;
        top: 50%;
        transform: translateY(-50%);
        position: absolute;
    }
    
    .wp-invoice-details .wp-invoice-label:hover::after,
    .wp-invoice-details-left .wp-invoice-label:hover::after,
    .wp-invoice-details-right .wp-invoice-label:hover::after {
        right: 10px;
        top: 50%;
        transform: translateY(-50%);
        position: absolute;
    }
    
    .wp-invoice-details .wp-invoice-label,
    .wp-invoice-details-left .wp-invoice-label,
    .wp-invoice-details-right .wp-invoice-label {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
        position: relative;
    }
}

.wp-invoice-number {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.25rem;
    font-size: 1.125rem;
}

.wp-invoice-number-input {
    border: none !important;
    border-bottom: 1px solid #d1d5db !important;
    background: transparent !important;
    font-size: 1.125rem;
    font-weight: 500;
    text-align: right;
    width: 10em !important;
    padding: 0.25rem 0;
    outline: none !important;
    transition: border-bottom-color 0.2s ease;
    border-radius: 0 !important;
    box-shadow: none !important;
}

.wp-invoice-number-input:focus {
    border: none !important;
    border-bottom: 2px solid #2563eb !important;
    background: transparent !important;
    box-shadow: none !important;
    outline: none !important;
}

/* Details Grid */
.wp-invoice-details-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.8rem;
    margin-bottom: 1rem;
}

@media (max-width: 768px) {
    .wp-invoice-details-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .wp-invoice-details-grid .wp-invoice-section {
        display: flex;
        flex-direction: column;
        margin-bottom: 1.2rem;
    }
    
    .wp-invoice-details-grid .wp-invoice-label {
        margin-bottom: 0.5rem;
        font-weight: 500;
        order: 1;
        display: block;
        width: 100%;
    }
    
    .wp-invoice-details-grid .wp-invoice-section input,
    .wp-invoice-details-grid .wp-invoice-section textarea {
        order: 2;
        width: 100%;
        margin-top: 0;
    }
}

/* Client Grid */
.wp-invoice-client-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

@media (max-width: 640px) {
    .wp-invoice-client-grid {
        grid-template-columns: 1fr;
    }
    
    .wp-invoice-client-grid .wp-invoice-section {
        display: flex;
        flex-direction: column;
        margin-bottom: 1.2rem;
    }
    
    .wp-invoice-client-grid .wp-invoice-label {
        margin-bottom: 0.5rem;
        font-weight: 500;
        order: 1;
    }
    
    .wp-invoice-client-grid .wp-invoice-section textarea {
        order: 2;
    }
}

/* Form Sections */
.wp-invoice-section {
    margin-bottom: 0.3rem;
}

.wp-invoice-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 400;
    color: #6b7280;
    margin-bottom: 0.5rem;
    cursor: pointer;
    position: relative;
}

.wp-invoice-label:hover::after {
    content: '\e61c';
    font-family: 'themify';
    position: absolute;
    right: -20px;
    font-size: 0.75rem;
    opacity: 0.7;
}

/* Mobile: Position pencil icon at end of line for form labels (excluding notes section) */
@media (max-width: 768px) {
    .wp-invoice-details .wp-invoice-label:hover::after,
    .wp-invoice-details-left .wp-invoice-label:hover::after,
    .wp-invoice-details-right .wp-invoice-label:hover::after {
        right: 10px;
        top: 50%;
        transform: translateY(-50%);
        position: absolute;
    }
    
    .wp-invoice-details .wp-invoice-label,
    .wp-invoice-details-left .wp-invoice-label,
    .wp-invoice-details-right .wp-invoice-label {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
        position: relative;
    }
}

/* Form Inputs */
.wp-invoice-form input,
.wp-invoice-form textarea,
.wp-invoice-form select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.875rem;
    outline: none;
    transition: border-color 0.2s ease;
    box-sizing: border-box;
}

@media (max-width: 768px) {
    .wp-invoice-form input,
    .wp-invoice-form textarea,
    .wp-invoice-form select {
        padding: 0.625rem;
        font-size: 0.875rem;
    }
}

@media (max-width: 480px) {
    .wp-invoice-form input,
    .wp-invoice-form textarea,
    .wp-invoice-form select {
        padding: 0.5rem;
        font-size: 0.8rem;
    }
}

.wp-invoice-form input:focus,
.wp-invoice-form textarea:focus,
.wp-invoice-form select:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
    outline: 2px solid rgba(37, 99, 235, 0.2);
    outline-offset: 2px;
}

/* Override focus styles for line item table inputs to maintain transparent appearance */
.wp-invoice-item-row input:focus {
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    outline: none !important;
}

.wp-invoice-form textarea {
    resize: vertical;
    min-height: 100px;
}

/* Items Table */
.wp-invoice-items-section {
    margin-bottom: 2rem;
}

@media (max-width: 768px) {
    .wp-invoice-items-section {
        margin-bottom: 1.5rem;
    }
}

@media (max-width: 480px) {
    .wp-invoice-items-section {
        margin-bottom: 1rem;
    }
}

.wp-invoice-items-table-container {
    overflow-x: auto;
    margin-bottom: 1rem;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    width: 100%;
    display: block;
    min-width: 600px;
}

@media (max-width: 768px) {
    .wp-invoice-items-table-container {
        display: none;
    }
}

/* Hide mobile view on desktop */
.wp-invoice-items-mobile {
    display: none;
}

.wp-invoice-items-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    display: table;
}

.wp-invoice-items-table thead {
    display: table-header-group;
}

.wp-invoice-items-table thead tr {
    display: table-row;
}

.wp-invoice-items-table tbody {
    display: table-row-group;
}

.wp-invoice-items-table tbody tr {
    display: table-row;
}

.wp-invoice-items-table th {
    background: #374151;
    color: white;
    padding: 0.75rem;
    text-align: left;
    font-weight: 500;
    font-size: 0.875rem;
    cursor: pointer;
    border: none;
    display: table-cell;
    vertical-align: middle;
    white-space: nowrap;
    writing-mode: initial;
    text-orientation: initial;
}

.wp-invoice-items-table th:hover::after {
    content: '\e61c';
    font-family: 'themify';
    margin-left: 0.5rem;
    font-size: 0.75rem;
    opacity: 0.7;
}

.wp-invoice-items-table th:nth-child(1) {
    width: 55%;
    text-align: left;
    min-width: 200px;
}

.wp-invoice-items-table th:nth-child(2) {
    width: 15%;
    text-align: left;
    min-width: 80px;
}

.wp-invoice-items-table th:nth-child(3) {
    width: 15%;
    text-align: left;
    min-width: 100px;
}

.wp-invoice-items-table th:nth-child(4) {
    width: 15%;
    text-align: left;
    min-width: 100px;
}

.wp-invoice-items-table td {
    padding: 0.5rem;
    border-bottom: 1px solid #e5e7eb;
    vertical-align: middle;
    border-left: none;
    border-right: none;
    display: table-cell;
    writing-mode: initial;
    text-orientation: initial;
    height: 52px;
}

.wp-invoice-items-table td:nth-child(1) {
    width: 50%;
    min-width: 200px;
    word-wrap: break-word;
    text-align: left;
}

.wp-invoice-items-table td:nth-child(1) input {
    width: 100% !important;
    min-width: 200px;
}

.wp-invoice-items-table td:nth-child(2) {
    width: 15%;
    text-align: center;
    min-width: 80px;
}

.wp-invoice-items-table td:nth-child(3) {
    width: 15%;
    text-align: center;
    min-width: 100px;
}

.wp-invoice-items-table td:nth-child(4) {
    width: 20%;
    text-align: center;
    min-width: 120px;
    position: relative;
}

.wp-invoice-item-row:hover {
    background: #f9fafb;
}

.wp-invoice-item-row:nth-child(even) {
    background: #f9fafb;
}

.wp-invoice-item-row:nth-child(even):hover {
    background: #f3f4f6;
}

.wp-invoice-currency-input {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    height: 40px;
}

.wp-invoice-currency-symbol {
    font-size: 0.875rem;
    color: #6b7280;
    font-weight: 500;
    line-height: 1;
}

.wp-invoice-currency-input input {
    border: none;
    background: transparent;
    outline: none;
    height: 40px;
    line-height: 1.2;
}

.wp-invoice-amount {
    background: #f9fafb;
    padding: 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    text-align: center;
    font-weight: 500;
    font-size: 0.875rem;
    min-width: 70px;
    white-space: nowrap;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.wp-invoice-remove-item {
    background: none;
    border: none;
    color: #ef4444;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    font-size: 1rem;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.wp-invoice-item-row:hover .wp-invoice-remove-item {
    opacity: 1;
}

.wp-invoice-remove-item:hover {
    background: #fef2f2;
}

.wp-invoice-add-item {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border: 1px solid #2563eb;
    background: transparent;
    color: #2563eb;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.875rem;
}

.wp-invoice-add-item:hover {
    background: transparent;
    box-shadow: none;
    color: #2563eb;
    transform: none;
}

@media (max-width: 768px) {
    .wp-invoice-add-item {
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
        width: 100%;
        justify-content: center;
        margin-top: 0.5rem;
    }
}

@media (max-width: 480px) {
    .wp-invoice-add-item {
        padding: 0.625rem 0.875rem;
        font-size: 0.85rem;
    }
}

/* Bottom Grid */
.wp-invoice-bottom-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

@media (max-width: 768px) {
    .wp-invoice-bottom-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
}

@media (max-width: 480px) {
    .wp-invoice-bottom-grid {
        gap: 1rem;
    }
}

/* Totals Section */
.wp-invoice-totals-section {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.wp-invoice-total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid #e5e7eb;
}

.wp-invoice-total-main {
    font-size: 1.125rem;
    font-weight: bold;
    border-bottom: 2px solid #374151;
    padding: 0.75rem 0;
}

.wp-invoice-balance-due {
    color: #2563eb;
    font-weight: 500;
    border-bottom: none;
}

.wp-invoice-total-label {
    color: #374151;
    cursor: pointer;
    position: relative;
}

.wp-invoice-total-label:hover::after {
    content: '\e61c';
    font-family: 'themify';
    position: absolute;
    right: -20px;
    font-size: 0.75rem;
    opacity: 0.7;
}

.wp-invoice-total-value {
    font-weight: 500;
}

.wp-invoice-total-input {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.wp-invoice-total-input input {
    width: 80px;
    padding: 0.25rem 0.5rem;
    border: none;
    border-bottom: 1px solid #d1d5db;
    text-align: right;
    outline: none;
}

.wp-invoice-total-input select {
    padding: 0.25rem;
    border: none;
    background: transparent;
    outline: none;
}

/* Type Toggle Buttons */
.wp-invoice-type-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    margin-left: 0.5rem;
}

.wp-invoice-type-toggle-btn {
    background: none !important;
    border: none !important;
    color: #6b7280 !important;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 0.25rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    transition: none !important;
    transform: none !important;
}

.wp-invoice-type-toggle-btn:hover {
    background: none !important;
    border: none !important;
    color: #6b7280 !important;
    transition: none !important;
    transform: none !important;
    box-shadow: none !important;
}

.wp-invoice-type-toggle-btn:active {
    background: none !important;
    border: none !important;
    color: #6b7280 !important;
    transition: none !important;
    transform: none !important;
    box-shadow: none !important;
}

.wp-invoice-type-display {
    font-size: 0.875rem;
    color: #374151;
    font-weight: 500;
    min-width: 20px;
    text-align: center;
}

/* Optional Toggles */
.wp-invoice-optional-toggles {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 0.5rem 0;
}

/* Hide optional toggles when all fields are active */
.wp-invoice-optional-toggles:empty {
    display: none;
    padding: 0;
    margin: 0;
}

.wp-invoice-toggle-btn {
    background: none;
    border: none;
    color: #2563eb;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 600;
    padding: 0.25rem 0;
}

.wp-invoice-toggle-btn:hover {
    color: #2563eb;
}

/* Remove all hover effects, transitions, and outlines for toggle buttons */
#toggle-discount,
#toggle-tax,
#toggle-shipping {
    outline: none !important;
    border: none !important;
    transition: none !important;
}

#toggle-discount:hover,
#toggle-tax:hover,
#toggle-shipping:hover {
    outline: none !important;
    border: none !important;
    box-shadow: none !important;
    background: none !important;
    transition: none !important;
    transform: none !important;
}

.wp-invoice-optional-row {
    position: relative;
}

.wp-invoice-remove-optional {
    background: none !important;
    border: none !important;
    color: #ef4444 !important;
    cursor: pointer;
    font-size: 1rem;
    padding: 0.25rem;
    margin-left: 0.5rem;
    transition: none !important;
    transform: none !important;
}

.wp-invoice-remove-optional:hover {
    background: none !important;
    border: none !important;
    color: #ef4444 !important;
    transition: none !important;
    transform: none !important;
    box-shadow: none !important;
}

.wp-invoice-remove-optional:active {
    background: none !important;
    border: none !important;
    color: #ef4444 !important;
    transition: none !important;
    transform: none !important;
    box-shadow: none !important;
}

/* Sidebar */
.wp-invoice-sidebar {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    min-width: 280px;
}

@media (max-width: 1024px) {
    .wp-invoice-sidebar {
        min-width: auto;
        width: 100%;
    }
}

@media (max-width: 768px) {
    .wp-invoice-sidebar {
        gap: 1rem;
    }
}

@media (max-width: 480px) {
    .wp-invoice-sidebar {
        gap: 0.75rem;
    }
}

.wp-invoice-sidebar-section {
    background: white;
    border-radius: 8px;
    padding: 1rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

@media (max-width: 768px) {
    .wp-invoice-sidebar-section {
        padding: 1rem;
        border-radius: 6px;
    }
}

@media (max-width: 480px) {
    .wp-invoice-sidebar-section {
        padding: 0.75rem;
        border-radius: 4px;
    }
}

.wp-invoice-sidebar-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.125rem;
    font-weight: 600;
    color: #1f2937;
    margin: 0 0 1rem 0;
}

.wp-invoice-count {
    color: #6b7280;
    font-weight: normal;
}

/* Currency Selector */
.wp-invoice-currency-selector {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

@media (max-width: 480px) {
    .wp-invoice-currency-selector {
        gap: 0.5rem;
        justify-content: space-between;
    }
}

.wp-invoice-currency-selector .wp-invoice-icon {
    font-size: 1.125rem;
    flex-shrink: 0;
}

.wp-invoice-currency-selector label {
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
    flex: 1;
}

.wp-invoice-currency-selector select {
    padding: 0.5rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    outline: none;
    font-size: 0.875rem;
    background: white;
    min-width: 80px;
    flex-shrink: 0;
    height: 40px;
    line-height: 1.5;
    vertical-align: middle;
    appearance: auto;
    -webkit-appearance: menulist;
    -moz-appearance: menulist;
    margin-bottom: 0;
}

/* Template Selector */
.wp-invoice-template-selector {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* Template selector icon and label styles removed - now using sidebar-title */

.wp-invoice-template-options {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}

@media (max-width: 480px) {
    .wp-invoice-template-options {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.5rem;
    }
}

.wp-invoice-template-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.75rem 0.5rem;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: white;
    text-align: center;
}

.wp-invoice-template-option:hover {
    border-color: #2563eb;
    background: #f8fafc;
}

.wp-invoice-template-option.active {
    border-color: #2563eb;
    background: #eff6ff;
    box-shadow: 0 0 0 1px #2563eb;
}

.wp-invoice-template-preview {
    width: 40px;
    height: 30px;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wp-invoice-template-icon {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Template Preview Styles */
.template-preview-standard {
    width: 32px;
    height: 24px;
    border: 1px solid #d1d5db;
    border-radius: 2px;
    padding: 3px;
    background: white;
}

.template-preview-standard .preview-header {
    width: 100%;
    height: 4px;
    background: #2563eb;
    border-radius: 1px;
    margin-bottom: 2px;
}

.template-preview-standard .preview-content {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.template-preview-standard .preview-line {
    height: 2px;
    background: #e5e7eb;
    border-radius: 1px;
}

.template-preview-standard .preview-line.short {
    width: 60%;
}

.template-preview-spreadsheet {
    width: 32px;
    height: 24px;
    border: 1px solid #d1d5db;
    border-radius: 2px;
    padding: 2px;
    background: white;
}

.template-preview-spreadsheet .preview-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 1px;
    width: 100%;
    height: 100%;
}

.template-preview-spreadsheet .preview-cell {
    background: #f3f4f6;
    border-radius: 1px;
}

.template-preview-spreadsheet .preview-cell:first-child,
.template-preview-spreadsheet .preview-cell:nth-child(2),
.template-preview-spreadsheet .preview-cell:nth-child(3) {
    background: #2563eb;
}

.template-preview-classic {
    width: 32px;
    height: 24px;
    border: 1px solid #d1d5db;
    border-radius: 2px;
    padding: 2px;
    background: white;
}

.template-preview-classic .preview-classic-header {
    width: 100%;
    height: 6px;
    background: #2563eb;
    border-radius: 1px;
    margin-bottom: 2px;
}

.template-preview-classic .preview-classic-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.template-preview-classic .preview-classic-line {
    height: 3px;
    background: #e5e7eb;
    border-radius: 1px;
}

.wp-invoice-template-name {
    font-size: 0.75rem;
    font-weight: 500;
    color: #374151;
    line-height: 1.2;
}

.wp-invoice-template-option.active .wp-invoice-template-name {
    color: #2563eb;
    font-weight: 600;
}

/* Theme Color Selector */
.wp-invoice-theme-selector {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* Theme selector icon and label styles removed - now using sidebar-title */

.wp-invoice-theme-colors {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.5rem;
    justify-items: center;
}

.wp-invoice-color-option {
    position: relative;
    cursor: pointer;
    padding: 3px;
    border-radius: 50%;
    border: 2px solid transparent;
    transition: all 0.2s ease;
}

.wp-invoice-color-option:hover {
    border-color: #d1d5db;
    transform: scale(1.1);
}

.wp-invoice-color-option.active {
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.wp-invoice-color-option .color-circle {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
}

.wp-invoice-color-option:hover .color-circle {
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.wp-invoice-color-option.active .color-circle {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

@media (max-width: 480px) {
    .wp-invoice-theme-colors {
        gap: 0.4rem;
    }
    
    .wp-invoice-color-option .color-circle {
        width: 24px;
        height: 24px;
    }
}

/* Saved Invoices */
.wp-invoice-saved-list {
    max-height: 400px;
    overflow-y: auto;
}

@media (max-width: 768px) {
    .wp-invoice-saved-list {
        max-height: 300px;
    }
}

@media (max-width: 480px) {
    .wp-invoice-saved-list {
        max-height: 250px;
    }
}

.wp-invoice-no-invoices {
    text-align: center;
    padding: 2rem 1rem;
    color: #6b7280;
}

.wp-invoice-no-invoices .wp-invoice-icon {
    font-size: 2rem;
    opacity: 0.5;
    display: block;
    margin-bottom: 0.5rem;
}

.wp-invoice-saved-item {
    padding: 0.75rem;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    margin-bottom: 0.0rem;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.wp-invoice-saved-item:hover {
    background: #f9fafb;
    border-color: #2563eb;
}

.wp-invoice-saved-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
}

.wp-invoice-saved-item-number {
    font-weight: 600;
    color: #1f2937;
}

.wp-invoice-saved-item-client {
    font-size: 0.875rem;
    color: #6b7280;
    margin-bottom: 0.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.wp-invoice-saved-item-details {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    color: #9ca3af;
}

.wp-invoice-saved-item-date,
.wp-invoice-saved-item-total {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.wp-invoice-delete-item {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: none;
    border: none;
    color: #ef4444;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    font-size: 1rem;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.wp-invoice-saved-item:hover .wp-invoice-delete-item {
    opacity: 1;
}

.wp-invoice-delete-item:hover {
    background: #fef2f2;
    color: #dc2626;
}

/* Editable Labels */
.editable-label {
    position: relative;
    cursor: pointer;
    display: inline-block;
}

.editable-label.editing {
    background: transparent;
    border-bottom: none;
    outline: none;
    min-width: 100px;
    border-radius: 0;
    /* Remove padding to prevent position changes */
}

/* Override white font color for table headers during inline editing */
.wp-invoice-items-table th.editable-label.editing {
    color: white !important;
    background: #374151 !important;
    border-radius: 0 !important;
    text-align: left;
    /* Maintain original table header padding */
    padding: 0.75rem !important;
}

/* Maintain position for first column (Item Description) */
.wp-invoice-items-table th:nth-child(1).editable-label.editing {
    text-align: left !important;
    padding: 0.75rem !important;
}

/* Ensure consistent positioning for all table header editable labels */
.wp-invoice-items-table th:nth-child(2).editable-label.editing,
.wp-invoice-items-table th:nth-child(3).editable-label.editing,
.wp-invoice-items-table th:nth-child(4).editable-label.editing {
    text-align: left !important;
    padding: 0.75rem !important;
}

/* For mobile card labels, maintain original spacing */
.wp-invoice-item-card-label.editable-label.editing {
    padding: 0 !important;
    margin: 0 !important;
    display: inline-block;
    width: auto;
    min-width: auto;
}

/* For mobile view, use transparent background */
@media (max-width: 768px) {
    .wp-invoice-items-table th.editable-label.editing {
        color: #1f2937 !important;
        background: transparent !important;
    }
}

/* Table Input Styling */
.wp-invoice-items-table input {
    border: none !important;
    background: transparent !important;
    outline: none !important;
    padding: 0.75rem !important;
    font-size: 0.875rem;
    width: 100%;
    height: 40px;
    line-height: 1.2;
}

.wp-invoice-items-table input:focus {
    background: transparent !important;
    border-radius: 4px;
}

.wp-invoice-items-table td input[type="number"] {
    text-align: center;
}

.wp-invoice-items-table td:first-child input {
    text-align: left;
}

/* Remove button styling */
.wp-invoice-remove-item {
    opacity: 0;
    transition: opacity 0.2s ease;
}

.wp-invoice-item-row:hover .wp-invoice-remove-item {
    opacity: 1;
}

.wp-invoice-remove-item:hover {
    color: #dc2626 !important;
    background: rgba(220, 38, 38, 0.1) !important;
    border-radius: 4px;
}

/* Remove right margins for specified fields */
#invoice-date,
#payment-terms,
#due-date,
#po-number,
#invoice-number {
    margin-right: 0;
}

/* Add hover effects for specified fields - matching invoice-number style */
/* Add consistent border radius and focus styles for all specified fields */
#invoice-date,
#payment-terms,
#due-date,
#po-number,
#amount-paid,
#discount-value,
#tax-value,
#shipping-value,
.wp-invoice-number-input {
    border-radius: 6px;
}

#invoice-date:focus,
#payment-terms:focus,
#due-date:focus,
#po-number:focus,
#amount-paid:focus,
#discount-value:focus,
#tax-value:focus,
#shipping-value:focus,
.wp-invoice-number-input:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
    outline: 2px solid rgba(37, 99, 235, 0.2);
    outline-offset: 2px;
    border-radius: 6px;
}

/* Additional Mobile Improvements */
@media (max-width: 480px) {
    /* Ensure proper touch targets */
    .wp-invoice-form input,
    .wp-invoice-form textarea,
    .wp-invoice-form select,
    .wp-invoice-btn {
        min-height: 44px;
    }
    
    /* Improve text readability */
    .wp-invoice-form {
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    /* Better spacing for small screens */
    .wp-invoice-section {
        margin-bottom: 1rem;
        display: flex;
        flex-direction: column;
    }
    
    .wp-invoice-label {
        font-size: 0.8rem;
        margin-bottom: 0.5rem;
        display: block;
        width: 100%;
        order: 1;
    }
    
    .wp-invoice-section input,
    .wp-invoice-section textarea,
    .wp-invoice-section select {
        order: 2;
        width: 100%;
        margin-top: 0;
    }
    
    /* Ensure details right section stacks properly */
    .wp-invoice-details-right .wp-invoice-section {
        display: flex;
        flex-direction: column;
        margin-bottom: 1.2rem;
    }
    
    .wp-invoice-details-right .wp-invoice-label {
        margin-bottom: 0.5rem;
        font-weight: 500;
        color: #374151;
    }
}

/* Responsive breakpoints for better mobile experience */
@media (max-width: 768px) {
    /* Hide desktop table on tablets and mobile */
    .wp-invoice-items-table-container {
        display: none !important;
    }
    
    /* Show mobile cards */
    .wp-invoice-items-mobile {
        display: block !important;
    }
    
    /* Restore center alignment for mobile table headers */
    .wp-invoice-items-table th:nth-child(2),
    .wp-invoice-items-table th:nth-child(3),
    .wp-invoice-items-table th:nth-child(4) {
        text-align: center;
    }
}

@media (max-width: 768px) {
    .wp-invoice-items-mobile {
        display: block;
    }

    .wp-invoice-item-card {
        border: 1px solid #d1d5db;
        border-radius: 8px;
        padding: 1rem;
        margin-bottom: 1rem;
        background: white;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
        position: relative;
    }

    @media (max-width: 480px) {
        .wp-invoice-item-card {
            padding: 0.75rem;
            margin-bottom: 0.75rem;
            border-radius: 6px;
        }
    }

    .wp-invoice-item-card-description {
        margin-bottom: 1rem;
        display: flex;
        gap: 0.5rem;
        align-items: flex-start;
    }

    .wp-invoice-item-card-description input {
        flex: 1;
        padding: 0.75rem;
        border: 1px solid #d1d5db;
        border-radius: 6px;
        font-size: 0.9rem;
        background: #f9fafb;
        outline: none;
        transition: border-color 0.2s, background-color 0.2s;
        min-height: 44px;
        resize: vertical;
    }

    .wp-invoice-item-card-description input:focus {
        border-color: #2563eb;
        background: white;
        box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
        outline: 2px solid rgba(37, 99, 235, 0.2);
        outline-offset: 2px;
    }

    @media (max-width: 480px) {
        .wp-invoice-item-card-description {
            margin-bottom: 0.75rem;
        }
        
        .wp-invoice-item-card-description input {
            padding: 0.625rem;
            font-size: 0.85rem;
            min-height: 40px;
        }
    }

    .wp-invoice-item-card-details {
        display: grid;
        grid-template-columns: 80px 80px 1fr;
        gap: 0.75rem;
        margin-bottom: 0.5rem;
    }

    @media (max-width: 480px) {
        .wp-invoice-item-card-details {
            grid-template-columns: 70px 70px 1fr;
            gap: 0.5rem;
            margin-bottom: 0.25rem;
        }
    }

    .wp-invoice-item-card-field {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }

    .wp-invoice-item-card-label {
        font-size: 0.75rem;
        color: #374151;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.025em;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        cursor: pointer;
        position: relative;
    }
    
    .wp-invoice-item-card-label:hover::after {
        content: '\e61c';
        font-family: 'themify';
        position: absolute;
        right: -15px;
        font-size: 0.65rem;
        opacity: 0.7;
    }

    .wp-invoice-item-card-field input {
        padding: 0.5rem;
        border: 1px solid #d1d5db;
        border-radius: 6px;
        font-size: 0.875rem;
        text-align: center;
        background: #f9fafb;
        outline: none;
        transition: border-color 0.2s, background-color 0.2s;
        min-width: 0;
        width: 100%;
        height: 44px;
    }

    .wp-invoice-item-card-field input:focus {
        border-color: #2563eb;
        background: white;
        box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
        outline: 2px solid rgba(37, 99, 235, 0.2);
        outline-offset: 2px;
    }

    .wp-invoice-item-card-field .wp-invoice-currency-input {
        display: block;
    }

    .wp-invoice-item-card-field .wp-invoice-currency-input .wp-invoice-currency-symbol {
        display: none;
    }

    .wp-invoice-item-card-field .wp-invoice-currency-input input {
        padding: 0.5rem;
        border: 1px solid #d1d5db;
        border-radius: 6px;
        font-size: 0.875rem;
        text-align: center;
        background: #f9fafb;
        outline: none;
        transition: border-color 0.2s, background-color 0.2s;
        min-width: 0;
        width: 100%;
        height: 44px;
    }

    .wp-invoice-item-card-field .wp-invoice-currency-input input:focus {
        border-color: #2563eb;
        background: white;
        box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
        outline: 2px solid rgba(37, 99, 235, 0.2);
        outline-offset: 2px;
    }

    .wp-invoice-amount-mobile {
        padding: 0.5rem;
        border: 1px solid #d1d5db;
        border-radius: 6px;
        background: #f3f4f6;
        text-align: center;
        font-weight: 600;
        color: #374151;
        font-size: 0.875rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .wp-invoice-remove-item-mobile {
        background: #ef4444;
        color: white;
        border: none;
        border-radius: 6px;
        padding: 0.5rem;
        font-size: 0.9rem;
        cursor: pointer;
        transition: background-color 0.2s;
        flex-shrink: 0;
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
        min-width: 40px;
    }

    .wp-invoice-remove-item-mobile:hover {
        background: #dc2626;
    }

    @media (max-width: 480px) {
        .wp-invoice-remove-item-mobile {
            width: 36px;
            height: 36px;
            min-width: 36px;
            font-size: 0.8rem;
            padding: 0.4rem;
        }
    }
}

/* Print Styles */
@media print {
    #wp-invoice-generator-pro {
        background: white;
        padding: 0;
    }

    .wp-invoice-actions,
    .wp-invoice-sidebar {
        display: none;
    }

    .wp-invoice-grid {
        grid-template-columns: 1fr;
        padding: 0;
    }
    
    /* Show desktop table for printing */
    .wp-invoice-items-table-container {
        display: block !important;
    }
    
    .wp-invoice-items-mobile {
        display: none !important;
    }
}

/* Loading States */
.wp-invoice-loading {
    opacity: 0.6;
    pointer-events: none;
}

.wp-invoice-spinner {
    display: none;
}

@keyframes wp-invoice-spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Success/Error Messages */
.wp-invoice-message {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.wp-invoice-message-success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.wp-invoice-message-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

/* Preview Styles */
.wp-invoice-preview-container {
    max-width: 8.5in;
    min-height: 11in;
    margin: 0 auto;
    padding: 0.5in;
    background: white;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 10pt;
    line-height: 1.4;
    color: #000;
}

.wp-invoice-preview-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 2rem;
    gap: 2rem;
}

.wp-invoice-preview-company {
    display: flex;
    gap: 1rem;
}

.wp-invoice-preview-logo {
    flex-shrink: 0;
}

.wp-invoice-preview-logo img {
    max-width: 120px;
    max-height: 80px;
    object-fit: contain;
}



.wp-invoice-preview-company-name {
    font-size: 12pt;
    font-weight: bold;
    margin: 0 0 0.5rem 0;
}

.wp-invoice-preview-company-address {
    font-size: 10pt;
    line-height: 1.4;
    white-space: pre-wrap;
}

.wp-invoice-preview-title {
    text-align: right;
}

.wp-invoice-preview-invoice-title {
    font-size: 28pt;
    font-weight: bold;
    color: #4a5568;
    margin: 0 0 0.5rem 0;
}

.wp-invoice-preview-invoice-number {
    font-size: 12pt;
}

.wp-invoice-preview-details {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
}

.wp-invoice-preview-section-title {
    font-size: 10pt;
    font-weight: bold;
    color: #4a5568;
    margin-bottom: 0.5rem;
}

.wp-invoice-preview-client-info {
    font-size: 10pt;
    line-height: 1.4;
    white-space: pre-wrap;
}

.wp-invoice-preview-detail-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.wp-invoice-preview-detail-label {
    font-size: 10pt;
    font-weight: bold;
    color: #4a5568;
}

.wp-invoice-preview-detail-value {
    font-size: 10pt;
}

.wp-invoice-preview-balance-due-box {
    background: #f7fafc;
    padding: 0.5rem;
    border-radius: 4px;
    margin-top: 1rem;
}

.wp-invoice-preview-items-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 2rem;
}

.wp-invoice-preview-items-table th {
    background: #2d3748;
    color: white;
    padding: 0.75rem;
    text-align: left;
    font-size: 10pt;
    font-weight: bold;
    border: 1px solid #4a5568;
}

.wp-invoice-preview-items-table td {
    padding: 0.75rem;
    border: 1px solid #e2e8f0;
    font-size: 10pt;
}

.wp-invoice-preview-items-table tbody tr:nth-child(even) {
    background: #f7fafc;
}

.wp-invoice-preview-bottom {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

.wp-invoice-preview-notes-section,
.wp-invoice-preview-terms-section {
    margin-bottom: 1.5rem;
}

.wp-invoice-preview-section-content {
    font-size: 10pt;
    line-height: 1.4;
    white-space: pre-wrap;
}

.wp-invoice-preview-totals {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.wp-invoice-preview-total-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid #e2e8f0;
}

.wp-invoice-preview-total-main {
    font-size: 12pt;
    font-weight: bold;
    border-bottom: 2px solid #2d3748;
    padding: 0.75rem 0;
}

.wp-invoice-preview-balance-due {
    color: #2563eb;
    font-weight: bold;
    border-bottom: none;
}

.wp-invoice-preview-discount {
    color: #dc2626;
}

/* Custom Color Picker Styles */
.wp-invoice-custom-color .custom-color-circle {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wp-invoice-custom-color .custom-color-plus {
    color: white;
    font-size: 16px;
    font-weight: bold;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.wp-invoice-custom-color:hover .custom-color-plus {
    transform: scale(1.1);
}

/* Simple Color Picker Styles */
.wp-invoice-simple-color-picker {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 1000;
    margin-top: 5px;
}

.wp-invoice-color-picker-content {
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 200px;
}

.wp-invoice-color-input {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    padding: 0;
}

.wp-invoice-color-input::-webkit-color-swatch-wrapper {
    padding: 0;
    border: none;
    border-radius: 6px;
}

.wp-invoice-color-input::-webkit-color-swatch {
    border: none;
    border-radius: 6px;
}

.wp-invoice-hex-input {
    flex: 1;
    padding: 8px 10px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 14px;
    font-family: monospace;
    text-transform: uppercase;
}

.wp-invoice-hex-input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 1px #2563eb;
}

.wp-invoice-color-apply-btn {
    background: #2563eb;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.wp-invoice-color-apply-btn:hover {
    background: #1d4ed8;
}

.wp-invoice-color-apply-btn:active {
    background: #1e40af;
}

/* Position the color picker relative to the custom color option */
.wp-invoice-custom-color {
    position: relative;
}

/* Hidden utility class */
.hidden {
    display: none !important;
}

/* Custom Color Picker */
.wp-invoice-custom-color {
    position: relative;
}

.wp-invoice-direct-color-input {
    opacity: 0;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
    border: none;
    z-index: 5;
    background: transparent;
}

/* Custom Added Colors */
.wp-invoice-custom-added-color {
    position: relative;
}

.wp-invoice-custom-added-color .color-circle {
    position: relative;
}

.custom-color-delete {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ef4444;
    color: white;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 10;
}

.wp-invoice-custom-added-color:hover .custom-color-delete {
    opacity: 1;
}

.custom-color-delete:hover {
    background: #dc2626;
    transform: scale(1.1);
}

.wp-invoice-color-input::-webkit-color-swatch {
    border: none;
    border-radius: 8px;
}

.wp-invoice-color-preview {
    display: flex;
    align-items: center;
    justify-content: center;
}

.wp-invoice-color-preview-circle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 3px solid white;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    transition: all 0.2s ease;
}

.wp-invoice-hex-input-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.wp-invoice-hex-input-container label {
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
}

.wp-invoice-hex-input {
    padding: 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.875rem;
    font-family: 'Courier New', monospace;
    text-transform: uppercase;
    outline: none;
    transition: border-color 0.2s ease;
}

.wp-invoice-hex-input:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.wp-invoice-hex-input.invalid {
    border-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.wp-invoice-eyedropper-container {
    display: flex;
    justify-content: center;
}

.wp-invoice-eyedropper-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    color: #374151;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.wp-invoice-eyedropper-btn:hover {
    background: #e5e7eb;
    border-color: #9ca3af;
}

.wp-invoice-eyedropper-btn:active {
    background: #2563eb;
    border-color: #2563eb;
    color: white;
}

.wp-invoice-eyedropper-btn.active {
    background: #2563eb;
    border-color: #2563eb;
    color: white;
    cursor: crosshair;
}

/* Button Styles */
.wp-invoice-btn-secondary {
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    color: #374151;
}

.wp-invoice-btn-secondary:hover {
    background: #e5e7eb;
    border-color: #9ca3af;
    color: #374151;
}

.wp-invoice-btn-primary {
    background: #2563eb;
    border: 1px solid #2563eb;
    color: white;
}

.wp-invoice-btn-primary:hover {
    background: #1d4ed8;
    border-color: #1d4ed8;
}

/* Mobile Responsive */
@media (max-width: 640px) {
    .wp-invoice-modal-content {
        width: 95%;
        margin: 1rem;
    }
    
    .wp-invoice-modal-header,
    .wp-invoice-modal-body,
    .wp-invoice-modal-footer {
        padding: 1rem;
    }
    
    .wp-invoice-color-picker-main {
        flex-direction: column;
        align-items: center;
    }
    
    .wp-invoice-color-input {
        width: 100px;
        height: 100px;
    }
}

/* History Page Styles */
.wp-invoice-history-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.wp-invoice-history-header {
    margin-bottom: 2rem;
}

.wp-invoice-history-title {
    font-size: 2rem;
    font-weight: 600;
    color: #111827;
    margin: 0 0 0.5rem 0;
}

.wp-invoice-history-description {
    color: #6b7280;
    font-size: 1rem;
    margin: 0;
    line-height: 1.5;
}

.wp-invoice-history-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    gap: 1rem;
}

.wp-invoice-search-container {
    position: relative;
    max-width: 300px;
    min-width: 200px;
    margin: 0;
}

.wp-invoice-search-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
    font-size: 0.875rem;
    z-index: 1;
    pointer-events: none;
}

.wp-invoice-search-input {
    width: 100%;
    padding: 0.75rem 2.75rem 0.75rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.875rem;
    background: #ffffff;
    transition: border-color 0.2s ease;
    margin: 0 !important;
    box-sizing: border-box;
}

.wp-invoice-search-input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.wp-invoice-actions-left {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.wp-invoice-actions-right {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.wp-invoice-history-table-container {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 2rem;
}

.wp-invoice-history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.wp-invoice-history-table thead {
    background: #f9fafb;
}

.wp-invoice-history-table th {
    padding: 1rem 0.75rem;
    text-align: left;
    font-weight: 600;
    color: #6b7280;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid #e5e7eb;
}

.wp-invoice-history-table td {
    padding: 1rem 0.75rem;
    border-bottom: 1px solid #f3f4f6;
    vertical-align: middle;
}

.wp-invoice-history-row:hover {
    background: #f9fafb;
}

.wp-invoice-col-action {
    width: 80px;
}

.wp-invoice-col-customer {
    width: 180px;
    font-weight: 500;
    color: #111827;
}

.wp-invoice-col-type {
    width: 100px;
}

.wp-invoice-col-reference {
    width: 130px;
}

.wp-invoice-col-date,
.wp-invoice-col-due-date {
    width: 120px;
    color: #6b7280;
}

.wp-invoice-col-total {
    width: 120px;
    font-weight: 600;
    color: #111827;
}

.wp-invoice-col-actions {
    width: 60px;
    text-align: center;
}

.wp-invoice-view-btn {
    display: inline-block;
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    color: #374151;
    padding: 0.375rem 0.75rem;
    border-radius: 4px;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    text-align: center;
    min-width: 60px;
}

.wp-invoice-view-btn:hover {
    background: #e5e7eb;
    border-color: #9ca3af;
    color: #374151;
    text-decoration: none;
}

.wp-invoice-view-btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.wp-invoice-reference-badge {
    display: inline-block;
    background: #fef3c7;
    color: #92400e;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.wp-invoice-reference-number {
    display: block;
    font-weight: 500;
    color: #111827;
}

.wp-invoice-type-badge {
    display: inline-block;
    background: #dbeafe;
    color: #1e40af;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: capitalize;
}

.wp-invoice-delete-btn {
    background: none;
    border: none;
    color: #ef4444;
    padding: 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wp-invoice-delete-btn:hover {
    background: #fef2f2;
    color: #dc2626;
}

.wp-invoice-no-history {
    text-align: center;
    padding: 4rem 2rem;
    color: #6b7280;
}

.wp-invoice-no-history-content {
    max-width: 400px;
    margin: 0 auto;
}

.wp-invoice-no-history .wp-invoice-icon {
    font-size: 3rem;
    color: #d1d5db;
    margin-bottom: 1rem;
}

.wp-invoice-no-history h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: #111827;
    margin: 0 0 0.5rem 0;
}

.wp-invoice-no-history p {
    margin: 0 0 1.5rem 0;
    line-height: 1.5;
}

.wp-invoice-history-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    background: #fef3c7;
    border-radius: 8px;
    gap: 1rem;
}

.wp-invoice-history-warning {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    flex: 1;
    color: #92400e;
    font-size: 0.875rem;
    line-height: 1.5;
}

.wp-invoice-history-warning .wp-invoice-icon {
    color: #f59e0b;
    font-size: 1.25rem;
    margin-top: 0.125rem;
    flex-shrink: 0;
}

.wp-invoice-btn-danger {
    background: #ef4444;
    border: 1px solid #ef4444;
    color: white;
}

.wp-invoice-btn-danger:hover {
    background: #dc2626;
    border-color: #dc2626;
}

/* Options Menu Styles */
.wp-invoice-options-menu {
    position: relative;
    display: inline-block;
}

.wp-invoice-options-btn {
    background: #f9fafb;
    border: 1px solid #d1d5db;
    color: #6b7280;
    padding: 0.5rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
}

.wp-invoice-options-btn:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
    color: #374151;
}

.wp-invoice-options-btn:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.wp-invoice-options-dropdown {
    position: absolute;
    right: 0;
    bottom: 100%;
    margin-bottom: 0.5rem;
    background: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    z-index: 50;
    min-width: 150px;
}

.wp-invoice-option-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.75rem 1rem;
    border: none;
    background: none;
    text-align: left;
    font-size: 0.875rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
    border-radius: 6px;
}

.wp-invoice-option-item:hover {
    background: #f3f4f6;
}

.wp-invoice-option-item.wp-invoice-btn-danger {
    color: #ef4444;
}

.wp-invoice-option-item.wp-invoice-btn-danger:hover {
    background: #fef2f2;
    color: #dc2626;
}

/* View All Link Styles */
.wp-invoice-view-all-container {
    margin-top: 1rem;
    text-align: center;
    border-top: 1px solid #e5e7eb;
    padding-top: 1rem;
}

.wp-invoice-view-all-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: #2563eb;
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.wp-invoice-view-all-link:hover {
    background: #eff6ff;
    color: #1d4ed8;
    text-decoration: none;
}

.wp-invoice-view-all-link .wp-invoice-icon {
    font-size: 1rem;
}

/* Export button specific hover fix */
#export-history-btn:hover {
    background: #e5e7eb;
    border-color: #9ca3af;
    color: #374151 !important;
}

/* Mobile Responsive for History Page */
@media (max-width: 768px) {
    .wp-invoice-history-container {
        padding: 1rem;
        margin: 0.5rem;
        border-radius: 6px;
    }
    
    .wp-invoice-history-title {
        font-size: 1.75rem;
        text-align: center;
    }
    
    .wp-invoice-history-description {
        text-align: center;
        font-size: 0.9rem;
    }
    
    .wp-invoice-history-actions {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }
    
    .wp-invoice-actions-left {
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        gap: 0.5rem;
    }
    
    .wp-invoice-actions-left .wp-invoice-btn {
        flex: 1;
        min-width: 0;
        max-width: none;
        padding: 0.75rem 0.5rem;
        font-size: 0.85rem;
        text-align: center;
    }
    
    .wp-invoice-options-menu {
        flex-shrink: 0;
    }
    
    .wp-invoice-search-container {
        max-width: none !important;
        width: 100% !important;
        position: relative;
        margin: 0 !important;
    }
    
    .wp-invoice-search-input {
        width: 100% !important;
        max-width: none !important;
        padding: 0.75rem 2.75rem 0.75rem 0.75rem !important;
        box-sizing: border-box !important;
        margin: 0 !important;
    }
    
    .wp-invoice-search-icon {
        position: absolute;
        right: 0.75rem;
        top: 50%;
        transform: translateY(-50%);
        font-size: 0.875rem;
        color: #9ca3af;
        z-index: 1;
        pointer-events: none;
    }
    
    .wp-invoice-history-table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: 6px;
    }
    
    .wp-invoice-history-table {
        min-width: 700px;
    }
    
    .wp-invoice-history-table th,
    .wp-invoice-history-table td {
        padding: 0.75rem 0.5rem;
        font-size: 0.8rem;
    }
    
    .wp-invoice-history-footer {
        flex-direction: column;
        text-align: center;
        gap: 1.5rem;
        padding: 1rem;
    }
    
    .wp-invoice-history-warning {
        text-align: left;
        font-size: 0.8rem;
    }
}

@media (max-width: 480px) {
    .wp-invoice-history-container {
        padding: 0.75rem;
        margin: 0.25rem;
    }
    
    .wp-invoice-history-title {
        font-size: 1.5rem;
    }
    
    .wp-invoice-history-description {
        font-size: 0.85rem;
    }
    
    .wp-invoice-actions-left {
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        gap: 0.375rem;
        width: 100%;
    }
    
    .wp-invoice-actions-left .wp-invoice-btn {
        flex: 1;
        min-width: 0;
        max-width: none;
        padding: 0.75rem 0.375rem;
        font-size: 0.8rem;
        text-align: center;
    }
    
    .wp-invoice-options-menu {
        flex-shrink: 0;
    }
    
    .wp-invoice-search-container {
        width: 100% !important;
        max-width: none !important;
        position: relative;
        margin: 0 !important;
    }
    
    .wp-invoice-search-input {
        width: 100% !important;
        max-width: none !important;
        padding: 0.75rem 2.5rem 0.75rem 0.75rem !important;
        font-size: 0.875rem;
        box-sizing: border-box !important;
        margin: 0 !important;
    }
    
    .wp-invoice-search-icon {
        position: absolute;
        right: 0.75rem;
        top: 50%;
        transform: translateY(-50%);
        font-size: 0.875rem;
        color: #9ca3af;
        z-index: 1;
        pointer-events: none;
    }
    
    .wp-invoice-history-table {
        min-width: 600px;
    }
    
    .wp-invoice-history-table th,
    .wp-invoice-history-table td {
        padding: 0.5rem 0.375rem;
        font-size: 0.75rem;
    }
    
    .wp-invoice-col-customer {
        width: 140px;
    }
    
    .wp-invoice-col-type {
        width: 80px;
    }
    
    .wp-invoice-col-reference {
        width: 100px;
    }
    
    .wp-invoice-col-date,
    .wp-invoice-col-due-date {
        width: 100px;
    }
    
    .wp-invoice-col-total {
        width: 100px;
    }
    
    .wp-invoice-no-history {
        padding: 2rem 1rem;
    }
    
    .wp-invoice-no-history h3 {
        font-size: 1.1rem;
    }
    
    .wp-invoice-no-history p {
        font-size: 0.9rem;
    }
}