/* Form and Modal Styles */

/* Password Input Wrapper */
.password-input-wrapper {
    position: relative;
}

.password-input-wrapper input {
    padding-right: 2.5rem !important;
}

.password-toggle {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-500);
    transition: color 0.2s;
}

.password-toggle:hover {
    color: var(--gray-700);
}

.password-toggle svg {
    width: 1.25rem;
    height: 1.25rem;
}

/* Change Password Modal - Match Login Form Styling */
#change-password-modal .form-group {
    margin-bottom: 1.5rem;
}

#change-password-modal .form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--gray-700);
    font-weight: 500;
    font-size: 0.95rem;
}

#change-password-modal .form-group input {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--gray-300);
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.2s ease-in-out;
    background: white;
}

#change-password-modal .form-group input:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px rgba(184, 134, 11, 0.1);
}

#change-password-modal .password-input-wrapper input {
    padding-right: 2.5rem;
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;
    pointer-events: auto;
}

.modal.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    background: var(--gray-50);
    background-image: 
        radial-gradient(circle at 20px 50px, rgba(184, 134, 11, 0.02) 1px, transparent 1px),
        radial-gradient(circle at 40px 80px, rgba(184, 134, 11, 0.02) 1px, transparent 1px);
    background-size: 100px 100px;
    border-radius: var(--border-radius-lg);
    outline: 1px solid var(--primary-600);
    box-shadow: var(--shadow-lg);
    max-width: 1200px;
    width: 90vw;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    z-index: 10;
    opacity: 1;
    transition: opacity 0.3s ease-in-out;
}


/* Special styling for invoice modal to be extra wide */
.modal-content.invoice-modal {
    max-width: none;
    width: 95vw;
    max-height: 95vh;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0rem 0.5rem 2.5rem;
    border-bottom: 1px solid var(--gray-200);
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--gray-900);
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    border-radius: var(--border-radius);
    color: var(--gray-400);
    transition: color 0.2s ease-in-out;
}

.modal-close:hover {
    color: var(--gray-600);
}

.modal-close svg {
    width: 1.5rem;
    height: 1.5rem;
}

.modal-body {
    padding: 1rem;
    max-height: 60vh;
    overflow-y: auto;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem;
    border-top: 1px solid var(--gray-200);
    background-color: var(--gray-50);
}

/* Form Styles */

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 0.5rem;
}

.form-help {
    display: block;
    font-size: 0.75rem;
    color: var(--gray-500);
    margin-top: 0.25rem;
    font-style: italic;
}

.invoice-form-status-container {
    display: flex;
    align-items: center;
    min-height: 38px; /* Match input height */
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 0.2rem;
    outline: 1px solid var(--gray-300);
    border-radius: var(--border-radius);
    font-size: 0.875rem;
    line-height: 1.25rem;
    font-family: var(--font-family);
    background-color: var(--gray-50);
    transition: border-color 0.2s ease-in-out, background-color 0.2s ease-in-out;
}

/* Custom dropdown styling to match stationary theme */
.form-select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    outline: 1px solid var(--gray-300);
    padding-right: 2.5rem;
    padding-left: 0.5rem;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23B8860B' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1rem;
    cursor: pointer;
}

select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    padding: 0.75rem 2.5rem 0.75rem 0.75rem;
    outline: 1px solid var(--gray-300);
    border-radius: var(--border-radius);
    font-size: 0.875rem;
    line-height: 1.25rem;
    font-family: var(--font-family);
    background-color: var(--gray-50);
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23B8860B' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1rem;
    cursor: pointer;
    transition: border-color 0.2s ease-in-out, background-color 0.2s ease-in-out;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    /* outline: none; */
    outline: 1px solid var(--gray-300);
    background-color: white;
}

select:focus {
    outline: none;
    border-color: var(--primary-600);
    background-color: white;
}

.form-select:hover,
select:hover {
    border-color: var(--gray-400);
    background-color: white;
}

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

.form-section {
    outline: 1px solid var(--gray-200);
    border-radius: var(--border-radius);
    padding: 0.5rem;
    margin-bottom: 1.5rem;
}

.form-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.form-section-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-900);
    margin: 0;
}

