/* modals.css - Modal Styles */

/* Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-base), visibility var(--transition-base);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Modal Container */
.modal {
    background-color: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    transform: scale(0.95);
    transition: transform var(--transition-base);
}

.modal-overlay.active .modal {
    transform: scale(1);
}

/* Modal Sizes */
.modal-sm { width: 400px; }
.modal-md { width: 600px; }
.modal-lg { width: 800px; }
.modal-xl { width: 1000px; }

/* Modal Header */
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid var(--border);
}

.modal-title {
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--text);
}

.modal-close {
    background: none;
    border: none;
    padding: var(--space-xs);
    cursor: pointer;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: background-color var(--transition-fast), color var(--transition-fast);
}

.modal-close:hover {
    background-color: var(--bg-hover);
    color: var(--text);
}

.modal-close svg {
    width: 20px;
    height: 20px;
}

/* Modal Body */
.modal-body {
    padding: var(--space-lg);
    overflow-y: auto;
    flex: 1;
}

/* Modal Footer */
.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    border-top: 1px solid var(--border);
    background-color: var(--bg);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* Confirm Modal */
.modal-confirm .modal-body {
    text-align: center;
    padding: var(--space-xl);
}

.modal-confirm-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto var(--space-md);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-confirm-icon.warning {
    background-color: #fffff0;
    color: var(--warning);
}

.modal-confirm-icon.danger {
    background-color: #fff5f5;
    color: var(--danger);
}

.modal-confirm-icon svg {
    width: 32px;
    height: 32px;
}

.modal-confirm-title {
    font-size: var(--text-xl);
    font-weight: 600;
    margin-bottom: var(--space-sm);
}

.modal-confirm-message {
    color: var(--text-muted);
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: var(--space-lg);
    right: var(--space-lg);
    z-index: 1100;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: var(--space-sm);
    padding: var(--space-md);
    background-color: var(--bg-card);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    min-width: 300px;
    max-width: 450px;
    animation: slideIn var(--transition-base) ease-out;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast.removing {
    animation: slideOut var(--transition-base) ease-in forwards;
}

@keyframes slideOut {
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

.toast-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
}

.toast-success .toast-icon { color: var(--success); }
.toast-error .toast-icon { color: var(--danger); }
.toast-warning .toast-icon { color: var(--warning); }
.toast-info .toast-icon { color: var(--primary); }

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: 500;
    margin-bottom: var(--space-xs);
}

.toast-message {
    font-size: var(--text-sm);
    color: var(--text-muted);
}

.toast-close {
    flex-shrink: 0;
    background: none;
    border: none;
    padding: var(--space-xs);
    cursor: pointer;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
}

.toast-close:hover {
    background-color: var(--bg-hover);
    color: var(--text);
}

/* Dropdown Menu */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    min-width: 180px;
    z-index: 200;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all var(--transition-fast);
}

.dropdown.active .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    color: var(--text);
    text-decoration: none;
    font-size: var(--text-sm);
    cursor: pointer;
    transition: background-color var(--transition-fast);
}

.dropdown-item:hover {
    background-color: var(--bg-hover);
}

.dropdown-item.danger {
    color: var(--danger);
}

.dropdown-item svg {
    width: 16px;
    height: 16px;
}

.dropdown-divider {
    height: 1px;
    background-color: var(--border);
    margin: var(--space-xs) 0;
}

/* ============ POLISHED MODAL HEADER ============ */
.modal-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
}

.modal-title {
    color: #fff;
}

.modal-close {
    background: rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.7);
    border-radius: var(--radius-sm);
    width: 32px;
    height: 32px;
}

.modal-close:hover {
    background: rgba(255,255,255,0.2);
    color: #fff;
}

/* ============ POLISHED FORM LABELS ============ */
.modal-body .form-label {
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.modal-body .form-label.required::after {
    color: var(--accent);
}

/* ============ POLISHED BUTTONS ============ */
.modal .btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    border-color: var(--primary);
    box-shadow: 0 2px 4px rgba(26, 54, 93, 0.25);
}

