/* Modern Invoice Approval System Styles */

:root {
    --primary-blue: #007bff;
    --success-green: #28a745;
    --danger-red: #dc3545;
    --light-gray: #f8f9fa;
    --medium-gray: #6c757d;
    --dark-gray: #343a40;
    --border-color: #dee2e6;
    --hover-color: #e9ecef;
    --shadow: 0 2px 4px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 8px rgba(0,0,0,0.15);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: #f5f5f5;
    color: var(--dark-gray);
}

.invoice-approval-container {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-header {
    background: white;
    padding: 1rem 2rem;
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    z-index: 1000;
    display: flex;
    align-items: center;
    position: relative;
}

.app-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--dark-gray);
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.header-insights-btn {
    /* Inherits all styling from .insights-btn, just ensures it stays left */
    margin-right: auto;
}

.main-content {
    flex: 1;
    display: grid;
    grid-template-columns: 300px 1fr 350px;
    gap: 0;
    overflow: hidden;
}

/* Files Panel */
.files-panel {
    background: white;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Logo Section */
.logo-section {
    padding: 1rem;
    background: white;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 140px; /* Increased height to accommodate potential button */
    gap: 10px;
}

.company-logo {
    max-width: 100px;
    max-height: 100px;
    width: auto;
    height: auto;
    object-fit: contain;
}

.panel-header {
    padding: 1rem 1rem 0.75rem; /* Reduced padding */
    border-bottom: 1px solid var(--border-color);
    background: var(--light-gray);
}

    .panel-header h2 {
        font-size: 0.8rem; /* Reduced from 0.875rem */
        font-weight: 600;
        color: var(--medium-gray);
        margin-bottom: 0.75rem; /* Reduced from 1rem */
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }

.search-box {
    position: relative;
    display: flex;
    align-items: center;
}

    .search-box input {
        width: 100%;
        padding: 0.5rem 2rem 0.5rem 0.75rem;
        border: 1px solid var(--border-color);
        border-radius: 4px;
        font-size: 0.875rem;
        background: white;
    }

        .search-box input:focus {
            outline: none;
            border-color: var(--primary-blue);
            box-shadow: 0 0 0 2px rgba(0,123,255,0.25);
        }

.clear-search {
    position: absolute;
    right: 0.5rem;
    background: none;
    border: none;
    font-size: 1rem;
    color: var(--medium-gray);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 2px;
}

    .clear-search:hover {
        background: var(--hover-color);
        color: var(--dark-gray);
    }

.files-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem 0;
}

.file-item {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

    .file-item:hover {
        background: var(--hover-color);
    }

    .file-item.selected {
        background: #e3f2fd;
        border-left: 4px solid var(--primary-blue);
    }

        .file-item.selected::after {
            content: '';
            position: absolute;
            left: 0;
            top: 0;
            bottom: 0;
            width: 4px;
            background: var(--primary-blue);
        }

.file-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.vendor-name {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--dark-gray);
    line-height: 1.3;
    word-break: break-word;
}

