/**
 * Frontend Styles for Invoice Validation
 */

/* Container */
.iv-sps-frontend-container {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.iv-sps-header {
    margin-bottom: 30px;
}

.iv-sps-header h2 {
    margin: 0;
    font-size: 28px;
    font-weight: 600;
    color: #1e1e1e;
}

/* Content Wrapper */
.iv-sps-content-wrapper {
    display: flex;
    gap: 30px;
}

/* Sidebar */
.iv-sps-sidebar {
    width: 280px;
    flex-shrink: 0;
}

.iv-sps-sidebar h3 {
    margin: 0 0 20px 0;
    font-size: 16px;
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.iv-sps-month-nav {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    overflow: hidden;
}

.iv-sps-month-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.iv-sps-month-list li {
    border-bottom: 1px solid #f0f0f0;
}

.iv-sps-month-list li:last-child {
    border-bottom: none;
}

.iv-sps-month-link {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
    text-decoration: none;
    color: #333;
    transition: all 0.2s ease;
}

.iv-sps-month-link:hover {
    background: #f8f9fa;
    color: #0073aa;
}

.iv-sps-month-link.active {
    background: linear-gradient(135deg, #0073aa 0%, #005a87 100%);
    color: #fff;
}

.iv-sps-month-name {
    font-weight: 500;
}

.iv-sps-month-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
    padding: 0 10px;
    background: #f0f0f0;
    border-radius: 14px;
    font-size: 13px;
    font-weight: 600;
    color: #666;
}

.iv-sps-month-link.active .iv-sps-month-count {
    background: rgba(255,255,255,0.25);
    color: #fff;
}

.iv-sps-loading-dot {
    width: 8px;
    height: 8px;
    background: #ccc;
    border-radius: 50%;
    animation: iv-pulse 1s ease-in-out infinite;
}

@keyframes iv-pulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

/* Main Content */
.iv-sps-main {
    flex: 1;
    min-width: 0;
}

/* Empty State */
.iv-sps-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    padding: 60px 40px;
    text-align: center;
}

.iv-sps-empty-icon {
    color: #ddd;
    margin-bottom: 20px;
}

.iv-sps-empty-state h3 {
    margin: 0 0 10px 0;
    font-size: 20px;
    color: #333;
}

.iv-sps-empty-state p {
    margin: 0;
    color: #666;
    max-width: 300px;
}

/* Invoice List */
.iv-sps-invoice-list {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    overflow: hidden;
}

.iv-sps-invoice-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: all 0.2s ease;
}

.iv-sps-invoice-item:hover {
    background: #f8f9fa;
}

.iv-sps-invoice-item:last-child {
    border-bottom: none;
}

.iv-sps-invoice-info {
    display: flex;
    align-items: center;
    gap: 16px;
}

.iv-sps-file-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 14px;
}

.iv-sps-invoice-details h4 {
    margin: 0 0 4px 0;
    font-size: 15px;
    font-weight: 600;
    color: #333;
}

.iv-sps-invoice-meta {
    font-size: 13px;
    color: #888;
}

.iv-sps-invoice-actions {
    display: flex;
    gap: 10px;
}

/* Form Elements */
.iv-sps-select {
    width: 100%;
    padding: 16px 16px;
    min-height: 54px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 15px;
    color: #333 !important;
    background-color: #fff;
    cursor: pointer;
    transition: border-color 0.2s ease;
    -webkit-appearance: menulist;
    -moz-appearance: menulist;
    appearance: menulist;
}

.iv-sps-select option {
    color: #333;
    background-color: #fff;
    padding: 10px;
}

.iv-sps-select:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.15);
}

.iv-sps-textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    color: #333;
    resize: vertical;
    transition: border-color 0.2s ease;
}

.iv-sps-textarea:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.15);
}

.iv-sps-form-group {
    margin-bottom: 20px;
}

.iv-sps-form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #333;
}

/* Modal */
.iv-sps-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 99999;
    display: none;
}

.iv-sps-modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.iv-sps-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.iv-sps-modal-container {
    position: relative;
    background: #fff;
    border-radius: 16px;
    width: 100%;
    max-width: 480px;
    margin: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: iv-modal-in 0.3s ease;
}

@keyframes iv-modal-in {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.iv-sps-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid #eee;
}

.iv-sps-modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.iv-sps-modal-close {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: #999;
    transition: color 0.2s ease;
    border-radius: 8px;
}

.iv-sps-modal-close:hover {
    color: #333;
    background: #f0f0f0;
}

.iv-sps-modal-body {
    padding: 24px;
}

.iv-sps-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid #eee;
    background: #f8f9fa;
    border-radius: 0 0 16px 16px;
}

/* Loading Overlay */
.iv-sps-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    z-index: 999999;
    display: none;
    align-items: center;
    justify-content: center;
}

.iv-sps-loading-overlay.active {
    display: flex;
}

.iv-sps-spinner {
    position: relative;
}

