/* Invoice Management System - Laravel Version */
/* This file is identical to assets/style.css from the PHP version */

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #4f46e5;
    --primary-dark: #4338ca;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --info-color: #3b82f6;
    --bg-color: #f8fafc;
    --surface-color: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Navigation */
.navbar {
    background: var(--surface-color);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-brand h1 {
    font-size: 1.5rem;
    color: var(--primary-color);
    padding: 1rem 0;
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: 0.5rem;
    align-items: center;
}

.nav-menu a {
    text-decoration: none;
    color: var(--text-secondary);
    padding: 0.75rem 1.25rem;
    border-radius: 0.5rem;
    transition: all 0.3s ease;
    font-weight: 500;
}

.nav-menu a:hover {
    background: var(--bg-color);
    color: var(--text-primary);
}

.nav-menu a.active {
    background: var(--primary-color);
    color: white;
}

/* Container */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
    flex: 1;
}

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.page-header h1 {
    font-size: 2rem;
    color: var(--text-primary);
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.3s ease;
    background: var(--surface-color);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    border: none;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
    border: none;
}

.btn-success {
    background: var(--success-color);
    color: white;
    border: none;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
    border: none;
}

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

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--surface-color);
    padding: 1.5rem;
    border-radius: 0.75rem;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: all 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.stat-icon {
    font-size: 2.5rem;
    background: var(--bg-color);
    padding: 1rem;
    border-radius: 0.5rem;
}

.stat-info h3 {
    font-size: 2rem;
    color: var(--primary-color);
    margin-bottom: 0.25rem;
}

.stat-info p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Tables */
.data-table {
    width: 100%;
    background: var(--surface-color);
    border-radius: 0.75rem;
    box-shadow: var(--shadow);
    overflow: hidden;
    border-collapse: collapse;
}

.data-table thead {
    background: var(--bg-color);
}

.data-table th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border-color);
}

.data-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
}

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

.data-table .actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.data-table .actions form {
    display: inline;
}

/* Forms */
.form-card {
    background: var(--surface-color);
    padding: 2rem;
    border-radius: 0.75rem;
    box-shadow: var(--shadow);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    font-size: 1rem;
    font-family: inherit;
    transition: all 0.3s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* Validation Styles */
.form-group input.is-invalid,
.form-group select.is-invalid,
.form-group textarea.is-invalid {
    border-color: var(--danger-color);
    background-color: #fef2f2;
}

.form-group input.is-invalid:focus,
.form-group select.is-invalid:focus,
.form-group textarea.is-invalid:focus {
    border-color: var(--danger-color);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.error-message {
    display: block;
    color: var(--danger-color);
    font-size: 0.875rem;
    margin-top: 0.25rem;
    font-weight: 500;
}

.error-message.server-error {
    color: var(--danger-color);
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}

/* Alerts */
.alert {
    padding: 1rem 1.5rem;
    border-radius: 0.5rem;
    margin-bottom: 1.5rem;
    font-weight: 500;
}

.alert-success {
    background: #d1fae5;
    color: #065f46;
    border-left: 4px solid var(--success-color);
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
    border-left: 4px solid var(--danger-color);
}

/* Status Badges */
.status-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.875rem;
    font-weight: 600;
}

.status-draft {
    background: #e0e7ff;
    color: #3730a3;
}

.status-sent {
    background: #dbeafe;
    color: #1e40af;
}

.status-paid {
    background: #d1fae5;
    color: #065f46;
}

.status-cancelled {
    background: #fee2e2;
    color: #991b1b;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    background: var(--surface-color);
    border-radius: 0.75rem;
    box-shadow: var(--shadow);
}

.empty-state p {
    font-size: 1.125rem;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

/* Recent Section */
.recent-section {
    background: var(--surface-color);
    padding: 1.5rem;
    border-radius: 0.75rem;
    box-shadow: var(--shadow);
}

.recent-section h2 {
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

/* Filter Bar */
.filter-bar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    text-decoration: none;
    color: var(--text-secondary);
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
    font-weight: 500;
}

.filter-btn:hover {
    background: var(--bg-color);
}

.filter-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* Invoice Items */
.invoice-item {
    margin-bottom: 1rem;
    padding: 1rem;
    background: var(--bg-color);
    border-radius: 0.5rem;
}

.item-row {
    display: grid;
    grid-template-columns: 1fr 2fr 1fr 1fr 1fr 100px;
    gap: 1rem;
    align-items: end;
}

/* Invoice Totals */
.invoice-totals {
    max-width: 400px;
    margin: 2rem 0 2rem auto;
    background: var(--bg-color);
    padding: 1.5rem;
    border-radius: 0.5rem;
}

.total-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1rem;
    align-items: center;
}

.total-row label {
    font-weight: 500;
}

.total-row input {
    width: 120px;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
}

.total-final {
    padding-top: 1rem;
    border-top: 2px solid var(--border-color);
    font-size: 1.25rem;
    color: var(--primary-color);
}

/* Invoice View */
.invoice-actions {
    display: flex;
    justify-content: space-between;
    margin-bottom: 2rem;
    gap: 1rem;
}

.invoice-actions > div {
    display: flex;
    gap: 0.5rem;
}

.invoice-container {
    background: var(--surface-color);
    padding: 3rem;
    border-radius: 0.75rem;
    box-shadow: var(--shadow-lg);
    max-width: 900px;
    margin: 0 auto;
}

.invoice-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 2rem;
    padding-bottom: 2rem;
    border-bottom: 2px solid var(--border-color);
}

