/* ================================================================
   ACCOUNTING MODULE - External CSS
   Layouts complexes, animations, print styles
   ================================================================ */

/* ========== DASHBOARD GRID LAYOUT ========== */
.acc-dashboard-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
}

.acc-dashboard-row {
    display: grid;
    gap: 20px;
}

.acc-dashboard-row.cols-4 {
    grid-template-columns: repeat(4, 1fr);
}

.acc-dashboard-row.cols-3 {
    grid-template-columns: repeat(3, 1fr);
}

.acc-dashboard-row.cols-2-1 {
    grid-template-columns: 2fr 1fr;
}

.acc-dashboard-row.cols-1-2 {
    grid-template-columns: 1fr 2fr;
}

.acc-dashboard-row.cols-1-1 {
    grid-template-columns: 1fr 1fr;
}

/* ========== DASHBOARD RECENT ITEMS ========== */
.acc-recent-list {
    background: var(--bg-primary, #fff);
    border-radius: 12px;
    border: 1px solid var(--border-color, #e0e0e0);
    overflow: hidden;
}

.acc-recent-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color, #f0f0f0);
}

.acc-recent-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary, #333);
    margin: 0;
}

.acc-recent-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border-color, #f5f5f5);
    transition: background 0.15s;
}

.acc-recent-item:last-child {
    border-bottom: none;
}

.acc-recent-item:hover {
    background: var(--bg-secondary, #f8f9fa);
}

.acc-recent-item-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.acc-recent-item-icon.invoice {
    background: rgba(9, 132, 227, 0.1);
    color: #0984e3;
}

.acc-recent-item-icon.expense {
    background: rgba(225, 112, 85, 0.1);
    color: #e17055;
}

.acc-recent-item-icon.payment {
    background: rgba(0, 184, 148, 0.1);
    color: #00b894;
}

.acc-recent-item-info {
    flex: 1;
    min-width: 0;
}

.acc-recent-item-title {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary, #333);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.acc-recent-item-sub {
    font-size: 0.75rem;
    color: var(--text-secondary, #999);
}

.acc-recent-item-amount {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary, #333);
    white-space: nowrap;
}

/* ========== CASH FLOW CHART AREA ========== */
.acc-cashflow-chart {
    position: relative;
    height: 300px;
    background: var(--bg-primary, #fff);
    border-radius: 12px;
    border: 1px solid var(--border-color, #e0e0e0);
    padding: 20px;
}

.acc-cashflow-legend {
    display: flex;
    gap: 20px;
    margin-bottom: 12px;
}

.acc-cashflow-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--text-secondary, #666);
}

.acc-cashflow-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

/* ========== SCANNER ANIMATIONS ========== */
@keyframes acc-scan-line {
    0% {
        top: 0;
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
    100% {
        top: calc(100% - 3px);
        opacity: 1;
    }
}

@keyframes acc-scan-pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.05);
        opacity: 0.8;
    }
}

@keyframes acc-scanner-glow {
    0%, 100% {
        box-shadow: 0 0 20px rgba(108, 92, 231, 0.2);
    }
    50% {
        box-shadow: 0 0 40px rgba(108, 92, 231, 0.5);
    }
}

.acc-scanner-active {
    animation: acc-scan-pulse 1.5s ease-in-out infinite;
}

.acc-scanner-line {
    position: absolute;
    left: 10%;
    width: 80%;
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--accent-primary, #6c5ce7), transparent);
    border-radius: 2px;
    animation: acc-scan-line 2s ease-in-out infinite;
    box-shadow: 0 0 10px var(--accent-primary, #6c5ce7);
}

.acc-scanner-processing {
    position: relative;
    overflow: hidden;
    border-radius: 12px;
}

.acc-scanner-processing::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(108, 92, 231, 0.1), transparent);
    animation: acc-scan-shimmer 1.5s infinite;
}

