/* Enhanced Revision Page - 기존 스타일 통일 */

* {
  box-sizing: border-box;
}

.materials-page {
  background: #f8f9fa;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', sans-serif;
  overflow-x: auto;
  min-width: 1400px;
}

/* 헤더 */
.materials-header {
  background: white;
  border-bottom: 1px solid #e5e7eb;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.back-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: #6366f1;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.back-button:hover {
  background: #5558e3;
  transform: translateY(-1px);
}

.header-center {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* 메인 콘텐츠 */
.materials-content {
  padding: 24px;
}

/* 컨트롤 섹션 */
.control-section {
    background: white;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    border: 1px solid #e5e7eb;
}

.section-header h3 {
    margin: 0 0 16px 0;
    color: #1f2937;
    font-size: 18px;
    font-weight: 600;
}

.control-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    align-items: end;
}

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

.control-group label {
    font-weight: 600;
    color: #34495e;
    margin-bottom: 8px;
    font-size: 0.95em;
}

.control-group select {
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    background: white;
    color: #374151;
    transition: all 0.2s ease;
}

.control-group select:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.control-group select:disabled {
    background-color: #f9fafb;
    color: #9ca3af;
    cursor: not-allowed;
}

.btn-compare {
    padding: 8px 16px;
    background: #6366f1;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-compare:hover:not(:disabled) {
    background: #5558e3;
    transform: translateY(-1px);
}

.btn-compare:disabled {
    background: #9ca3af;
    cursor: not-allowed;
    transform: none;
}

/* 메인 콘텐츠 레이아웃 */
.revision-content {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 25px;
}

