@import url("./invoice-doc.css");

/* ============================================
   Sidebar Navigation Layout
   ============================================ */

/* Main layout wrapper */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 240px;
    background-color: #ffffff;
    border-right: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column;
    z-index: 40;
    overflow-y: auto;
}

/* Logo area */
.app-sidebar__logo {
    padding: 1.5rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.app-sidebar__logo-bold {
    font-size: 1.125rem;
    font-weight: 700;
    color: #1f2937;
    font-family: 'Inter', system-ui, sans-serif;
}

.app-sidebar__logo-light {
    font-size: 1.125rem;
    font-weight: 400;
    color: #6b7280;
    font-family: 'Inter', system-ui, sans-serif;
}

/* Navigation */
.app-sidebar__nav {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.5rem 0.75rem;
    flex: 1;
}

.app-sidebar__link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.875rem;
    border-radius: 0.5rem;
    font-size: 0.9375rem;
    font-weight: 500;
    color: #4b5563;
    text-decoration: none;
    transition: all 0.15s ease;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-family: 'Inter', system-ui, sans-serif;
}

.app-sidebar__link:hover {
    background-color: #f3f4f6;
    color: #1f2937;
}

.app-sidebar__link--active {
    background-color: #eff6ff;
    color: #2563eb;
    font-weight: 600;
}

.app-sidebar__link--active:hover {
    background-color: #dbeafe;
}

.app-sidebar__link svg,
.app-sidebar__link-icon {
    width: 1.25rem;
    height: 1.25rem;
    flex-shrink: 0;
}

/* User area at bottom */
.app-sidebar__user {
    padding: 1rem 1.25rem;
    border-top: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

/* Avatar + name → profile (logout stays separate) */
.app-sidebar__user-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
    min-width: 0;
    text-decoration: none;
    color: inherit;
    border-radius: 0.5rem;
    padding: 0.125rem 0.375rem 0.125rem 0.125rem;
    margin: -0.125rem 0 -0.125rem -0.125rem;
    transition: background-color 0.15s ease;
}

.app-sidebar__user-profile:hover {
    background-color: #f3f4f6;
}

.app-sidebar__user-profile:focus-visible {
    outline: 2px solid #4a90e2;
    outline-offset: 2px;
}

.app-sidebar__avatar {
    width: 2rem;
    height: 2rem;
    border-radius: 9999px;
    background-color: #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.app-sidebar__avatar svg {
    width: 1.25rem;
    height: 1.25rem;
    color: #6b7280;
}

.app-sidebar__username {
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Main content area */
.app-main {
    flex: 1;
    margin-left: 240px;
    min-height: 100vh;
    background-color: #f3f4f6;
}

/* Mobile sidebar overlay backdrop */
.app-sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.4);
    z-index: 35;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.app-sidebar-backdrop.open {
    opacity: 1;
}

/* Mobile hamburger for sidebar */
.app-sidebar-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 0.5rem;
    border: none;
    background: none;
    color: #374151;
    cursor: pointer;
}

.app-sidebar-toggle:hover {
    background-color: #f3f4f6;
}

/* Mobile top bar (shown when sidebar is hidden) */
.app-mobile-topbar {
    display: none;
    position: sticky;
    top: 0;
    z-index: 30;
    background-color: #ffffff;
    border-bottom: 1px solid #e5e7eb;
    padding: 0.75rem 1rem;
    align-items: center;
    justify-content: space-between;
}

.app-mobile-topbar__logo {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

/* ============================================
   Responsive: Tablet and below
   ============================================ */
@media (max-width: 1023px) {
    .app-sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: none;
    }

    .app-sidebar.open {
        transform: translateX(0);
        box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    }

    .app-sidebar-backdrop {
        display: block;
        pointer-events: none;
    }

    .app-sidebar-backdrop.open {
        pointer-events: auto;
    }

    .app-sidebar-toggle {
        display: flex;
    }

    .app-mobile-topbar {
        display: flex;
    }

    .app-main {
        margin-left: 0;
    }
}

/* ============================================
   Top Navigation Bar (for invoice list view)
   ============================================ */
.app-topnav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.875rem 1.5rem;
    background-color: #ffffff;
    border-bottom: 1px solid #e5e7eb;
}

