/**
 * main-enhanced.css v2.5
 * Enhanced styles for ProstyPrzetarg
 * 
 * New features:
 * - Color-coded deadline system
 * - Enhanced tender cards
 * - 70% modal
 * - Calendar button states
 * - Animations
 */

/* ==========================================
   DEADLINE COLOR SYSTEM
   ========================================== */

/* Deadline badge in cards */
.deadline-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
}

.deadline-icon {
    font-size: 18px;
}

.deadline-text {
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Pulse animation for critical deadlines */
@keyframes deadline-pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(244, 67, 54, 0.4);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(244, 67, 54, 0);
    }
}

/* Unknown deadline */
.deadline-unknown {
    background: #F5F5F5;
    border: 2px solid #BDBDBD;
    color: #757575;
}

/* ==========================================
   ENHANCED TENDER CARDS
   ========================================== */

.tender-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: all 0.2s ease-in-out;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.tender-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.12);
}

/* Card Header */
.tender-card-header {
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #f0f0f0;
    background: #fafafa;
}

.card-actions {
    display: flex;
    gap: 8px;
}

/* Card Body */
.tender-card-body {
    padding: 20px;
    flex: 1;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.tender-authority {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #64748b;
    font-size: 14px;
}

.tender-authority i {
    color: #3b82f6;
}

.tender-title {
    font-size: 18px;
    font-weight: 600;
    color: #1e293b;
    line-height: 1.4;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.tender-category {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #64748b;
}

.tender-category i {
    color: #10b981;
}

.tender-cpv-codes {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.cpv-badge {
    background: #f1f5f9;
    color: #475569;
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    font-family: 'Courier New', monospace;
}

.cpv-badge.cpv-none {
    background: #fee;
    color: #c62828;
}

.tender-meta {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-top: 12px;
    border-top: 1px solid #f0f0f0;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.meta-item i {
    color: #3b82f6;
    width: 16px;
}

.meta-label {
    color: #64748b;
    font-weight: 500;
}

.meta-value {
    color: #1e293b;
    font-weight: 600;
}

/* ==========================================
   CALENDAR BUTTON STATES
   ========================================== */

.calendar-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 2px solid #3b82f6;
    background: white;
    color: #3b82f6;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.calendar-btn:hover:not(:disabled) {
    background: #eff6ff;
    transform: translateY(-1px);
}

.calendar-btn:active:not(:disabled) {
    transform: translateY(0);
}

/* Loading state */
.calendar-btn-loading {
    border-color: #94a3b8;
    color: #64748b;
    cursor: wait;
    opacity: 0.8;
}

.calendar-btn-loading i {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Success state */
.calendar-btn-success {
    border-color: #10b981;
    background: #d1fae5;
    color: #059669;
    cursor: default;
}

/* Added state (in calendar) */
.calendar-btn-added {
    border-color: #10b981;
    background: #10b981;
    color: white;
}

.calendar-btn-added:hover {
    background: #059669;
    border-color: #059669;
}

/* Error state */
.calendar-btn-error {
    border-color: #ef4444;
    background: #fee;
    color: #dc2626;
}

.calendar-btn-error:hover {
    background: #fecaca;
}

/* ==========================================
   ENHANCED MODAL (70% VIEWPORT)
   ========================================== */

#tenderModal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    backdrop-filter: blur(4px);
}

#tenderModal.show {
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: white;
    border-radius: 16px;
    width: 70vw;
    max-width: 1400px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(40px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    padding: 24px 32px;
    border-bottom: 2px solid #f1f5f9;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-size: 24px;
    font-weight: 700;
    color: #1e293b;
    margin: 0;
    flex: 1;
    padding-right: 20px;
}

.modal-close {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: #f1f5f9;
    color: #64748b;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: #e2e8f0;
    color: #1e293b;
}

.modal-body {
    padding: 32px;
    overflow-y: auto;
    flex: 1;
}

/* Enhanced Modal Content */
.tender-detail-enhanced {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Deadline Banner */
.detail-deadline-banner {
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 8px;
}

.deadline-banner-content {
    display: flex;
    align-items: center;
    gap: 16px;
}

.deadline-icon-large {
    font-size: 48px;
}

.deadline-info {
    flex: 1;
}

.deadline-status {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 4px;
}

.deadline-description {
    font-size: 14px;
    opacity: 0.8;
}

/* Actions Bar */
.detail-actions-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 16px;
    background: #f8fafc;
    border-radius: 12px;
}

.action-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: 2px solid #e2e8f0;
    background: white;
    color: #475569;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.action-btn:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    transform: translateY(-1px);
}

.action-btn-calendar {
    border-color: #3b82f6;
    color: #3b82f6;
}

.action-btn-calendar:hover {
    background: #eff6ff;
}

.action-btn-calendar-added {
    border-color: #10b981;
    background: #10b981;
    color: white;
}

.action-btn-calendar-added:hover {
    background: #059669;
}

.action-btn-external {
    border-color: #8b5cf6;
    color: #8b5cf6;
}

.action-btn-external:hover {
    background: #f5f3ff;
}

.action-btn-share {
    border-color: #06b6d4;
    color: #06b6d4;
}

.action-btn-share:hover {
    background: #ecfeff;
}

.action-btn-print {
    border-color: #64748b;
    color: #64748b;
}

.action-btn-print:hover {
    background: #f8fafc;
}

/* Content Grid */
.detail-content-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

.detail-section {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 20px;
    transition: all 0.2s;
}

.detail-section:hover {
    border-color: #cbd5e1;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.detail-section-full {
    grid-column: 1 / -1;
}

.section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    font-weight: 600;
    color: #1e293b;
    margin: 0 0 16px 0;
    padding-bottom: 12px;
    border-bottom: 2px solid #f1f5f9;
}