@keyframes acc-scan-shimmer {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

/* ========== DRAG AND DROP ZONE ========== */
.acc-drop-active {
    border-color: var(--accent-primary, #6c5ce7) !important;
    background: rgba(108, 92, 231, 0.05) !important;
}

.acc-drop-active::before {
    content: 'Deposez vos fichiers ici';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--accent-primary, #6c5ce7);
    z-index: 10;
}

/* ========== INVOICE LINE ITEMS ========== */
.acc-line-items {
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 16px;
}

.acc-line-items-header {
    display: grid;
    grid-template-columns: 3fr 1fr 1fr 1fr 40px;
    gap: 8px;
    padding: 10px 16px;
    background: var(--bg-secondary, #f8f9fa);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary, #666);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.acc-line-item-row {
    display: grid;
    grid-template-columns: 3fr 1fr 1fr 1fr 40px;
    gap: 8px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-color, #f0f0f0);
    align-items: center;
}

.acc-line-item-row:last-child {
    border-bottom: none;
}

.acc-line-item-row input,
.acc-line-item-row select {
    padding: 6px 10px;
    border: 1px solid var(--border-color, #ddd);
    border-radius: 6px;
    font-size: 0.85rem;
    background: var(--bg-primary, #fff);
    color: var(--text-primary, #333);
    width: 100%;
    box-sizing: border-box;
}

.acc-line-item-remove {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: rgba(231, 76, 60, 0.1);
    color: #e74c3c;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.acc-line-item-remove:hover {
    background: rgba(231, 76, 60, 0.25);
}

.acc-line-items-total {
    display: flex;
    justify-content: flex-end;
    gap: 24px;
    padding: 16px;
    background: var(--bg-secondary, #f8f9fa);
    border-top: 2px solid var(--border-color, #e0e0e0);
}

.acc-line-items-total-row {
    display: flex;
    gap: 16px;
    align-items: center;
}

.acc-line-items-total-label {
    font-size: 0.85rem;
    color: var(--text-secondary, #666);
}

.acc-line-items-total-value {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary, #333);
    min-width: 100px;
    text-align: right;
}

.acc-line-items-total-value.grand {
    font-size: 1.2rem;
    color: var(--accent-primary, #6c5ce7);
}

/* ========== FINANCIAL STATEMENTS ========== */
.acc-financial-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-primary, #fff);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border-color, #e0e0e0);
}

.acc-financial-table th {
    padding: 14px 20px;
    text-align: left;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary, #666);
    background: var(--bg-secondary, #f8f9fa);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.acc-financial-table td {
    padding: 12px 20px;
    font-size: 0.9rem;
    color: var(--text-primary, #333);
    border-bottom: 1px solid var(--border-color, #f0f0f0);
}

.acc-financial-table tr.total td {
    font-weight: 700;
    background: var(--bg-secondary, #f8f9fa);
    border-top: 2px solid var(--border-color, #e0e0e0);
}

.acc-financial-table tr.subtotal td {
    font-weight: 600;
    font-style: italic;
}

.acc-financial-table td.amount {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* ========== PRINT STYLES ========== */
@media print {
    body * {
        visibility: hidden;
    }

    .acc-print-area,
    .acc-print-area * {
        visibility: visible;
    }

    .acc-print-area {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        padding: 20mm;
        box-sizing: border-box;
    }

    .acc-print-header {
        display: flex;
        justify-content: space-between;
        margin-bottom: 40px;
    }

    .acc-print-logo {
        max-height: 60px;
    }

    .acc-print-company {
        text-align: right;
    }

    .acc-print-company-name {
        font-size: 1.2rem;
        font-weight: 700;
        margin-bottom: 4px;
    }

    .acc-print-company-info {
        font-size: 0.85rem;
        color: #666;
        line-height: 1.5;
    }

    .acc-print-title {
        font-size: 1.8rem;
        font-weight: 700;
        margin-bottom: 8px;
    }

    .acc-print-number {
        font-size: 1rem;
        color: #666;
        margin-bottom: 30px;
    }

    .acc-print-parties {
        display: flex;
        justify-content: space-between;
        margin-bottom: 30px;
    }

    .acc-print-party {
        max-width: 45%;
    }

    .acc-print-party-label {
        font-size: 0.8rem;
        font-weight: 600;
        text-transform: uppercase;
        color: #999;
        margin-bottom: 8px;
    }

    .acc-print-table {
        width: 100%;
        border-collapse: collapse;
        margin-bottom: 30px;
    }

    .acc-print-table th {
        padding: 10px 12px;
        text-align: left;
        font-size: 0.8rem;
        font-weight: 600;
        border-bottom: 2px solid #333;
    }

    .acc-print-table td {
        padding: 10px 12px;
        font-size: 0.85rem;
        border-bottom: 1px solid #e0e0e0;
    }

    .acc-print-totals {
        margin-left: auto;
        width: 280px;
    }

    .acc-print-total-row {
        display: flex;
        justify-content: space-between;
        padding: 6px 0;
        font-size: 0.9rem;
    }

    .acc-print-total-row.grand {
        font-size: 1.1rem;
        font-weight: 700;
        border-top: 2px solid #333;
        padding-top: 10px;
        margin-top: 6px;
    }

    .acc-print-footer {
        margin-top: 50px;
        font-size: 0.8rem;
        color: #666;
        line-height: 1.5;
    }

    .acc-print-footer-legal {
        border-top: 1px solid #e0e0e0;
        padding-top: 16px;
        margin-top: 16px;
    }

    /* Masquer elements non imprimables */
    .acc-tabs,
    .acc-header-actions,
    .acc-filter-bar,
    .acc-pagination,
    .acc-btn,
    .acc-modal-overlay,
    .acc-table-actions,
    .no-print {
        display: none !important;
    }
}

/* ========== RESPONSIVE COMPLEX BREAKPOINTS ========== */
@media (max-width: 1400px) {
    .acc-dashboard-row.cols-4 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 1024px) {
    .acc-dashboard-row.cols-2-1,
    .acc-dashboard-row.cols-1-2 {
        grid-template-columns: 1fr;
    }

    .acc-dashboard-row.cols-3 {
        grid-template-columns: 1fr 1fr;
    }

    .acc-line-items-header,
    .acc-line-item-row {
        grid-template-columns: 2fr 1fr 1fr 1fr 36px;
    }
}

@media (max-width: 768px) {
    .acc-dashboard-row.cols-4,
    .acc-dashboard-row.cols-3,
    .acc-dashboard-row.cols-1-1 {
        grid-template-columns: 1fr;
    }

    .acc-line-items-header {
        display: none;
    }

    .acc-line-item-row {
        grid-template-columns: 1fr;
        gap: 8px;
        padding: 14px 16px;
        position: relative;
    }

    .acc-line-item-row input::placeholder {
        font-size: 0.75rem;
    }

    .acc-line-item-remove {
        position: absolute;
        top: 10px;
        right: 10px;
    }

    .acc-cashflow-chart {
        height: 220px;
    }

    .acc-print-parties {
        flex-direction: column;
        gap: 20px;
    }

    .acc-print-party {
        max-width: 100%;
    }
}

@media (max-width: 480px) {
    .acc-line-items-total {
        flex-direction: column;
        gap: 8px;
    }

    .acc-line-items-total-row {
        justify-content: space-between;
    }

    .acc-cashflow-chart {
        height: 180px;
        padding: 12px;
    }

    .acc-financial-table th,
    .acc-financial-table td {
        padding: 8px 12px;
        font-size: 0.8rem;
    }
}

/* ========== TRANSITIONS ET ANIMATIONS ========== */
@keyframes acc-fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes acc-slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes acc-scaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.acc-animate-in {
    animation: acc-fadeIn 0.3s ease-out forwards;
}

.acc-animate-slide {
    animation: acc-slideInRight 0.3s ease-out forwards;
}

.acc-animate-scale {
    animation: acc-scaleIn 0.2s ease-out forwards;
}

/* Stagger animation for list items */
.acc-stagger-item {
    opacity: 0;
    animation: acc-fadeIn 0.3s ease-out forwards;
}

.acc-stagger-item:nth-child(1) { animation-delay: 0.05s; }
.acc-stagger-item:nth-child(2) { animation-delay: 0.1s; }
.acc-stagger-item:nth-child(3) { animation-delay: 0.15s; }
.acc-stagger-item:nth-child(4) { animation-delay: 0.2s; }
.acc-stagger-item:nth-child(5) { animation-delay: 0.25s; }
.acc-stagger-item:nth-child(6) { animation-delay: 0.3s; }
.acc-stagger-item:nth-child(7) { animation-delay: 0.35s; }
.acc-stagger-item:nth-child(8) { animation-delay: 0.4s; }
.acc-stagger-item:nth-child(9) { animation-delay: 0.45s; }
.acc-stagger-item:nth-child(10) { animation-delay: 0.5s; }

/* ========== SKELETON LOADING ========== */
@keyframes acc-skeleton {
    0% {
        background-position: -200px 0;
    }
    100% {
        background-position: calc(200px + 100%) 0;
    }
}

.acc-skeleton {
    background: linear-gradient(90deg, var(--bg-secondary, #f0f0f0) 25%, #e0e0e0 50%, var(--bg-secondary, #f0f0f0) 75%);
    background-size: 200px 100%;
    animation: acc-skeleton 1.5s ease-in-out infinite;
    border-radius: 6px;
}

.acc-skeleton-text {
    height: 14px;
    margin-bottom: 8px;
    width: 80%;
}

.acc-skeleton-text.short {
    width: 40%;
}

.acc-skeleton-card {
    height: 120px;
    border-radius: 12px;
}

.acc-skeleton-chart {
    height: 280px;
    border-radius: 12px;
}
