/**
 * UI Components - Light theme
 */

/* Card */
.card {
    background: var(--bg-card);
    border: 1px solid #e5e7eb;
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    box-shadow: none;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.card:hover {
    border-color: #e5e7eb;
    box-shadow: none;
    transform: none;
}

.card-header {
    margin-bottom: var(--spacing-md);
    padding-bottom: var(--spacing-md);
    border-bottom: 1px solid #e5e7eb;
}

.card-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0;
}

.card-body {
    padding: var(--spacing-md) 0;
}

/* Button */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    padding: 0.625rem 1.25rem;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.15;
    letter-spacing: normal;
    border-radius: var(--radius-md);
    border: 1px solid #d1d5db;
    background: var(--bg-card);
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-base);
    text-decoration: none;
    white-space: nowrap;
    vertical-align: middle;
    box-sizing: border-box;
}

.btn:hover:not(:disabled) {
    background: #f9fafb;
    border-color: #9ca3af;
}

.btn:active:not(:disabled) {
    background: #f3f4f6;
    border-color: #6b7280;
}

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

.btn-primary {
    background: var(--accent-blue);
    color: white;
    border: 1px solid var(--accent-blue);
}

.btn-primary:hover:not(:disabled) {
    background: #0052a3;
    border-color: #0052a3;
    transform: none;
    box-shadow: none;
}

.btn-primary:active:not(:disabled) {
    background: #003d7a;
    border-color: #003d7a;
}

.btn-secondary {
    background: var(--bg-card);
    border: 1px solid #d1d5db;
    color: var(--text-primary);
}

.btn-secondary:hover:not(:disabled) {
    background: #f9fafb;
    border-color: #9ca3af;
    box-shadow: none;
}

.btn-secondary:active:not(:disabled) {
    background: #f3f4f6;
    border-color: #6b7280;
}

/* Add/Create Button */
.btn-add,
.btn-create {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    background: #6b7280;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: none;
    text-decoration: none;
    white-space: nowrap;
}

.btn-add:hover,
.btn-create:hover {
    background: #4b5563;
    transform: none;
    box-shadow: none;
    color: white;
    text-decoration: none;
}

.btn-add:active,
.btn-create:active {
    background: #374151;
    transform: none;
    box-shadow: none;
}

.btn-add:focus,
.btn-create:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(107, 114, 128, 0.3);
}

.btn-add svg,
.btn-create svg {
    transition: transform 0.2s ease;
    width: 14px;
    height: 14px;
}

.btn-add:hover svg,
.btn-create:hover svg {
    transform: none;
}

.btn-add.btn-sm,
.btn-create.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.8125rem;
    height: 2rem;
}

.btn-add.btn-sm svg,
.btn-create.btn-sm svg {
    width: 14px;
    height: 14px;
}

.btn-success {
    background: #10b981;
    border: 1px solid #10b981;
    color: white;
}

.btn-success:hover:not(:disabled) {
    background: #059669;
    border-color: #059669;
}

.btn-danger {
    background: #ef4444;
    border: 1px solid #ef4444;
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: #dc2626;
    border-color: #dc2626;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.8125rem;
}

.btn-sm.btn-icon {
    padding: 0.5rem;
    min-width: 32px;
    width: 32px;
    height: 32px;
}

.btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
}

.btn-icon {
    padding: 0.625rem;
    aspect-ratio: 1;
    min-width: 40px;
}

.btn-icon svg {
    display: block;
}

/* Sync and Export Buttons */
.btn-sync {
    background: rgba(0, 102, 204, 0.1);
    color: #0066cc;
    border: 1px solid rgba(0, 102, 204, 0.2);
}

.btn-sync:hover:not(:disabled) {
    background: rgba(0, 102, 204, 0.15);
    border-color: rgba(0, 102, 204, 0.3);
    color: #0052a3;
    box-shadow: 0 2px 8px rgba(0, 102, 204, 0.15);
}

.btn-sync:active:not(:disabled) {
    background: rgba(0, 102, 204, 0.2);
}

.btn-export {
    background: rgba(107, 114, 128, 0.1);
    color: #6b7280;
    border: 1px solid rgba(107, 114, 128, 0.2);
}

.btn-export:hover:not(:disabled) {
    background: rgba(107, 114, 128, 0.15);
    border-color: rgba(107, 114, 128, 0.3);
    color: #4b5563;
    box-shadow: 0 2px 8px rgba(107, 114, 128, 0.1);
}

.btn-export:active:not(:disabled) {
    background: rgba(107, 114, 128, 0.2);
}

.btn-send {
    background: rgba(34, 197, 94, 0.1);
    color: #22c55e;
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.btn-send:hover:not(:disabled) {
    background: rgba(34, 197, 94, 0.15);
    border-color: rgba(34, 197, 94, 0.3);
    color: #16a34a;
    box-shadow: 0 2px 8px rgba(34, 197, 94, 0.15);
}

.btn-send:active:not(:disabled) {
    background: rgba(34, 197, 94, 0.2);
}

/* Input */
.input,
.textarea,
.select {
    width: 100%;
    padding: 0.625rem 0.875rem;
    background: var(--bg-card);
    border: 1px solid #d1d5db;
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.875rem;
    transition: all var(--transition-base);
}

.select {
    padding-right: 2rem;
    cursor: pointer;
}

.input:hover:not(:focus),
.textarea:hover:not(:focus),
.select:hover:not(:focus) {
    border-color: #9ca3af;
}

.input:focus,
.textarea:focus,
.select:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
    background: var(--bg-card);
}