.iv-sps-spinner-ring {
    width: 48px;
    height: 48px;
    border: 4px solid #f0f0f0;
    border-top-color: #0073aa;
    border-radius: 50%;
    animation: iv-spin 0.8s linear infinite;
}

@keyframes iv-spin {
    to { transform: rotate(360deg); }
}

/* Toast Notifications */
.iv-sps-toast-container {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 999999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.iv-sps-toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: #333;
    color: #fff;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    animation: iv-toast-in 0.3s ease;
    max-width: 400px;
}

.iv-sps-toast.success {
    background: linear-gradient(135deg, #46b450 0%, #3a9a42 100%);
}

.iv-sps-toast.error {
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
}

.iv-sps-toast.warning {
    background: linear-gradient(135deg, #f0ad4e 0%, #ec971f 100%);
}

@keyframes iv-toast-in {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.iv-sps-toast.hiding {
    animation: iv-toast-out 0.3s ease forwards;
}

@keyframes iv-toast-out {
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

/* PDF Viewer Frontend */
#pdf-viewer-frontend {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    overflow: hidden;
}

#pdf-viewer-frontend .iv-sps-viewer-header {
    padding: 20px 24px;
}

#pdf-viewer-frontend .iv-sps-pdf-canvas-container {
    border-radius: 0;
}

/* Responsive */
@media screen and (max-width: 992px) {
    .iv-sps-content-wrapper {
        flex-direction: column;
    }
    
    .iv-sps-sidebar {
        width: 100%;
    }
    
    .iv-sps-month-list {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
    }
    
    .iv-sps-month-list li {
        border-bottom: none;
        border-right: 1px solid #f0f0f0;
    }
    
    .iv-sps-month-list li:nth-child(4n) {
        border-right: none;
    }
    
    .iv-sps-month-link {
        flex-direction: column;
        gap: 8px;
        padding: 16px 12px;
        text-align: center;
    }
}

@media screen and (max-width: 600px) {
    .iv-sps-frontend-container {
        padding: 15px;
    }
    
    .iv-sps-month-list {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .iv-sps-month-list li:nth-child(4n) {
        border-right: 1px solid #f0f0f0;
    }
    
    .iv-sps-month-list li:nth-child(3n) {
        border-right: none;
    }
    
    .iv-sps-invoice-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    
    .iv-sps-invoice-actions {
        width: 100%;
    }
    
    .iv-sps-invoice-actions .iv-sps-btn {
        flex: 1;
    }
    
    .iv-sps-toast-container {
        left: 15px;
        right: 15px;
        bottom: 15px;
    }
    
    .iv-sps-toast {
        max-width: 100%;
    }
}

/* ======================================
   PDF Iframe Viewer Styles
   ====================================== */

.iv-sps-pdf-canvas-container {
    position: relative;
    width: 100%;
    min-height: 500px;
    max-height: 70vh;
    background: #525659;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: auto;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 20px;
}

.iv-sps-pdf-canvas-container canvas {
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    background: white;
}

.iv-sps-pdf-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.95);
    z-index: 10;
}

.iv-sps-pdf-loading p {
    margin-top: 15px;
    color: #666;
}

.iv-sps-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #2271b1;
    border-radius: 50%;
    animation: iv-spin 1s linear infinite;
}

@keyframes iv-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.iv-sps-external-link {
    display: flex;
    justify-content: center;
}

.iv-sps-external-link a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

.iv-sps-external-link svg {
    flex-shrink: 0;
}

.iv-sps-viewer-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 4px 4px;
    flex-wrap: wrap;
    gap: 10px;
}

.iv-sps-pagination,
.iv-sps-zoom-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.iv-sps-page-info {
    min-width: 60px;
    text-align: center;
    font-size: 14px;
}

#pdf-zoom-level-frontend {
    min-width: 50px;
    text-align: center;
    font-size: 14px;
}

/* ======================================
   Escompte Badge Styles
   ====================================== */

.iv-sps-badge {
    display: inline-block;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 12px;
    vertical-align: middle;
    margin-left: 8px;
}

.iv-sps-badge-escompte {
    background-color: #fef3cd;
    color: #856404;
    border: 1px solid #ffc107;
}

.iv-sps-invoice-details h4 {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
}

/* ======================================
   Tabs Styles
   ====================================== */

.iv-sps-header {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 20px;
}

.iv-sps-tabs {
    display: flex;
    gap: 5px;
    border-bottom: 2px solid #e5e7eb;
    padding-bottom: 0;
}

.iv-sps-tab {
    padding: 10px 20px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #6b7280;
    transition: all 0.2s;
}

.iv-sps-tab:hover {
    color: #2271b1;
}

.iv-sps-tab.active {
    color: #2271b1;
    border-bottom-color: #2271b1;
}

.iv-sps-tab-content {
    display: none;
}

.iv-sps-tab-content.active {
    display: block;
}

/* ======================================
   History Styles
   ====================================== */

.iv-sps-history-filters {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    padding: 15px;
    background: #f9fafb;
    border-radius: 8px;
}

