/* Frontend styles */
.author-dashboard,
.author-books,
.author-payouts {
    margin: 16px;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.adbs-frontend-card {
    background: #fff;
    box-shadow: 0 -2px 6px rgba(0,0,0,0.06), 0 4px 12px rgba(0,0,0,0.08);
    border-radius: 0.5rem;
    padding: 1rem 1.1rem 1.25rem;
    margin-bottom: 0.25rem;
    overflow: hidden; /* prevent children from causing page-level overflow */
}

.adbs-table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.sales-table,
.books-table,
.payouts-table {
    width: 100%;
}

/* ===== DataTables top toolbar: Show entries | Channel | Search ===== */
.dataTables_wrapper {
    margin-top: 4px;
    width: 100%;
    box-sizing: border-box;
}

/* Custom top bar created by our dom option */
.adbs-dt-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 16px;
    margin-bottom: 12px;
    width: 100%;
    box-sizing: border-box;
}

.adbs-dt-toolbar .dataTables_length {
    margin: 0;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
}

.adbs-dt-toolbar .dataTables_length label {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    padding: 0;
    font-weight: 600 !important;
    color: #1e3c78 !important;
    font-size: 0.88rem !important;
    white-space: nowrap;
    line-height: 34px; /* vertically center text with the select box */
    height: 34px;
}

.adbs-dt-toolbar .adbs-channel-slot {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 6px 10px;
    flex: 0 1 auto;
}

.adbs-dt-toolbar .dataTables_filter {
    margin: 0 0 0 auto; /* push search to the right */
    flex: 0 1 auto;
    min-width: 0;
}

.adbs-dt-toolbar .dataTables_filter label {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
}

/* All toolbar selects share the same look & height for perfect alignment */
.dataTables_length select,
.adbs-channel-select {
    width: auto;
    min-width: 120px;
    height: 34px;
    padding: 5px 8px;
    border: 1px solid #ccd0d4;
    border-radius: 6px;
    font-size: 0.9rem;
    background: #fff;
    box-sizing: border-box;
    vertical-align: middle;
    line-height: 1.2;
}

.dataTables_length select {
    min-width: 110px;
}

.adbs-channel-select {
    min-width: 150px;
    max-width: 190px;
}

.dataTables_filter input[type="search"] {
    height: 34px;
    padding: 5px 10px;
    border: 1px solid #ccd0d4;
    border-radius: 6px;
    font-size: 0.9rem;
    width: 180px;
    max-width: 100%;
    box-sizing: border-box;
}

.adbs-channel-label {
    display: inline-flex;
    align-items: center;
    height: 34px;
    font-weight: 600;
    color: #1e3c78;
    font-size: 0.88rem;
    white-space: nowrap;
    line-height: 1;
    margin: 0;
    padding: 0;
}

/* Note under sales table about returns / cancellations */
.adbs-return-note {
    margin: 14px 0 4px;
    margin-top: 36px;
    padding: 10px 14px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-left: 4px solid #dc2626;
    border-radius: 6px;
    font-size: 0.88rem;
    line-height: 1.5;
    color: #374151;
}

.adbs-return-note strong {
    color: #1f2937;
}

/* ===== Table cell styling (smaller fonts) ===== */
#sales-table th,
#sales-table td,
.sales-table th,
.sales-table td {
    box-sizing: border-box;
    vertical-align: top;
}

#sales-table th,
.sales-table th {
    background-color: #2563eb !important;
    color: #ffffff !important;
    border: none;
    padding: 0.55rem 0.7rem !important;
    font-size: 0.95rem !important;   /* reduced from ~1.1rem */
    font-weight: 500;
    text-transform: uppercase;
    text-align: center;
}

#sales-table td,
.sales-table td {
    border-bottom: 1px solid #e5e7eb;
    background-color: #ffffff;
    padding: 0.55rem 0.65rem !important;
    font-size: 0.95rem !important;   /* reduced from ~1.1rem */
}

#sales-table tr:hover td,
.sales-table tr:hover td {
    background-color: #eff6ff;
}

/* Column widths – slightly tighter to reduce horizontal scroll */
#sales-table {
    table-layout: fixed;
    width: 100%;
}