.app-topnav__logo {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.app-topnav__links {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.app-topnav__link {
    font-size: 0.9375rem;
    font-weight: 500;
    color: #4b5563;
    text-decoration: none;
    transition: color 0.15s ease;
}

.app-topnav__link:hover {
    color: #1f2937;
}

.app-topnav__link--active {
    color: #1f2937;
    font-weight: 600;
}

.app-topnav__user {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ============================================
   Dashboard Cards
   ============================================ */
.dashboard-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}

@media (max-width: 767px) {
    .dashboard-cards {
        grid-template-columns: 1fr;
    }
}

@media (min-width: 768px) and (max-width: 1023px) {
    .dashboard-cards {
        grid-template-columns: repeat(2, 1fr);
    }
}

.dashboard-card {
    background-color: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    padding: 1.5rem;
    transition: box-shadow 0.2s ease;
}

.dashboard-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.dashboard-card__title {
    font-size: 0.875rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 1rem;
}

.dashboard-card__value {
    font-size: 1.875rem;
    font-weight: 700;
    color: #111827;
}

.dashboard-card__subtitle {
    font-size: 0.8125rem;
    color: #6b7280;
    margin-top: 0.25rem;
}

.dashboard-card__trend--up {
    color: #059669;
    font-size: 0.8125rem;
    font-weight: 500;
}

.dashboard-card__trend--down {
    color: #dc2626;
    font-size: 0.8125rem;
    font-weight: 500;
}

/* ============================================
   Invoice Table Styles
   ============================================ */
.invoice-table-wrapper {
    background-color: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    overflow: hidden;
}

.invoice-table {
    width: 100%;
    border-collapse: collapse;
}

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

.invoice-table th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #6b7280;
    text-transform: none;
}

.invoice-table td {
    padding: 0.875rem 1rem;
    font-size: 0.875rem;
    color: #374151;
    border-bottom: 1px solid #f3f4f6;
}

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

.invoice-table tbody tr:hover {
    background-color: #f9fafb;
}

/* Status badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 9999px;
    font-weight: 600;
    font-size: 0.75rem;
    line-height: 1rem;
    padding: 0.25rem 0.75rem;
}

.status-badge--paid {
    background-color: #dcfce7;
    color: #166534;
}

.status-badge--open {
    background-color: #dbeafe;
    color: #1d4ed8;
}

.status-badge--overdue {
    background-color: #fee2e2;
    color: #b91c1c;
}

.status-badge--draft {
    background-color: #f3f4f6;
    color: #6b7280;
}

/* Pagination */
.invoice-pagination {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 1rem;
    border-top: 1px solid #e5e7eb;
    font-size: 0.875rem;
    color: #6b7280;
}

.invoice-pagination__btn {
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.375rem;
    border: 1px solid #e5e7eb;
    background: #ffffff;
    color: #374151;
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.invoice-pagination__btn:hover {
    background-color: #f3f4f6;
}

.invoice-pagination__btn--active {
    background-color: #2563eb;
    color: #ffffff;
    border-color: #2563eb;
}

/* ============================================
   Filter bar
   ============================================ */
.invoice-filters {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 0;
    flex-wrap: wrap;
}

.invoice-filters__search {
    flex: 1;
    min-width: 200px;
    position: relative;
}

.invoice-filters__search input {
    width: 100%;
    padding: 0.625rem 0.875rem 0.625rem 2.5rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    background-color: #ffffff;
    outline: none;
    transition: border-color 0.15s ease;
}

.invoice-filters__search input:focus {
    border-color: #93c5fd;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.invoice-filters__search svg {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    width: 1.125rem;
    height: 1.125rem;
    color: #9ca3af;
}

.invoice-filters select {
    padding: 0.625rem 2rem 0.625rem 0.875rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    background-color: #ffffff;
    color: #374151;
    outline: none;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
}

.invoice-filters select:focus {
    border-color: #93c5fd;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* ============================================
   Invoice Editor Split View
   ============================================ */
.invoice-editor-layout {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 0;
    min-height: calc(100vh - 60px);
}

@media (max-width: 1023px) {
    .invoice-editor-layout {
        grid-template-columns: 1fr;
    }
}

.invoice-editor__preview {
    background-color: #eef2f7;
    background-image: radial-gradient(circle at 1px 1px, #d1d9e6 1px, transparent 0);
    background-size: 24px 24px;
    padding: 2.5rem 2rem;
    display: flex;
    justify-content: center;
    overflow-y: auto;
}

.invoice-editor__paper {
    background-color: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08), 0 1px 4px rgba(0,0,0,0.04);
    /* ~1,5–2 cm Rand links/rechts zur Endrechnung (A4-Optik) */
    padding: 3rem 3.5rem;
    width: 100%;
    max-width: 820px;
    min-height: 700px;
}

.invoice-editor__config {
    background-color: #ffffff;
    border-left: 1px solid #e5e7eb;
    padding: 2rem;
    overflow-y: auto;
    max-height: 100vh;
    position: sticky;
    top: 0;
}

@media (max-width: 1023px) {
    .invoice-editor__config {
        border-left: none;
        border-top: 1px solid #e5e7eb;
        position: static;
        max-height: none;
    }
}

.invoice-editor__config-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #111827;
    margin-bottom: 1.5rem;
}

.invoice-editor__config-group {
    margin-bottom: 1.5rem;
}

.invoice-editor__config-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.5rem;
}

.invoice-editor__config-select,
.invoice-editor__config-input,
textarea.invoice-editor__config-input {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    background-color: #ffffff;
    outline: none;
}

.invoice-editor__config-select:focus,
.invoice-editor__config-input:focus {
    border-color: #93c5fd;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Toggle switch */
.toggle-switch {
    position: relative;
    width: 2.75rem;
    height: 1.5rem;
    background-color: #d1d5db;
    border-radius: 9999px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.toggle-switch.active {
    background-color: #2563eb;
}

.toggle-switch::after {
    content: '';
    position: absolute;
    top: 0.125rem;
    left: 0.125rem;
    width: 1.25rem;
    height: 1.25rem;
    background-color: #ffffff;
    border-radius: 9999px;
    transition: transform 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.toggle-switch.active::after {
    transform: translateX(1.25rem);
}

/* Send button */
.btn-send-invoice {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 0.875rem 1.5rem;
    background-color: #1e40af;
    color: #ffffff;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 0.5rem;
    border: none;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.btn-send-invoice:hover {
    background-color: #1d4ed8;
}

/* ============================================
   Recent Activities List
   ============================================ */
.activity-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.activity-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.activity-item__icon {
    width: 2rem;
    height: 2rem;
    border-radius: 9999px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.activity-item__icon--success {
    background-color: #dcfce7;
    color: #16a34a;
}

.activity-item__icon--info {
    background-color: #dbeafe;
    color: #2563eb;
}

.activity-item__icon--warning {
    background-color: #ffedd5;
    color: #ea580c;
}

.activity-item__text {
    font-size: 0.8125rem;
    color: #374151;
    line-height: 1.4;
}

.activity-item__amount {
    font-weight: 600;
    color: #111827;
}

/* Config panel right-side divider */
.invoice-editor__config hr {
    border: none;
    border-top: 1px solid #f3f4f6;
    margin: 1.25rem 0;
}

/* ============================================
   Invoice Document (Live Preview)
   ============================================ */
.inv-doc {
    padding: 0;
    font-size: 0.9rem;
    color: #1f2937;
    line-height: 1.6;
}

/* Accent bar at top of document */
.inv-doc::before {
    content: '';
    display: block;
    height: 4px;
    background: linear-gradient(90deg, #4A90E2, #6366f1);
    border-radius: 2px;
    margin-bottom: 2.5rem;
}

/* Two-column header: sender (left) | invoice meta (right) */
.inv-doc__header {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 3rem;
    align-items: start;
    margin-bottom: 3rem;
}

.inv-doc__company-name {
    font-size: 1.25rem;
    font-weight: 800;
    color: #111827;
    letter-spacing: -0.01em;
    margin-bottom: 0.35rem;
}

.inv-doc__sender-address {
    font-size: 0.85rem;
    color: #6b7280;
    line-height: 1.55;
    white-space: pre-line;
}

.inv-doc__sender-tax {
    margin-top: 0.75rem;
    font-size: 0.78rem;
    color: #9ca3af;
    line-height: 1.6;
}

.inv-doc__sender-tax strong {
    color: #6b7280;
    font-weight: 500;
}

/* Right column: RECHNUNG title + meta */
.inv-doc__invoice-meta {
    text-align: right;
    min-width: 200px;
}

.inv-doc__title {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    color: #111827;
    text-align: right;
    margin-bottom: 1rem;
    text-transform: uppercase;
}

.inv-doc__meta-table {
    border-collapse: collapse;
    margin-left: auto;
}

.inv-doc__meta-table td {
    padding: 0.2rem 0;
    font-size: 0.8rem;
    white-space: nowrap;
}

.inv-doc__meta-table td:first-child {
    color: #9ca3af;
    padding-right: 1.25rem;
    text-align: right;
}

.inv-doc__meta-table td:last-child {
    font-weight: 600;
    color: #111827;
    text-align: right;
}

/* Divider between header and bill-to */
.inv-doc__divider {
    border: none;
    border-top: 1px solid #e5e7eb;
    margin: 0 0 2rem 0;
}

/* Bill To section */
.inv-doc__bill-to {
    margin-bottom: 2.5rem;
    padding: 1.25rem 1.5rem;
    background: #f8fafc;
    border-radius: 0.625rem;
    border-left: 3px solid #4A90E2;
}

.inv-doc__bill-to-label {
    font-size: 0.68rem;
    font-weight: 700;
    color: #4A90E2;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.4rem;
}

/* Items area border */
.inv-doc__items-area {
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    overflow: hidden;
    margin-bottom: 1rem;
}

/* Items column header — matches invoice-item-fields grid */
.inv-items-header {
    display: none;
    padding: 0.5rem 0.75rem;
    background: #f8fafc;
    border-bottom: 1px solid #e5e7eb;
}

@media (min-width: 640px) {
    .inv-items-header {
        display: grid;
        grid-template-columns:
            minmax(0, 1fr)
            2.75rem
            3.75rem
            4.25rem
            minmax(4rem, auto)
            auto;
        gap: 0;
        align-items: center;
    }
}

.inv-items-header span {
    font-size: 0.68rem;
    font-weight: 700;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    padding: 0 0.25rem;
}

.inv-items-header span:not(:first-child) {
    text-align: right;
}

/* Item rows inside inv-doc: flat, no card */
.inv-doc .invoice-item-row {
    background: transparent !important;
    border: none !important;
    border-bottom: 1px solid #f1f5f9 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    padding: 0.5rem 0.75rem !important;
    transition: background-color 0.1s !important;
}

.inv-doc .invoice-item-row:last-of-type {
    border-bottom: none !important;
}

.inv-doc .invoice-item-row:focus-within {
    background-color: #f0f9ff !important;
    border-radius: 0 !important;
}

/* Add item button */
.inv-add-item-btn {
    display: inline-flex;
    align-items: center;
    font-size: 0.8rem;
    font-weight: 600;
    color: #4A90E2;
    background: transparent;
    border: 1.5px dashed #bfdbfe;
    border-radius: 0.375rem;
    padding: 0.4rem 0.875rem;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.inv-add-item-btn:hover {
    background: #eff6ff;
    border-color: #4A90E2;
    color: #2563eb;
}

/* Totals section */
.inv-doc__totals {
    margin-left: auto;
    width: 300px;
    margin-top: 1.5rem;
    padding: 1.25rem 1.5rem;
    background: #f8fafc;
    border-radius: 0.625rem;
    border: 1px solid #e5e7eb;
}

.inv-doc__total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.3rem 0;
    font-size: 0.875rem;
    color: #4b5563;
}

.inv-doc__total-final {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 700;
    font-size: 1.125rem;
    color: #111827;
    border-top: 2px solid #111827;
    padding-top: 0.75rem;
    margin-top: 0.5rem;
}

/* Payment info section */
.inv-doc__payment-info {
    margin-top: 2.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid #f1f5f9;
    font-size: 0.825rem;
    color: #6b7280;
}

.inv-doc__payment-info p:first-child {
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.375rem;
}