.iv-sps-history-filters .iv-sps-select {
    min-width: 180px;
}

.iv-sps-history-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.iv-sps-history-table thead {
    background: #f3f4f6;
}

.iv-sps-history-table th,
.iv-sps-history-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
}

.iv-sps-history-table th {
    font-weight: 600;
    color: #374151;
    font-size: 13px;
    text-transform: uppercase;
}

.iv-sps-history-table td {
    color: #4b5563;
    font-size: 14px;
}

.iv-sps-history-table tbody tr:hover {
    background: #f9fafb;
}

.iv-sps-history-name {
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.iv-sps-badge-validated {
    background-color: #d1fae5;
    color: #065f46;
    border: 1px solid #10b981;
}

.iv-sps-history-pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    padding: 15px;
    background: #f9fafb;
    border-radius: 8px;
}

.iv-sps-pagination-info {
    color: #6b7280;
    font-size: 14px;
}

.iv-sps-pagination-buttons {
    display: flex;
    gap: 10px;
}

.iv-sps-btn-small {
    padding: 6px 12px;
    font-size: 13px;
}

/* Responsive */
@media (max-width: 768px) {
    .iv-sps-history-table {
        display: block;
        overflow-x: auto;
    }
    
    .iv-sps-history-filters {
        flex-direction: column;
    }
    
    .iv-sps-tabs {
        flex-wrap: wrap;
    }
}

/* ======================================
   History Stats
   ====================================== */

.iv-sps-history-stats {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
}

.iv-sps-stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 40px;
    background: linear-gradient(135deg, #2271b1 0%, #135e96 100%);
    border-radius: 12px;
    color: #fff;
    box-shadow: 0 4px 15px rgba(34, 113, 177, 0.3);
}

.iv-sps-stat-number {
    font-size: 36px;
    font-weight: 700;
    line-height: 1;
}

.iv-sps-stat-label {
    font-size: 14px;
    opacity: 0.9;
    margin-top: 5px;
}

/* Fix for select text visibility */
.iv-sps-modal .iv-sps-select {
    color: #333 !important;
    background-color: #fff !important;
    -webkit-text-fill-color: #333 !important;
    opacity: 1 !important;
}

.iv-sps-modal .iv-sps-select option {
    color: #333 !important;
    background-color: #fff !important;
}

.iv-sps-modal .iv-sps-select:valid {
    color: #333 !important;
}

/* Ultra-force select text visibility */
#assign-user-frontend,
.iv-sps-modal select,
.iv-sps-modal .iv-sps-select,
select#assign-user-frontend {
    color: #333 !important;
    -webkit-text-fill-color: #333 !important;
    background-color: #fff !important;
    opacity: 1 !important;
}

#assign-user-frontend option,
.iv-sps-modal select option,
.iv-sps-modal .iv-sps-select option {
    color: #333 !important;
    background-color: #fff !important;
}

/* Override any theme styles */
body .iv-sps-modal select,
body #assign-user-frontend,
html body .iv-sps-modal .iv-sps-select {
    color: #333 !important;
    -webkit-text-fill-color: #333 !important;
}

/* ======================================
   Assigned Badge
   ====================================== */

.iv-sps-badge-assigned {
    background-color: #e3f2fd;
    color: #1565c0;
    border: 1px solid #2196f3;
}

.iv-sps-invoice-assigned {
    margin-top: 6px;
}

/* ======================================
   Date Filters and Export
   ====================================== */

.iv-sps-filter-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
}

.iv-sps-date-filters {
    display: flex;
    align-items: center;
    gap: 10px;
}

.iv-sps-date-filters label {
    font-weight: 500;
    color: #555;
    white-space: nowrap;
}

.iv-sps-date-input {
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    min-width: 150px;
}

.iv-sps-date-input:focus {
    outline: none;
    border-color: #2271b1;
    box-shadow: 0 0 0 2px rgba(34, 113, 177, 0.15);
}

.iv-sps-btn-success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #fff;
    border: none;
}

.iv-sps-btn-success:hover {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

@media (max-width: 768px) {
    .iv-sps-filter-row {
        flex-direction: column;
        align-items: stretch;
    }
    
    .iv-sps-date-filters {
        flex-wrap: wrap;
    }
    
    .iv-sps-date-input {
        min-width: 100%;
    }
}

/* ======================================
   Delete Button
   ====================================== */

.iv-sps-btn-danger {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: #fff;
    border: none;
    padding: 10px 14px;
    margin-left: 8px;
}

.iv-sps-btn-danger:hover {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.iv-sps-icon-trash {
    font-size: 16px;
}

.iv-sps-invoice-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ======================================
   Export Checkbox
   ====================================== */

.iv-sps-export-row {
    justify-content: space-between;
    margin-top: 10px;
    padding-top: 15px;
    border-top: 1px solid #eee;
}

.iv-sps-checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: 500;
    color: #333;
}

.iv-sps-checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #2271b1;
}

.iv-sps-checkbox-hint {
    font-weight: 400;
    color: #666;
    font-size: 13px;
}