.content-left, .content-right {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

/* 비교 결과 */
.comparison-result {
    background: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    border: 1px solid #e5e7eb;
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e5e7eb;
}

.result-header h3 {
    margin: 0;
    color: #1f2937;
    font-size: 18px;
    font-weight: 600;
}

.btn-apply {
    padding: 8px 16px;
    background: #10b981;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

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

/* 비교 요약 */
.comparison-summary {
    margin-bottom: 30px;
}

.comparison-summary h3 {
    margin: 0 0 20px 0;
    color: #2c3e50;
    font-size: 1.2em;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.summary-card {
    padding: 20px;
    border-radius: 10px;
    border-left: 4px solid;
}

.summary-card.purchased {
    background: #e8f5e8;
    border-left-color: #27ae60;
}

.summary-card.unpurchased {
    background: #fff3cd;
    border-left-color: #ffc107;
}

.summary-card.changes {
    background: #e3f2fd;
    border-left-color: #2196f3;
}

.summary-card h4 {
    margin: 0 0 15px 0;
    font-size: 1.1em;
    color: #2c3e50;
}

.summary-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.stat-item {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.9em;
    font-weight: 600;
    background: white;
    color: #2c3e50;
    border: 1px solid #e1e8ed;
}

.stat-item.increase {
    background: #ffebee;
    color: #c62828;
    border-color: #ffcdd2;
}

.stat-item.decrease {
    background: #e8f5e8;
    color: #2e7d32;
    border-color: #c8e6c9;
}

.stat-item.new {
    background: #e3f2fd;
    color: #1565c0;
    border-color: #bbdefb;
}

.stat-item.deleted {
    background: #fce4ec;
    color: #ad1457;
    border-color: #f8bbd9;
}

/* 변경사항 상세 */
.change-details {
    margin-top: 20px;
}

.change-details h3 {
    margin: 0 0 20px 0;
    color: #2c3e50;
    font-size: 1.2em;
}

.change-section {
    margin-bottom: 25px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 10px;
}

.change-section h4 {
    margin: 0 0 15px 0;
    color: #2c3e50;
    font-size: 1.1em;
}

.change-category {
    margin-bottom: 20px;
}

.change-category h5 {
    margin: 0 0 12px 0;
    color: #34495e;
    font-size: 1em;
}

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

.material-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: white;
    border-radius: 8px;
    border-left: 3px solid #e1e8ed;
}

.change-category.additional-purchase .material-item {
    border-left-color: #e74c3c;
}

.change-category.excess-inventory .material-item {
    border-left-color: #f39c12;
}

.change-category.quantity-updated .material-item {
    border-left-color: #3498db;
}

.change-category.quantity-reduced .material-item {
    border-left-color: #95a5a6;
}

.change-category.new-materials .material-item {
    border-left-color: #27ae60;
}

.change-category.deleted-materials .material-item {
    border-left-color: #e74c3c;
}

.material-desc {
    flex: 1;
    font-weight: 500;
    color: #2c3e50;
}

.quantity-change, .quantity-info {
    font-weight: 600;
    color: #7f8c8d;
    font-size: 0.9em;
}

.reason {
    font-style: italic;
    color: #95a5a6;
    font-size: 0.85em;
}

/* PIPE 길이 요약 */
.pipe-length-summary {
    background: white;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.summary-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #ecf0f1;
}

.summary-header h3 {
    margin: 0;
    color: #2c3e50;
    font-size: 1.3em;
}

.btn-recalculate {
    padding: 8px 16px;
    background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.9em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-recalculate:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(243, 156, 18, 0.3);
}

.pipe-stats {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
}

.pipe-stats span {
    font-weight: 600;
    color: #2c3e50;
}

.pipe-lines {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.pipe-line {
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid;
    background: white;
    transition: all 0.2s ease;
}

.pipe-line:hover {
    transform: translateX(5px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.pipe-line.purchased {
    border-left-color: #27ae60;
    background: #e8f5e8;
}

.pipe-line.pending {
    border-left-color: #f39c12;
    background: #fff3cd;
}

.pipe-line.mixed {
    border-left-color: #e74c3c;
    background: #ffebee;
}

.line-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.drawing-line {
    font-weight: 600;
    color: #2c3e50;
    font-size: 1.05em;
}

.material-spec {
    font-size: 0.9em;
    color: #7f8c8d;
}

.line-stats {
    display: flex;
    gap: 15px;
    align-items: center;
}

.line-stats span {
    font-size: 0.9em;
    color: #34495e;
}

.status {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.8em;
    font-weight: 600;
}

.status.purchased {
    background: #d4edda;
    color: #155724;
}

.status.pending {
    background: #fff3cd;
    color: #856404;
}

.status.mixed {
    background: #f8d7da;
    color: #721c24;
}

/* 비교 이력 */
.comparison-history {
    background: white;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.comparison-history h3 {
    margin: 0 0 20px 0;
    color: #2c3e50;
    font-size: 1.3em;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.history-item {
    padding: 15px;
    border-radius: 8px;
    border: 2px solid;
    transition: all 0.2s ease;
}

.history-item.applied {
    border-color: #27ae60;
    background: #e8f5e8;
}

.history-item.pending {
    border-color: #f39c12;
    background: #fff3cd;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.comparison-date {
    font-weight: 600;
    color: #2c3e50;
    font-size: 0.9em;
}

.status.applied {
    background: #d4edda;
    color: #155724;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.8em;
    font-weight: 600;
}

.status.pending {
    background: #fff3cd;
    color: #856404;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.8em;
    font-weight: 600;
}

.history-summary {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 10px;
}

.history-summary span {
    font-size: 0.85em;
    color: #7f8c8d;
}

.btn-apply-small {
    padding: 6px 12px;
    background: linear-gradient(135deg, #27ae60 0%, #2ecc71 100%);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.8em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    align-self: flex-start;
}

.btn-apply-small:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(39, 174, 96, 0.3);
}

.no-history {
    text-align: center;
    color: #95a5a6;
    font-style: italic;
    padding: 40px 20px;
}

/* 반응형 디자인 */
@media (max-width: 1200px) {
    .revision-content {
        grid-template-columns: 1fr;
    }
    
    .control-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    }
}

@media (max-width: 768px) {
    .enhanced-revision-page {
        padding: 15px;
    }
    
    .page-header {
        padding: 15px;
    }
    
    .page-header h1 {
        font-size: 1.8em;
    }
    
    .revision-controls,
    .comparison-result,
    .pipe-length-summary,
    .comparison-history {
        padding: 20px;
    }
    
    .control-grid {
        grid-template-columns: 1fr;
    }
    
    .summary-grid {
        grid-template-columns: 1fr;
    }
    
    .line-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }
    
    .line-stats {
        flex-wrap: wrap;
        gap: 10px;
    }
    
    .material-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
}

/* 카테고리별 자재 관리 섹션 */
.category-materials-section {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    padding: 24px;
    margin-bottom: 24px;
    border: 1px solid #e2e8f0;
}

.category-materials-section h3 {
    margin: 0 0 20px 0;
    font-size: 18px;
    font-weight: 600;
    color: #1e293b;
}

.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
}

.category-card {
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 20px;
    transition: all 0.3s ease;
    position: relative;
}

.category-card:hover {
    border-color: #6366f1;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.15);
    transform: translateY(-2px);
}

.category-card.has-revisions {
    background: linear-gradient(135deg, #fef3c7 0%, #fbbf24 100%);
    border-color: #f59e0b;
}

.category-card.has-revisions:hover {
    border-color: #d97706;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.25);
}

.category-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.category-icon {
    font-size: 24px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.category-info h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #1e293b;
}

.category-desc {
    font-size: 14px;
    color: #64748b;
}

.category-stats {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.category-stats .stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 12px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    min-width: 60px;
}

.category-stats .stat-item.revision {
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    color: white;
}

.category-stats .stat-item.inventory {
    background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 100%);
    color: white;
}

.category-stats .stat-label {
    font-size: 12px;
    font-weight: 500;
    margin-bottom: 2px;
}

.category-stats .stat-value {
    font-size: 18px;
    font-weight: 700;
}

.empty-category {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #9ca3af;
    font-size: 14px;
    font-style: italic;
}

/* 카테고리 카드 반응형 */
@media (max-width: 768px) {
    .category-grid {
        grid-template-columns: 1fr;
    }
    
    .category-stats {
        justify-content: center;
    }
}
