/**
 * Custom styles for iXBRL Accounts Generator
 * Extends Tailwind CSS with form-specific styling
 */

/* Currency input fields - integers only, left-aligned */
.currency-input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    text-align: left;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    background-color: #ffffff;
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    font-size: 0.875rem;
    line-height: 1.25rem;
    color: #111827;
    transition: all 200ms;
    outline: none;
}

.currency-input:hover {
    border-color: #9ca3af;
    box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
}

.currency-input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    outline: none;
}

/* Calculated/read-only fields - subtotals */
.calculated-field {
    width: 100%;
    padding: 0.5rem 0.75rem;
    text-align: right;
    background: linear-gradient(to bottom right, #eff6ff, #eef2ff);
    border: 1px solid #93c5fd;
    border-radius: 0.5rem;
    color: #1f2937;
    font-weight: 600;
    font-size: 0.875rem;
    line-height: 1.25rem;
    cursor: not-allowed;
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}

/* Calculated fields - major totals (bold) */
.calculated-field.font-bold {
    background: linear-gradient(to bottom right, #bfdbfe, #c7d2fe);
    border: 2px solid #3b82f6;
    color: #111827;
    font-weight: 700;
}

/* Input field base styles - matching Flowbite floating label style */
.input-field {
    background-color: #ffffff;
    border: 1px solid #9ca3af;
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    font-size: 0.875rem;
    line-height: 1.25rem;
    color: #111827;
    border-radius: 0.5rem;
    appearance: none;
    transition: all 200ms;
}

.input-field:hover {
    border-color: #6b7280;
    box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
}

.input-field:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    ring: 0;
}

/* Table styling improvements */
table {
    font-size: 0.875rem;
    line-height: 1.25rem;
}

table tbody tr {
    transition: background-color 150ms;
}

table tbody tr:hover {
    background-color: rgba(239, 246, 255, 0.4);
}

table td {
    border-bottom: 1px solid #f3f4f6;
    background-color: #ffffff;
    vertical-align: middle;
}

table th {
    vertical-align: middle;
}

table td.p-3 {
    padding: 0.5rem 0.75rem;
}

/* Ensure input fields in table cells don't add extra padding */
table td input {
    margin: 0;
}

table tr:last-child td {
    border-bottom: 0;
}

/* Section headers in tables */
table tr.bg-gray-50 td {
    background: linear-gradient(to right, #f3f4f6, #f9fafb);
    font-weight: 600;
    color: #1f2937;
    border-top: 2px solid #d1d5db;
    border-bottom: 2px solid #d1d5db;
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
}

/* Subtotal rows */
table tr.bg-blue-50 td {
    background: linear-gradient(to right, #eff6ff, rgba(219, 234, 254, 0.5));
    border-top: 1px solid #bfdbfe;
    border-bottom: 1px solid #bfdbfe;
}

table tr.bg-blue-100 td {
    background: linear-gradient(to right, #dbeafe, rgba(191, 219, 254, 0.5));
    border-top: 2px solid #93c5fd;
    border-bottom: 2px solid #93c5fd;
}

table tr.bg-blue-200 td {
    background: linear-gradient(to right, #bfdbfe, rgba(147, 197, 253, 0.6));
    border-top: 2px solid #60a5fa;
    border-bottom: 2px solid #60a5fa;
    font-weight: 700;
}

/* Remove number input spinners for cleaner look */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type="number"] {
    -moz-appearance: textfield;
}

/* Button styles */
.btn-primary {
    transition: all 200ms;
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}

.btn-primary:hover {
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    transition: all 200ms;
}

.btn-secondary:active {
    transform: translateY(0);
}

/* Section headers */
section h2 {
    border-bottom: 2px solid #e5e7eb;
    padding-bottom: 0.5rem;
}

/* Responsive table on mobile */
@media (max-width: 768px) {
    .overflow-x-auto {
        margin-left: -1.5rem;
        margin-right: -1.5rem;
    }

    table {
        font-size: 0.75rem;
        line-height: 1rem;
    }

    .currency-input,
    .calculated-field {
        padding: 0.25rem 0.5rem;
        font-size: 0.75rem;
        line-height: 1rem;
    }
}

/* Balance validation error styling */
.balance-error {
    border: 2px solid #ef4444;
    background-color: #fef2f2;
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* Form group animations */
.form-group {
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Loading state for HTMX requests */
.htmx-request {
    opacity: 0.75;
    pointer-events: none;
}

.htmx-request::after {
    content: "Loading...";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: #ffffff;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1);
}

/* Validation messages */
.validation-message {
    margin-top: 0.25rem;
    font-size: 0.875rem;
    line-height: 1.25rem;
}

.validation-message.error {
    color: #dc2626;
}

.validation-message.warning {
    color: #d97706;
}

.validation-message.success {
    color: #16a34a;
}

/* Directors list styling */
#directors-container {
    max-height: 300px;
    overflow-y: auto;
}

/* P&L section collapse transition */
#pl-section {
    transition: max-height 300ms ease-in-out, opacity 300ms ease-in-out, margin-top 300ms ease-in-out;
}

/* Sticky table headers for long forms */
@media (min-width: 768px) {
    .overflow-x-auto {
        max-height: 600px;
        overflow-y: auto;
    }

    table thead {
        position: sticky;
        top: 0;
        z-index: 10;
        background-color: #f3f4f6;
    }
}

/* Print styles */
@media print {
    .no-print {
        display: none;
    }

    body {
        background-color: #ffffff;
    }

    section {
        box-shadow: none;
        border: 1px solid #d1d5db;
        page-break-inside: avoid;
    }
}