.invoice-details {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.invoice-number {
    font-size: 0.75rem;
    color: var(--medium-gray);
    font-family: monospace;
}

/* PDF Panel */
.pdf-panel {
    background: white;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-right: 1px solid var(--border-color);
}

.pdf-viewer {
    flex: 1;
    overflow: hidden;
    position: relative;
    background: white;
    margin: 0;
    padding: 0;
    min-height: 0; /* Important for flex child */
}

    .pdf-viewer iframe,
    .pdf-viewer .pdf-iframe {
        width: 100%;
        height: 100%;
        border: none;
        margin: 0;
        padding: 0;
        display: block;
        background: white;
        object-fit: contain;
    }

/* Enhanced PDF iframe styling for better fit */
.pdf-iframe {
    transform-origin: top left;
    overflow: hidden;
}

/* Try to ensure PDF scales to fit width */
@media screen {
    .pdf-viewer iframe {
        min-width: 100%;
        max-width: 100%;
        width: 100% !important;
    }
}

/* Hide scrollbars on PDF iframe when needed */
.pdf-viewer iframe::-webkit-scrollbar {
    width: 8px;
}

.pdf-viewer iframe::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.pdf-viewer iframe::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

    .pdf-viewer iframe::-webkit-scrollbar-thumb:hover {
        background: #a8a8a8;
    }

/* Ensure no border or outline on focus */
.pdf-viewer iframe:focus {
    outline: none;
    border: none;
}

/* Try to hide PDF viewer controls (may not work due to cross-origin restrictions) */
.pdf-viewer iframe {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Additional attempts to hide PDF controls */
.pdf-viewer {
    position: relative;
    overflow: hidden;
}

    /* Create overlay to hide potential PDF chrome */
    .pdf-viewer::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        height: 0px; /* Adjust this if you see a toolbar at the top */
        background: white;
        z-index: 10;
        pointer-events: none;
    }

.loading-indicator,
.no-pdf-message,
.no-selection-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--medium-gray);
    text-align: center;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--primary-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

.spinner-small {
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    display: inline-block;
    margin-right: 0.5rem;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Data Panel */
.data-panel {
    background: white;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.data-form {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.65rem; /* Balanced reduction */
}

.login-box .form-group {
    margin-bottom: 1.5rem;
}

    .login-box .form-group label.form-label {
        margin-bottom: 0.15rem;
    }

.login-box .btn-login {
    margin-top: 0.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.3rem; /* Balanced */
}

    .form-group label {
        font-weight: 600;
        font-size: 0.8rem;
        color: var(--dark-gray);
        line-height: 1; /* Tighter line height */
    }

    .form-group input,
    .form-group textarea {
        padding: 0.6rem 0.75rem; /* Keep horizontal padding, reduce vertical */
        border: 1px solid var(--border-color);
        border-radius: 4px;
        font-size: 0.85rem;
        transition: border-color 0.2s ease, box-shadow 0.2s ease;
        line-height: 1.2; /* Tighter line height */
    }

    .form-group textarea {
        resize: none; /* Prevent resizing */
        min-height: 55px;
        max-height: 55px;
    }

.action-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-top: 0.5rem; /* Reduced */
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0; /* Prevent buttons from being cut off */
}

.approve-btn,
.reject-btn {
    padding: 0.65rem 0.75rem;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    min-height: 40px;
}

.approve-btn {
    background: var(--success-green);
    color: white;
}

    .approve-btn:hover:not(:disabled) {
        background: #218838;
        transform: translateY(-1px);
        box-shadow: var(--shadow);
    }

.reject-btn {
    background: var(--danger-red);
    color: white;
}

    .reject-btn:hover:not(:disabled) {
        background: #c82333;
        transform: translateY(-1px);
        box-shadow: var(--shadow);
    }

    .approve-btn:disabled,
    .reject-btn:disabled {
        opacity: 0.6;
        cursor: not-allowed;
        transform: none;
    }

/* Responsive Design */
@media (max-width: 1200px) {
    .main-content {
        grid-template-columns: 280px 1fr 320px;
    }

    /* Ensure PDF scales properly on smaller screens */
    .pdf-viewer {
        min-width: 0;
        flex-shrink: 1;
    }
}

@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 250px 1fr 300px;
    }

    .data-form {
        padding: 1rem;
        gap: 0.75rem;
    }

    /* Better PDF display on medium screens */
    .pdf-viewer iframe {
        height: 100%;
        min-height: 500px;
    }
}