#sales-table th:nth-child(1),
#sales-table td:nth-child(1) { width: 13%; } /* ISBN */
#sales-table th:nth-child(2),
#sales-table td:nth-child(2) { width: 20%; } /* Title */
#sales-table th:nth-child(3),
#sales-table td:nth-child(3) { width: 12%; } /* Order ID */
#sales-table th:nth-child(4),
#sales-table td:nth-child(4) { width: 7%;  } /* Qty */
#sales-table th:nth-child(5),
#sales-table td:nth-child(5) { width: 11%; } /* Channel */
#sales-table th:nth-child(6),
#sales-table td:nth-child(6) { width: 11%; } /* MRP */
#sales-table th:nth-child(7),
#sales-table td:nth-child(7) { width: 12%; } /* Date */
#sales-table th:nth-child(8),
#sales-table td:nth-child(8) { width: 14%; } /* Royalty */

/* Pagination */
.dataTables_paginate {
    margin-top: 12px;
}
.dataTables_paginate .paginate_button {
    padding: 5px 11px;
    margin: 0 2px;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
}
.dataTables_paginate .paginate_button.current {
    background-color: #2563eb;
    color: white !important;
    border-color: #2563eb;
}
.dataTables_paginate .paginate_button:hover {
    background-color: #eff6ff;
    color: #2563eb;
}
.dataTables_paginate .paginate_button.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.dataTables_info {
    font-size: 0.88rem;
    color: #555;
}

/* Books / Payouts tables – keep consistent smaller size */
.books-table th,
.payouts-table th {
    background-color: #2563eb;
    color: white;
    border: 1px solid #ddd;
    padding: 0.55rem 0.7rem;
    font-size: 0.95rem;
}
.books-table td,
.payouts-table td {
    border: 1px solid #ddd;
    padding: 0.55rem 0.7rem;
    font-size: 0.95rem;
}
.books-table tr:hover,
.payouts-table tr:hover {
    background-color: #eff6ff;
}

.books-table th:nth-child(1),
.books-table th:nth-child(3) {
    text-align: center;
}

/* Responsive */
@media (max-width: 900px) {
    .adbs-dt-toolbar {
        gap: 10px;
    }
    .adbs-dt-toolbar .dataTables_filter {
        margin-left: 0;
        width: 100%;
    }
    .dataTables_filter input[type="search"] {
        width: 100%;
    }
    .adbs-channel-select {
        min-width: 130px;
    }
}

@media (max-width: 768px) {
    #sales-table th,
    #sales-table td {
        font-size: 0.85rem !important;
        padding: 0.45rem 0.4rem !important;
    }
}

/* ===== Royalty Payouts – Earnings card ===== */
.adbs-earnings-card {
    position: relative;
    background: linear-gradient(145deg, #ffffff 0%, #eff6ff 60%, #f8fafc 100%);
    border: 1px solid #bfdbfe;
    border-radius: 14px;
    padding: 1.4rem 1.5rem 1.25rem;
    box-shadow: 0 4px 18px rgba(37, 99, 235, 0.09);
    margin-bottom: 0.75rem;
    overflow: hidden;
}

.adbs-earnings-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, #2563eb, #3b82f6);
}

.adbs-earnings-card.is-eligible {
    border-color: #86efac;
    background: linear-gradient(145deg, #ffffff 0%, #f0fdf4 70%, #ecfdf5 100%);
    box-shadow: 0 4px 18px rgba(34, 197, 94, 0.10);
}

.adbs-earnings-card.is-eligible::before {
    background: linear-gradient(90deg, #16a34a, #22c55e);
}

.adbs-earnings-top {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 0.35rem;
}

.adbs-earnings-label {
    font-size: 1.12rem;
    font-weight: 600;
    color: #1e3a5f;
}

.adbs-earnings-amount {
    font-size: 1.75rem;
    font-weight: 800;
    color: #1d4ed8;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
}

.adbs-earnings-card.is-eligible .adbs-earnings-amount {
    color: #15803d;
}

.adbs-earnings-note {
    margin: 0 0 1rem;
    font-size: 0.9rem;
    color: #64748b;
    line-height: 1.45;
}

.adbs-progress-wrap {
    height: 11px;
    background: #e2e8f0;
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 0.6rem;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.05);
}

.adbs-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #60a5fa, #2563eb);
    border-radius: 999px;
    transition: width 0.45s ease;
    min-width: 0;
}