.section-title i {
    color: #3b82f6;
}

.section-content {
    color: #475569;
    font-size: 14px;
    line-height: 1.6;
}

/* Authority Section */
.authority-name {
    font-size: 16px;
    font-weight: 600;
    color: #1e293b;
    margin: 0 0 12px 0;
}

.authority-location,
.authority-address,
.authority-type {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 8px 0;
    color: #64748b;
}

/* Timeline */
.timeline-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #f1f5f9;
}

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

.timeline-label {
    color: #64748b;
    font-weight: 500;
}

.timeline-value {
    color: #1e293b;
    font-weight: 600;
}

.timeline-deadline {
    background: #eff6ff;
    padding: 12px;
    border-radius: 8px;
    border: none;
}

.timeline-countdown {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    background: #fef3c7;
    color: #92400e;
    border-radius: 8px;
    font-weight: 500;
    margin-top: 8px;
}

/* CPV List Enhanced */
.cpv-list-enhanced {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cpv-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    background: #f8fafc;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.cpv-code {
    font-family: 'Courier New', monospace;
    font-weight: 600;
    color: #3b82f6;
}

.cpv-name {
    color: #64748b;
    font-size: 13px;
}

/* Value Section */
.value-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #f1f5f9;
}

.value-label {
    color: #64748b;
    font-weight: 500;
}

.value-amount {
    font-size: 18px;
    font-weight: 700;
    color: #10b981;
}

.funding-info {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    background: #f0fdf4;
    border-radius: 8px;
    color: #166534;
    font-size: 13px;
    margin-top: 12px;
}

/* Location Section */
.location-region,
.location-province {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
}

/* Order Type */
.order-type,
.notice-type {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
}

/* Description */
.tender-description-full {
    line-height: 1.8;
    color: #475569;
    white-space: pre-wrap;
}

/* Info Grid */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.info-label {
    color: #64748b;
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.info-value {
    color: #1e293b;
    font-weight: 600;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 13px;
}

.status-active {
    background: #d1fae5;
    color: #059669;
}

.status-expired {
    background: #fee;
    color: #dc2626;
}

.no-data {
    color: #94a3b8;
    font-style: italic;
}

/* ==========================================
   RESPONSIVE DESIGN
   ========================================== */

@media (max-width: 1200px) {
    .modal-content {
        width: 85vw;
    }
}

@media (max-width: 768px) {
    .modal-content {
        width: 95vw;
        max-height: 95vh;
    }
    
    .modal-header {
        padding: 16px 20px;
    }
    
    .modal-title {
        font-size: 18px;
    }
    
    .modal-body {
        padding: 20px;
    }
    
    .detail-content-grid {
        grid-template-columns: 1fr;
    }
    
    .tender-card-header {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }
    
    .card-actions {
        width: 100%;
        justify-content: flex-end;
    }
    
    .calendar-btn {
        font-size: 12px;
        padding: 6px 12px;
    }
    
    .deadline-badge {
        font-size: 12px;
        padding: 6px 12px;
    }
    
    .detail-actions-bar {
        flex-direction: column;
    }
    
    .action-btn {
        width: 100%;
        justify-content: center;
    }
}

/* ==========================================
   LOADING STATES
   ========================================== */

.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: #64748b;
    font-size: 16px;
}

.loading i {
    margin-right: 12px;
}

/* ==========================================
   PRINT STYLES
   ========================================== */

@media print {
    .tender-card-header,
    .card-actions,
    .detail-actions-bar {
        display: none !important;
    }
    
    .modal-content {
        box-shadow: none;
        width: 100%;
        max-height: none;
    }
    
    .detail-deadline-banner {
        border: 1px solid #000;
    }
}