.modal .btn-primary:hover:not(:disabled) {
    box-shadow: 0 4px 8px rgba(26, 54, 93, 0.35);
    transform: translateY(-1px);
}

.modal .btn-primary:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(26, 54, 93, 0.25);
}

/* ============ LINE ITEMS TABLE ============ */
.line-items-section {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.line-items-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-sm);
}

.line-items-table thead tr {
    background: linear-gradient(180deg, #edf2f7 0%, #e2e8f0 100%);
}

.line-items-table th {
    padding: 10px 6px;
    font-weight: 600;
    text-align: left;
    color: var(--text-light);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    border-bottom: 1px solid var(--border-dark);
}

.line-items-table th:first-child {
    padding-left: 12px;
}

.line-items-table th.col-right {
    text-align: right;
}

.line-items-table tbody tr {
    background: var(--bg-card);
    transition: background var(--transition-fast);
}

.line-items-table tbody tr:hover {
    background: #fafbfd;
}

.line-items-table tbody tr:not(:last-child) {
    border-bottom: 1px solid #f1f5f9;
}

.line-items-table td {
    padding: 5px 4px;
}

.line-items-table td:first-child {
    padding-left: 8px;
}

/* Line item inputs - borderless until interaction */
.line-items-table input,
.line-items-table select {
    width: 100%;
    padding: 8px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
    font-family: inherit;
    color: var(--text);
    background: transparent;
    transition: all var(--transition-fast);
}

.line-items-table input:hover,
.line-items-table select:hover {
    border-color: var(--border);
    background: var(--bg-card);
}

.line-items-table input:focus,
.line-items-table select:focus {
    outline: none;
    border-color: var(--primary-light);
    background: var(--bg-card);
    box-shadow: 0 0 0 2px rgba(26, 54, 93, 0.08);
}

.line-items-table input::placeholder {
    color: var(--text-muted);
}

.line-items-table input.line-right {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.line-items-table input.line-amount {
    font-weight: 500;
    color: var(--primary);
}

.line-items-table select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' fill='%23a0aec0' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 6px center;
    padding-right: 22px;
}

/* Delete button - ghosted until row hover */
.line-items-table .line-delete {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 16px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    opacity: 0.3;
    line-height: 1;
}

.line-items-table tbody tr:hover .line-delete {
    opacity: 1;
}

.line-items-table .line-delete:hover {
    color: var(--danger);
    background: rgba(197, 48, 48, 0.08);
}

/* Add Line button - full width at table bottom */
.line-items-add {
    display: block;
    width: 100%;
    padding: 10px;
    background: none;
    border: none;
    border-top: 1px solid var(--border);
    font-size: var(--text-sm);
    font-family: inherit;
    color: var(--primary-light);
    cursor: pointer;
    font-weight: 500;
    transition: all var(--transition-fast);
}

.line-items-add:hover {
    background: rgba(26, 54, 93, 0.04);
    color: var(--primary);
}

/* Total bar */
.invoice-total-bar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 16px;
    padding: 16px 0 4px;
}

.invoice-total-label {
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.invoice-total-amount {
    font-size: 22px;
    font-weight: 700;
    color: var(--primary);
    font-variant-numeric: tabular-nums;
}

/* Hide number input spinners */
.line-items-table input[type="number"]::-webkit-inner-spin-button,
.line-items-table input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.line-items-table input[type="number"] {
    -moz-appearance: textfield;
}

/* Responsive */
@media (max-width: 768px) {
    .modal {
        max-width: 100vw;
        max-height: 100vh;
        border-radius: 0;
        width: 100% !important;
        height: 100%;
    }
    
    .toast-container {
        left: var(--space-md);
        right: var(--space-md);
        bottom: var(--space-md);
    }
    
    .toast {
        min-width: auto;
        max-width: none;
    }
}