/* Invoice Items */
.invoice-item {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr auto;
    gap: 0.75rem;
    align-items: end;
    padding: 0.75rem;
    outline: 1px solid var(--gray-200);
    border-radius: var(--border-radius);
    margin-bottom: 0.75rem;
    background-color: var(--gray-50);
}

.invoice-item:last-child {
    margin-bottom: 0;
}

.remove-item-btn {
    background: var(--red-600);
    color: white;
    border: none;
    padding: 0.5rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: background-color 0.2s ease-in-out;
}

.remove-item-btn:hover {
    background-color: var(--red-700);
}

.remove-item-btn svg {
    width: 1rem;
    height: 1rem;
}

.totals-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
}

.totals-row.total {
    border-top: 1px solid var(--gray-200);
    margin-top: 0.5rem;
    padding-top: 1rem;
    font-weight: 600;
    font-size: 1.125rem;
}

/* Filter Controls */
.filter-controls {
    
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
    
    margin-bottom: 1.5rem;
}

.filter-group {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.date-range-picker {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.date-range-picker .form-input {
    width: auto;
    margin: 0;
}

/* Button Variants - Stationary Theme */
.btn-secondary {
    background-color: transparent;
    color: var(--gray-600);
    outline: 1px solid var(--gray-400);
}

.btn-secondary:hover {
    background-color: var(--gray-100);
    border-color: var(--gray-500);
    color: var(--gray-700);
}

.btn-danger {
    background: linear-gradient(135deg, rgba(220, 20, 60, 0.08) 0%, rgba(220, 20, 60, 0.12) 100%);
    color: var(--red-600);
    outline: 1px solid var(--red-600);
    box-shadow: 0 1px 3px rgba(220, 20, 60, 0.1);
}

.btn-danger:hover {
    background: linear-gradient(135deg, var(--red-50) 0%, var(--red-100) 100%);
    border-color: var(--red-700);
    color: var(--red-700);
}

.btn-danger:focus,
.btn-danger:active {
    background: linear-gradient(135deg, var(--red-100) 0%, rgba(220, 20, 60, 0.2) 100%);
    border-color: var(--red-700);
    color: var(--red-700);
    outline: none;
    padding: 0.5rem 1rem;
    outline: 1px solid var(--red-700);
}

/* Filled danger button variant */
.btn-danger.btn-filled {
    background: linear-gradient(135deg, var(--red-600) 0%, var(--red-700) 100%);
    color: white;
    outline: 1px solid var(--red-700);
    box-shadow: 0 2px 4px rgba(220, 20, 60, 0.25);
}

.btn-danger.btn-filled:hover {
    background: linear-gradient(135deg, var(--red-700) 0%, var(--red-800) 100%);
    border-color: var(--red-800);
}

.btn-danger.btn-filled:focus,
.btn-danger.btn-filled:active {
    background: linear-gradient(135deg, var(--red-800) 0%, #b71c1c 100%);
    border-color: var(--red-800);
    outline: none;
    padding: 0.5rem 1rem;
    outline: 1px solid var(--red-800);
}

/* Responsive Form Styles */
@media (max-width: 768px) {
    .modal-content {
        width: 95vw;
        max-height: 95vh;
    }
    
    .modal-body {
        padding: 1rem;
    }
    
    .modal-footer {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .modal-footer .btn {
        width: 100%;
        justify-content: center;
    }
    
    .invoice-item {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
    
    .filter-group {
        flex-direction: column;
        align-items: stretch;
    }
    
    .date-range-picker {
        flex-direction: column;
        align-items: stretch;
    }
}

/* Enhanced Invoice Form Styles */
.customer-select-container {
    position: relative;
}

.customer-info {
    margin-top: 0.75rem;
    padding: 0.75rem;
    background-color: var(--gray-100);
    outline: 1px solid var(--gray-200);
    border-radius: var(--border-radius);
}

.customer-details p {
    margin: 0.25rem 0;
    font-size: 0.875rem;
}

.customer-name {
    font-weight: 600;
    color: var(--gray-900);
}

.customer-email {
    color: var(--gray-600);
}

.customer-address {
    color: var(--gray-700);
    white-space: pre-line;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.btn-small {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
    line-height: 1.25rem;
}

/* Invoice Items Table */
.items-table-container {
    margin-top: 1rem;
}

.items-table {
    width: 100%;
    border-collapse: collapse;
    border-radius: var(--border-radius);
    overflow: hidden;
    outline: 1px solid var(--gray-200);
    table-layout: fixed;
}

/* Fixed column widths to prevent layout shifts */
.items-table th:nth-child(1),
.items-table td:nth-child(1) { 
    width: 25%; 
    word-wrap: break-word;
    overflow-wrap: break-word;
} /* Description */
.items-table th:nth-child(2),
.items-table td:nth-child(2) { width: 10%; } /* Quantity */
.items-table th:nth-child(3),
.items-table td:nth-child(3) { width: 12%; } /* Unit Price */
.items-table th:nth-child(4),
.items-table td:nth-child(4) { width: 10%; } /* Currency */
.items-table th:nth-child(5),
.items-table td:nth-child(5) { width: 20%; } /* Tax Settings */
.items-table th:nth-child(6),
.items-table td:nth-child(6) { width: 13%; } /* Total */
.items-table th:nth-child(7),
.items-table td:nth-child(7) { width: 10%; } /* Actions */

.items-table th {
    background-color: var(--gray-100);
    padding: 0.25rem 0.5rem;
    text-align: left;
    font-weight: 600;
    color: var(--gray-900);
    font-size: 0.875rem;
    border-bottom: 1px solid var(--gray-200);
}

.items-table td {
    padding: 0rem 0.5rem;
    border-bottom: 1px solid var(--gray-200);
}

.items-table tbody tr:last-child td {
    border-bottom: none;
}

.items-table tbody tr:hover {
    background-color: var(--gray-50);
}

.invoice-item-row {
    background-color: white;
}

.invoice-item-row input,
.invoice-item-row select {
    width: 100%;
    outline: 1px solid var(--gray-200);
    padding: 0.2rem;
    border-radius: var(--border-radius);
    font-size: 0.85rem;
    box-sizing: border-box;
}

/* Description input specifically */
.invoice-item-row td:nth-child(1) input {
    max-width: 100%;
    word-wrap: break-word;
    overflow: hidden;
    text-overflow: ellipsis;
}

.invoice-item-row input:focus,
.invoice-item-row select:focus {
    outline: 1px solid var(--primary-600);
}

.item-total-display {
    font-weight: 500;
    color: var(--gray-900);
    text-align: right;
    min-width: 80px;
}

.tax-settings-group {
    flex-direction: row;
    gap: 0.5rem;
}

.tax-checkbox-group {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.75rem;
}

.tax-checkbox-group input[type="checkbox"] {
    width: auto;
    margin: 0;
}

.tax-rate-input {
    width: 60px !important;
}

.no-items-message {
    text-align: center;
    padding: 1rem;
    color: var(--gray-500);
    font-style: italic;
    outline: 1px solid var(--gray-200);
    border-radius: var(--border-radius);
    background-color: var(--gray-50);
}

.form-help {
    display: block;
    font-size: 0.75rem;
    color: var(--gray-500);
    margin-top: 0.25rem;
}

/* Action Buttons in Tables */
.action-buttons {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.action-btn {
    padding: 0.375rem;
    outline: 1px solid transparent;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.9) 0%, rgba(250, 250, 250, 0.95) 100%);
    cursor: pointer;
    border-radius: var(--border-radius);
    transition: all 0.2s ease-in-out;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.action-btn:hover {
    background: linear-gradient(135deg, white 0%, rgba(250, 250, 250, 1) 100%);
}

.action-btn.edit {
    color: var(--blue-600);
    border-color: var(--blue-100);
}

.action-btn.edit:hover {
    background: linear-gradient(135deg, var(--blue-50) 0%, rgba(70, 130, 180, 0.1) 100%);
    border-color: var(--blue-600);
}

.action-btn.delete {
    color: var(--red-600);
    border-color: var(--red-100);
}

.action-btn.delete:hover {
    background: linear-gradient(135deg, var(--red-50) 0%, rgba(220, 20, 60, 0.1) 100%);
    border-color: var(--red-600);
}

.action-btn.delete-btn {
    color: var(--red-600);
    border-color: var(--red-100);
}

.action-btn.delete-btn:hover {
    background: linear-gradient(135deg, var(--red-50) 0%, rgba(220, 20, 60, 0.1) 100%);
    border-color: var(--red-600);
}

.action-btn.view {
    color: var(--primary-600);
    border-color: var(--primary-100);
}

.action-btn.view:hover {
    background: linear-gradient(135deg, var(--primary-50) 0%, rgba(218, 165, 32, 0.1) 100%);
    border-color: var(--primary-600);
}

.action-btn.send {
    color: var(--green-600);
    border-color: var(--green-100);
}

.action-btn.send:hover {
    background: linear-gradient(135deg, var(--green-50) 0%, rgba(34, 139, 34, 0.1) 100%);
    border-color: var(--green-600);
}

.action-btn svg {
    width: 1rem;
    height: 1rem;
}

/* Enhanced Invoice Form Styles */
.customer-select-container {
    margin-bottom: 0;
}

.customer-info {
    margin-top: 1rem;
    padding: 1rem;
    background-color: var(--gray-100);
    outline: 1px solid var(--gray-200);
    border-radius: var(--border-radius);
}

.customer-details .customer-name {
    font-weight: 600;
    color: var(--gray-900);
    margin: 0 0 0.25rem 0;
}

.customer-details .customer-email {
    color: var(--gray-600);
    font-size: 0.875rem;
    margin: 0 0 0.25rem 0;
}

.customer-details .customer-address {
    color: var(--gray-600);
    font-size: 0.875rem;
    margin: 0;
    white-space: pre-line;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.items-table-container {
    margin-top: 1rem;
}

.items-table {
    width: 100%;
    border-collapse: collapse;
    outline: 1px solid var(--gray-200);
    border-radius: var(--border-radius);
    overflow: hidden;
}

.items-table thead {
    background-color: var(--gray-100);
}

.items-table th,
.items-table td {
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
}

.items-table th {
    font-weight: 600;
    color: var(--gray-700);
    font-size: 0.85rem;
}

.items-table tbody tr:hover {
    background-color: var(--gray-50);
}

.items-table tbody tr:last-child td {
    border-bottom: none;
}

.no-items-message {
    padding: 1rem;
    text-align: center;
    color: var(--gray-500);
    font-style: italic;
}

.form-help {
    display: block;
    font-size: 0.75rem;
    color: var(--gray-500);
    margin-top: 0.25rem;
}

.btn-small {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
}

.item-tax-settings {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.tax-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
}

.tax-checkbox input[type="checkbox"] {
    width: auto;
    margin: 0;
}

.tax-rate-input {
    width: 80px;
    padding: 0.25rem;
    font-size: 0.75rem;
}

/* Responsive adjustments for invoice form */
@media (max-width: 768px) {
    .form-row {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    .items-table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -0.5rem;
        padding: 0 0.5rem;
    }
    
    .items-table {
        min-width: 650px;
    }
    
    .no-items-message {
        min-width: 650px;
    }
    
    .modal-content {
        max-width: none;
        margin: 0.5rem;
    }
    
    .tax-settings-group {
        min-width: 120px;
    }
    
    /* Slightly reduce font size on very small screens */
    .items-table th,
    .items-table td {
        font-size: 0.8rem;
    }
    
    .invoice-item-row input,
    .invoice-item-row select {
        font-size: 0.8rem;
        padding: 0.15rem;
    }
    
    /* Keep form section headers properly spaced */
    .form-section-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 0.5rem;
    }
    
    /* Convert Add Item and Add Customer buttons to icon-only circles on mobile */
    #add-invoice-item,
    #add-new-customer-inline {
        width: 2rem;
        height: 2rem;
        padding: 0;
        border-radius: 50%;
        justify-content: center;
        font-size: 0;
        flex-shrink: 0;
    }
    
    #add-invoice-item .btn-icon,
    #add-new-customer-inline .btn-icon {
        margin: 0;
        width: 1.25rem;
        height: 1.25rem;
    }
    
    /* Keep footer buttons full width for easier tapping */
    .modal-footer .btn {
        width: 100%;
    }
}

/* Extra small screens */
@media (max-width: 480px) {
    .items-table {
        min-width: 600px;
    }
    
    .no-items-message {
        min-width: 600px;
    }
    
    .items-table th,
    .items-table td {
        font-size: 0.75rem;
        padding: 0.25rem;
    }
}