@media (max-width: 768px) {
    .main-content {
        grid-template-columns: 1fr;
        grid-template-rows: 300px 1fr 400px;
    }

    .files-panel,
    .pdf-panel,
    .data-panel {
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    /* Mobile PDF viewer adjustments */
    .pdf-viewer {
        min-height: 400px;
    }

        .pdf-viewer iframe {
            min-height: 400px;
        }

    .app-header {
        padding: 1rem;
    }

    .app-title {
        font-size: 1.25rem;
    }
}

/* Scrollbar Styling */
.files-list::-webkit-scrollbar,
.data-form::-webkit-scrollbar {
    width: 6px;
}

.files-list::-webkit-scrollbar-track,
.data-form::-webkit-scrollbar-track {
    background: var(--light-gray);
}

.files-list::-webkit-scrollbar-thumb,
.data-form::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

    .files-list::-webkit-scrollbar-thumb:hover,
    .data-form::-webkit-scrollbar-thumb:hover {
        background: var(--medium-gray);
    }

/* Animation for status changes */
.file-item {
    animation: fadeIn 0.3s ease;
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Missing PO indicator */
.file-item.missing-po {
    border-left: 4px solid #dc3545;
    background-color: #fff5f5;
}

    .file-item.missing-po:hover {
        background-color: #ffe5e5;
    }

    .file-item.missing-po.selected {
        background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
        color: white;
        border-left: 4px solid #a71d2a;
    }

/* Red outline for missing PO input field */
.form-group input.missing-po-field {
    border: 2px solid #dc3545;
    background-color: #fff5f5;
}

    .form-group input.missing-po-field:focus {
        border-color: #dc3545;
        box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25);
    }

.insights-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--primary-blue);
    color: white;
    text-decoration: none;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s ease;
    border: none;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

    .insights-btn:hover {
        background: #0056b3;
        color: white;
        text-decoration: none;
        transform: translateY(-1px);
        box-shadow: 0 2px 4px rgba(0,123,255,0.3);
    }

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 1400px;
    margin: 0 auto;
}

.back-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    color: var(--primary-blue);
    text-decoration: none;
    border: 1px solid var(--primary-blue);
    border-radius: 6px;
    font-weight: 500;
    transition: all 0.2s ease;
}

    .back-button:hover {
        background: var(--primary-blue);
        color: white;
        text-decoration: none;
    }

.insights-content {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
}

.period-selector {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.period-buttons {
    display: flex;
    gap: 12px;
}

.period-btn {
    padding: 10px 20px;
    border: 1px solid var(--border-color);
    background: white;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
}

    .period-btn:hover {
        background: var(--light-gray);
    }

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

.period-info {
    font-weight: 600;
    color: var(--dark-gray);
}

.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem;
    text-align: center;
}

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

.metric-card {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 1.5rem;
    transition: transform 0.2s ease;
}

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

.metric-icon {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--light-gray);
    color: var(--primary-blue);
    font-size: 24px;
}

    .metric-icon.approved {
        background: #d4edda;
        color: var(--success-green);
    }

    .metric-icon.rejected {
        background: #f8d7da;
        color: var(--danger-red);
    }

    .metric-icon.warning {
        background: #fff3cd;
        color: #856404;
    }

.metric-content h3 {
    font-size: 2rem;
    font-weight: 700;
    margin: 0;
    color: var(--dark-gray);
}

.metric-content p {
    margin: 0;
    color: var(--medium-gray);
    font-weight: 500;
}

.analytics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.chart-card {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
}

    .chart-card.wide {
        grid-column: 1 / -1;
    }

    .chart-card h3 {
        margin: 0 0 1.5rem 0;
        color: var(--dark-gray);
        font-size: 1.25rem;
        font-weight: 600;
    }

.pie-chart-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.chart-legend {
    display: flex;
    gap: 1.5rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 4px;
}

    .legend-color.approved {
        background: var(--success-green);
    }

    .legend-color.rejected {
        background: var(--danger-red);
    }