.input::placeholder,
.textarea::placeholder {
    color: var(--text-muted);
}

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

.input-group {
    margin-bottom: var(--spacing-md);
}

.label {
    display: block;
    margin-bottom: var(--spacing-sm);
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
}

.input-error {
    border-color: #ef4444;
}

.error-message {
    display: block;
    margin-top: var(--spacing-xs);
    font-size: 0.8125rem;
    color: #dc2626;
}

/* Table */
.table-wrapper {
    overflow-x: auto;
    border-radius: 0.5rem;
    border: 1px solid #e5e7eb;
    box-shadow: none;
    background: var(--bg-card);
}

.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--bg-card);
}

.table thead {
    background: #f9fafb;
    border-bottom: 2px solid #e5e7eb;
}

.table th,
.table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
}

.table th {
    font-weight: 600;
    font-size: 0.75rem;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.table td {
    color: var(--text-primary);
    font-size: 0.875rem;
}

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

.table tbody tr:hover {
    background: var(--bg-card);
}

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

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

/* Editable name */
.editable-invoice-name {
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: all var(--transition-fast);
    display: inline-block;
    min-width: 100px;
}

.editable-invoice-name:hover {
    background: var(--bg-primary);
    color: var(--accent-blue);
}

.editable-invoice-name:active {
    background: var(--bg-secondary);
}

.inline-edit-input {
    outline: none !important;
    border: 1px solid var(--accent-blue) !important;
    box-shadow: 0 0 0 2px rgba(0, 102, 204, 0.1) !important;
}

/* Badge */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.625rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    white-space: nowrap;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.badge > * {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    flex: 1 1 auto;
}

td .badge:only-child,
th .badge:only-child {
    display: inline-flex;
    width: auto;
}

div[style*="max-width"] .badge:only-child {
    display: flex;
    width: 100%;
}

.badge-primary {
    background: rgba(0, 102, 204, 0.1);
    color: #0066cc;
}

.badge-success {
    background: rgba(16, 185, 129, 0.1);
    color: #059669;
}

.badge-danger {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
}

.badge-warning {
    background: rgba(245, 158, 11, 0.1);
    color: #d97706;
}

/* Alert */
.alert {
    padding: var(--spacing-md);
    border-radius: 0.375rem;
    margin-bottom: var(--spacing-md);
    border-left: 4px solid;
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    border-left-color: #10b981;
    color: #047857;
}

.alert-error {
    background: rgba(239, 68, 68, 0.1);
    border-left-color: #ef4444;
    color: #b91c1c;
}

.alert-warning {
    background: rgba(245, 158, 11, 0.1);
    border-left-color: #f59e0b;
    color: #b45309;
}

.alert-info {
    background: rgba(0, 102, 204, 0.1);
    border-left-color: #0066cc;
    color: #0052a3;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn var(--transition-base);
}

.modal-overlay.hidden,
#uploadModal.hidden {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
}

.modal {
    background: var(--bg-card);
    border: 1px solid #e5e7eb;
    border-radius: var(--radius-lg);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideIn var(--transition-base);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.modal-header {
    padding: var(--spacing-lg);
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header .modal-title {
    flex: 0 1 auto;
}

.modal-header button:last-child {
    flex: 0 0 auto;
    margin-left: auto;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
}

.modal-body {
    padding: var(--spacing-lg);
}

.modal-footer {
    padding: var(--spacing-lg);
    border-top: 1px solid #e5e7eb;
    display: flex;
    gap: var(--spacing-sm);
    justify-content: flex-end;
}

/* Loading spinner */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Progress bar */
.progress {
    height: 8px;
    background: var(--bg-primary);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--accent-blue);
    transition: width var(--transition-slow);
}

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

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.25rem;
    background: var(--bg-card);
    border: 1px solid #e5e7eb;
    border-radius: var(--radius-md);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    min-width: 200px;
    z-index: 100;
    padding: 0.25rem 0;
    animation: slideIn var(--transition-base);
}

.dropdown-item {
    display: block;
    padding: 0.5rem 1rem;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.875rem;
    transition: background var(--transition-fast);
}

.dropdown-item:hover {
    background: #f9fafb;
}

.dropdown-item:active {
    background: #f3f4f6;
}

.dropdown-divider {
    height: 1px;
    background: #e5e7eb;
    margin: 0.25rem 0;
}

/* Tooltip */
.tooltip {
    position: relative;
}

.tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.8125rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-base);
    margin-bottom: var(--spacing-sm);
}

.tooltip:hover::after {
    opacity: 1;
}

/* Form aliases used across views */
.form-input,
.form-textarea {
    width: 100%;
    padding: 0.625rem 0.875rem;
    background: var(--bg-card);
    border: 1px solid #d1d5db;
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.875rem;
    transition: all var(--transition-base);
}

.form-input:hover:not(:focus),
.form-textarea:hover:not(:focus) {
    border-color: #9ca3af;
}

.form-input:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
    background: var(--bg-card);
}

.form-input::placeholder,
.form-textarea::placeholder {
    color: var(--text-muted);
}

select.form-input {
    padding-right: 2rem;
    cursor: pointer;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.6rem center;
}

.form-label {
    display: block;
    margin-bottom: var(--spacing-sm);
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
}

.form-group {
    margin-bottom: var(--spacing-md);
}