.invoice-header h1 {
    color: var(--primary-color);
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.company-info {
    text-align: right;
}

.company-info h2 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.invoice-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
    align-items: start;
}

.bill-to,
.invoice-info {
    display: flex;
    flex-direction: column;
}

.bill-to h3,
.invoice-info strong {
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.invoice-info {
    text-align: right;
    align-items: flex-end;
}

.invoice-table {
    width: 100%;
    margin-bottom: 2rem;
    border-collapse: collapse;
}

.invoice-table thead {
    background: var(--bg-color);
}

.invoice-table th,
.invoice-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.invoice-table th:last-child,
.invoice-table td:last-child {
    text-align: right;
}

.invoice-summary {
    max-width: 350px;
    margin-left: auto;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 0;
}

.summary-total {
    border-top: 2px solid var(--border-color);
    margin-top: 0.5rem;
    padding-top: 1rem;
    font-size: 1.25rem;
    color: var(--primary-color);
}

.invoice-notes {
    margin-top: 2rem;
    padding: 1.5rem;
    background: var(--bg-color);
    border-radius: 0.5rem;
}

.invoice-notes h3 {
    margin-bottom: 0.5rem;
}

.invoice-footer {
    text-align: center;
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
    color: var(--text-secondary);
}

/* Footer */
.footer {
    background: var(--surface-color);
    border-top: 1px solid var(--border-color);
    padding: 1.5rem 0;
    text-align: center;
    color: var(--text-secondary);
    margin-top: auto;
}

/* Print Styles for A4 Format */
@media print {
    /* Hide non-essential elements */
    .navbar, .nav-container, .footer, .btn, button,
    .filter-bar, .page-header .btn, .invoice-actions,
    .alert, .stats-grid, .recent-section {
        display: none !important;
    }
    
    /* A4 Page Setup */
    @page {
        size: A4 portrait;
        margin: 15mm 15mm 15mm 15mm;
    }
    
    /* Reset body and containers */
    body {
        margin: 0;
        padding: 0;
        background: white !important;
        color: black;
        font-size: 10pt;
    }
    
    .container {
        max-width: 100%;
        width: 100%;
        padding: 0;
        margin: 0;
    }
    
    /* Invoice container adjustments */
    .invoice-container {
        box-shadow: none !important;
        border: none !important;
        padding: 0;
        margin: 0;
        max-width: 100%;
        background: white !important;
    }
    
    /* Tables */
    .data-table,
    .invoice-table {
        page-break-inside: auto;
        border-collapse: collapse;
    }
    
    .data-table tr,
    .invoice-table tr {
        page-break-inside: avoid;
        page-break-after: auto;
    }
    
    .data-table thead,
    .invoice-table thead {
        display: table-header-group;
    }
    
    /* Preserve colors */
    * {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        color-adjust: exact;
    }
    
    /* Links */
    a {
        text-decoration: none;
        color: inherit;
    }
    
    /* Avoid page breaks */
    .invoice-header,
    .invoice-summary,
    .invoice-notes,
    .invoice-footer,
    .bill-to,
    .invoice-info {
        page-break-inside: avoid;
    }
}

/* ============================================
   SIDEBAR LAYOUT STYLES
   ============================================ */

/* Sidebar Layout Body */
body.sidebar-layout {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Top Bar */
.topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: var(--surface-color);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 2rem;
    z-index: 1000;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.topbar-brand {
    font-size: 1.25rem;
    color: var(--primary-color);
    margin: 0;
}

.sidebar-toggle {
    display: none; /* Hidden on desktop */
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    width: 40px;
    height: 40px;
    position: relative;
}

.sidebar-toggle span {
    display: block;
    width: 24px;
    height: 2px;
    background: var(--text-primary);
    margin: 5px 0;
    transition: all 0.3s ease;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.user-info {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.user-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.user-role {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: capitalize;
}

/* Sidebar */
.sidebar {
    position: fixed;
    left: 0;
    top: 60px;
    bottom: 0;
    width: 260px;
    background: var(--surface-color);
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    overflow-x: visible;
    transition: all 0.3s ease;
    z-index: 999;
    height: calc(100vh - 60px);
}

.sidebar.collapsed {
    width: 70px;
}

.sidebar.collapsed .sidebar-item span,
.sidebar.collapsed .sidebar-section-title,
.sidebar.collapsed .sidebar-collapse-btn span {
    display: none;
}

.sidebar.collapsed .sidebar-item {
    justify-content: center;
}

.sidebar-nav {
    padding: 1rem 0;
    padding-bottom: 100px; /* Space for footer */
    min-height: calc(100vh - 60px);
    display: block !important;
    position: relative;
    z-index: 2;
}

.sidebar-section {
    margin-bottom: 1.5rem;
    display: block !important;
    visibility: visible !important;
    overflow: visible !important;
    height: auto !important;
    max-height: none !important;
}

.sidebar-section .sidebar-item,
.sidebar-section > .sidebar-item,
.sidebar-section a.sidebar-item {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    height: auto !important;
    max-height: none !important;
    position: relative !important;
}

/* Ensure all sidebar items are visible when expanded */
.sidebar:not(.collapsed) .sidebar-item,
.sidebar .sidebar-item,
.sidebar-section .sidebar-item,
.sidebar-section a.sidebar-item {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    height: auto !important;
    min-height: auto !important;
    max-height: none !important;
    position: relative !important;
    z-index: 1 !important;
}

.sidebar:not(.collapsed) .sidebar-section,
.sidebar .sidebar-section {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    height: auto !important;
    min-height: auto !important;
    max-height: none !important;
}

.sidebar:not(.collapsed) .sidebar-section-title,
.sidebar .sidebar-section-title {
    display: block !important;
    visibility: visible !important;
}

.sidebar-section-title {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-secondary);
    padding: 0.5rem 1.5rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.sidebar-item {
    display: flex !important;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.2s ease;
    font-weight: 500;
    position: relative;
    visibility: visible !important;
    opacity: 1 !important;
    height: auto !important;
    min-height: 44px !important;
    max-height: none !important;
    overflow: visible !important;
}

/* Force all sidebar items to be visible - no exceptions */
.sidebar .sidebar-section .sidebar-item:nth-child(1),
.sidebar .sidebar-section .sidebar-item:nth-child(2),
.sidebar .sidebar-section .sidebar-item:nth-child(3),
.sidebar .sidebar-section .sidebar-item:nth-child(4),
.sidebar .sidebar-section .sidebar-item:nth-child(5) {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.sidebar-item:hover {
    background: var(--bg-color);
    color: var(--primary-color);
}

.sidebar-item.active {
    background: linear-gradient(90deg, rgba(79, 70, 229, 0.1) 0%, transparent 100%);
    color: var(--primary-color);
    border-left: 3px solid var(--primary-color);
}

.sidebar-item svg {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
}

.sidebar-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    background: var(--surface-color);
    z-index: 5;
    pointer-events: auto;
    height: auto;
    max-height: 80px;
}

.sidebar-collapse-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
}

.sidebar-collapse-btn:hover {
    background: var(--bg-color);
    color: var(--text-primary);
}

.sidebar.collapsed .sidebar-collapse-btn {
    justify-content: center;
}

.sidebar.collapsed .sidebar-collapse-btn svg {
    transform: rotate(180deg);
}

/* Main Content with Sidebar */
.main-content {
    margin-left: 260px;
    margin-top: 60px;
    padding: 2rem;
    min-height: calc(100vh - 60px);
    transition: margin-left 0.3s ease;
}

.sidebar.collapsed + .main-content {
    margin-left: 70px;
}

/* Page Header with Sidebar Layout */
.main-content .page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.main-content .page-header h1 {
    font-size: 2rem;
    color: var(--text-primary);
    margin: 0;
}

/* Guest Layout (for login/register pages) */
.guest-layout {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.mobile-open {
        transform: translateX(0);
    }
    
    .sidebar-toggle {
        display: block;
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .topbar {
        padding: 0 1rem;
    }
    
    .topbar-brand {
        font-size: 1rem;
    }
    
    .user-info {
        display: none;
    }
}

@media (max-width: 768px) {
    .nav-container {
        flex-direction: column;
        padding: 1rem;
    }
    
    .nav-menu {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .item-row {
        grid-template-columns: 1fr;
    }
    
    .invoice-header,
    .invoice-details {
        grid-template-columns: 1fr;
    }
    
    .company-info {
        text-align: left;
    }
    
    .invoice-container {
        padding: 1.5rem;
    }
    
    .data-table {
        font-size: 0.875rem;
    }
    
    .data-table .actions {
        flex-direction: column;
    }
    
    .main-content {
        padding: 1rem;
    }
    
    .topbar-right .btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
    }
    
    .topbar-right .btn svg {
        width: 14px;
        height: 14px;
    }
}