.adbs-progress-bar.adbs-progress-complete {
    background: linear-gradient(90deg, #4ade80, #16a34a);
}

.adbs-progress-meta {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    flex-wrap: wrap;
    font-size: 0.875rem;
    color: #475569;
}

.adbs-progress-right {
    font-weight: 600;
    color: #1e40af;
    white-space: nowrap;
}

/* Payouts table polish */
.payouts-table th {
    background-color: #2563eb !important;
    color: #fff !important;
    border: none !important;
    padding: 0.6rem 0.75rem !important;
    font-size: 0.9rem !important;
    font-weight: 500;
    text-transform: uppercase;
    text-align: center !important;
}

.payouts-table td {
    padding: 0.55rem 0.7rem !important;
    font-size: 0.95rem !important;
    text-align: center;
    border-bottom: 1px solid #e5e7eb;
    background: #fff;
}

.payouts-table tr:hover td {
    background-color: #eff6ff;
}

@media (max-width: 560px) {
    .adbs-earnings-card {
        padding: 1.15rem 1.1rem 1rem;
    }
    .adbs-earnings-amount {
        font-size: 1.45rem;
    }
    .adbs-progress-meta {
        flex-direction: column;
        gap: 4px;
    }
    .adbs-progress-right {
        white-space: normal;
    }
}

.adbs-payout-deadline {
    margin: 0.9rem 0 0;
    padding: 10px 14px;
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.45;
    color: #166534;
    background: #dcfce7;
    border: 1px solid #86efac;
    border-radius: 8px;
}

/* ---- Payout Schedule boxes ---- */
.adbs-schedule-wrap {
    margin-top: 1rem;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 1.25rem 1.35rem 1.1rem;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

.adbs-schedule-title {
    font-size: 1.1rem;
    font-weight: 650;
    color: #0f172a;
    margin-bottom: 0.95rem;
    letter-spacing: -0.01em;
}

.adbs-schedule-box {
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 1rem 1.15rem;
    margin-bottom: 0.85rem;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
}

.adbs-schedule-box.adbs-schedule-current {
    background: linear-gradient(180deg, #fffbeb 0%, #fef3c7 100%);
    border-color: #fde68a;
}

.adbs-schedule-box.adbs-schedule-empty {
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    text-align: left;
    padding: 1.15rem 1.25rem;
}

.adbs-empty-title {
    font-size: 1.05rem;
    font-weight: 650;
    color: #1e293b;
    margin: 0 0 0.4rem;
}

.adbs-empty-amount {
    font-size: 1rem;
    color: #000;
    margin: 0 0 0.5rem;
}

.adbs-empty-text {
    margin: 0;
    font-size: 0.92rem;
    line-height: 1.55;
    color: #334155;
}

.adbs-schedule-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 0.4rem;
    font-size: 0.93rem;
}

.adbs-schedule-row:last-of-type {
    margin-bottom: 0;
}

.adbs-schedule-row-amount {
    margin-bottom: 0.55rem;
    padding-bottom: 0.45rem;
    border-bottom: 1px solid #e2e8f0;
}

.adbs-schedule-label {
    color: #475569;
    font-weight: 550;
    min-width: 110px;
    flex-shrink: 0;
}

.adbs-schedule-value {
    color: #0f172a;
    font-weight: 550;
    text-align: right;
    word-break: break-word;
}

.adbs-schedule-amount {
    font-weight: 750;
    font-size: 1.25rem;
    color: #1d4ed8;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.01em;
}

.adbs-schedule-row-amount .adbs-schedule-label {
    font-size: 1rem;
    font-weight: 600;
    color: #334155;
    align-self: center;
}

.adbs-schedule-current .adbs-schedule-amount {
    color: #b45309;
}

.adbs-schedule-note {
    margin-top: 0.5rem;
    font-size: 0.82rem;
    color: #92400e;
    font-style: italic;
    line-height: 1.4;
}

.adbs-threshold-note {
    margin: 0.75rem 0 0;
    font-size: 0.88rem;
    color: #475569;
    line-height: 1.5;
}

@media (max-width: 560px) {
    .adbs-schedule-row {
        flex-direction: column;
        gap: 2px;
    }
    .adbs-schedule-value {
        text-align: left;
    }
    .adbs-schedule-label {
        min-width: auto;
    }
    .adbs-schedule-amount {
        font-size: 1.15rem;
    }
}