.list-chart {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.list-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.list-item-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.vendor-name,
.job-name {
    font-weight: 500;
    color: var(--dark-gray);
}

.vendor-amount,
.job-amount {
    font-weight: 600;
    color: var(--primary-blue);
}

.progress-bar {
    width: 100%;
    height: 6px;
    background: var(--light-gray);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-blue) 0%, #0056b3 100%);
    border-radius: 3px;
    transition: width 0.3s ease;
}

.frequency-chart {
    display: flex;
    justify-content: center;
}

.insights-summary {
    margin-top: 2rem;
}

.summary-card {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
}

    .summary-card h3 {
        margin: 0 0 1.5rem 0;
        color: var(--dark-gray);
        font-size: 1.25rem;
        font-weight: 600;
    }

    .summary-card ul {
        list-style: none;
        padding: 0;
        margin: 0;
    }

    .summary-card li {
        padding: 0.75rem 0;
        border-bottom: 1px solid var(--border-color);
        color: var(--medium-gray);
    }

        .summary-card li:last-child {
            border-bottom: none;
        }

    .summary-card strong {
        color: var(--dark-gray);
    }

@media (max-width: 768px) {
    .insights-content {
        padding: 1rem;
    }

    .period-selector {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }

    .period-buttons {
        justify-content: center;
    }

    .metrics-grid {
        grid-template-columns: 1fr;
    }

    .analytics-grid {
        grid-template-columns: 1fr;
    }

    .header-content {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
}

/*Auto-Suggestions*/
.autosuggest-wrapper {
    position: relative;
    width: 100%;
}

    .autosuggest-wrapper input {
        width: 100%;
    }

.autosuggest-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 4px 4px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    max-height: 240px;
    overflow-y: auto;
    z-index: 100;
}

.autosuggest-item {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    font-size: 0.85rem;
    border-bottom: 1px solid #f0f0f0;
}

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

    .autosuggest-item.highlighted,
    .autosuggest-item:hover {
        background: var(--hover-color);
    }

/*Login page*/
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1D4C94 0%, #19407E 100%);
    padding: 20px;
}

.login-box {
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    padding: 3rem 2.5rem;
    width: 100%;
    max-width: 400px;
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-icon {
    margin-bottom: 1rem;
}

.logo-img {
    width: 64px;
    height: 64px;
    object-fit: contain;
}

.login-title {
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--dark-gray);
    margin: 0 0 0.5rem 0;
}

.login-subtitle {
    color: var(--medium-gray);
    margin: 0;
    font-size: 0.9rem;
}

.form-label {
    display: block;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--dark-gray);
    margin-bottom: 0.4rem;
}

.form-input {
    width: 100%;
    padding: 0.65rem 0.85rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.95rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

    .form-input:focus {
        outline: none;
        border-color: var(--primary-blue);
        box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.15);
    }

.login-error {
    color: var(--danger-red);
    background: #fff5f5;
    border: 1px solid #fed7d7;
    border-radius: 6px;
    padding: 0.6rem 0.85rem;
    margin-bottom: 1rem;
    font-size: 0.85rem;
}

.btn-login {
    width: 100%;
    padding: 0.75rem;
    background: linear-gradient(135deg, #E50F0F 0%, #C20D0D 100%);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

    .btn-login:hover:not(:disabled) {
        transform: translateY(-1px);
        box-shadow: 0 4px 12px rgba(229, 15, 15, 0.3);
    }

    .btn-login:disabled {
        opacity: 0.7;
        cursor: not-allowed;
    }

.global-logout-btn {
    position: absolute;
    top: 1rem;
    right: 2rem;
    z-index: 1100;
    padding: 6px 12px;
    background: white;
    color: #dc3545;
    border: 1px solid #dc3545;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}

    .global-logout-btn:hover {
        background: #dc3545;
        color: white;
        transform: translateY(-1px);
        box-shadow: 0 2px 4px rgba(220, 53, 69, 0.3);
    }

/*Tax Review*/
.tax-review-header {
    min-height: 60px;
}
