/* Steel Coil Cutting System - Main Stylesheet */

/* -----------------------------------------------------------------------------
   Design tokens (additive)
   NOTE: We keep existing styles unchanged; these tokens are for incremental UI
   refactors and new components. Do not remove without migrating usages.
----------------------------------------------------------------------------- */
:root {
    /* Colors */
    --sc-bg: #f5f5f5;
    --sc-surface: #ffffff;
    --sc-text: #333333;
    --sc-text-muted: #6b7280;
    --sc-border: #dee2e6;
    --sc-border-soft: #e5e7eb;

    --sc-primary: #2c3e50;
    --sc-primary-hover: #1a252f;
    --sc-secondary: #95a5a6;
    --sc-secondary-hover: #7f8c8d;
    --sc-danger: #e74c3c;
    --sc-danger-hover: #c0392b;
    --sc-success: #27ae60;
    --sc-success-hover: #229954;

    --sc-info: #2c3e50;
    --sc-warning: #b26a00;

    /* Spacing */
    --sc-space-1: 0.25rem;
    --sc-space-2: 0.5rem;
    --sc-space-3: 0.75rem;
    --sc-space-4: 1rem;
    --sc-space-6: 1.5rem;
    --sc-space-8: 2rem;

    /* Radius / shadow */
    --sc-radius-sm: 4px;
    --sc-radius-md: 6px;
    --sc-shadow-1: 0 2px 4px rgba(0,0,0,0.1);
}

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

body {
    font-family: Arial, sans-serif;
    line-height: 1.35;
    font-size: 13px;
    color: #333;
    background-color: #f5f5f5;
}

/* Header */
header {
    background-color: #2c3e50;
    color: white;
    padding: 0.6rem 1.25rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    font-size: 1.15rem;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Navigation */
nav {
    background-color: #34495e;
    padding: 0;
}

.nav-menu {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    margin: 0;
    padding: 0;
}

.nav-menu li {
    margin: 0;
}

.nav-link {
    display: block;
    padding: 0.55rem 0.9rem;
    color: white;
    text-decoration: none;
    transition: background-color 0.3s;
}

.nav-link:hover {
    background-color: #2c3e50;
}

.nav-link.active {
    background-color: #1a252f;
}

/* Main Content */
main {
    max-width: 1400px;
    margin: 1rem auto;
    padding: 0 1rem;
}

/* Flash Messages */
.flash-messages {
    margin-bottom: 1rem;
}

.flash {
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.5rem;
    border-radius: 4px;
}

.flash-success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.flash-error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.flash-info {
    background-color: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* Buttons */
.btn {
    padding: 0.35rem 0.7rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    font-size: 0.85rem;
    transition: background-color 0.3s;
}

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

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

.btn-secondary {
    background-color: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background-color: #7f8c8d;
}

.btn-danger {
    background-color: #e74c3c;
    color: white;
}

.btn-danger:hover {
    background-color: #c0392b;
}

.btn-success {
    background-color: #27ae60;
    color: white;
}

.btn-success:hover {
    background-color: #229954;
}

.btn-warning {
    background-color: #f39c12;
    color: white;
}

.btn-warning:hover {
    background-color: #e67e22;
}

.btn-logout {
    background-color: #e74c3c;
    color: white;
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
}

.btn-logout:hover {
    background-color: #c0392b;
}

/* Tables */
.table-container {
    background: white;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    overflow-x: auto;
    margin-bottom: 2rem;
}

.table-controls {
    padding: 0.6rem 0.75rem;
    background-color: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: center;
}

.table-controls input[type="search"],
.table-controls select {
    padding: 0.35rem 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
}

table {
    width: 100%;
    border-collapse: collapse;
}

table th,
table td {
    padding: 0.3rem 0.4rem;
    text-align: left;
    border-bottom: 1px solid #dee2e6;
    font-size: 0.75rem;
}

table th {
    background-color: #f8f9fa;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    font-size: 0.75rem;
}

table th:hover {
    background-color: #e9ecef;
}

table th.sort-asc::after {
    content: " ▲";
    font-size: 0.8em;
}

table th.sort-desc::after {
    content: " ▼";
    font-size: 0.8em;
}

table tr:hover {
    background-color: #f8f9fa;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 0.75rem;
    background-color: #f8f9fa;
}

.pagination button {
    padding: 0.35rem 0.55rem;
    border: 1px solid #ddd;
    background: white;
    cursor: pointer;
    border-radius: 4px;
}

.pagination button:hover:not(:disabled) {
    background-color: #e9ecef;
}

.pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination button.active {
    background-color: #3498db;
    color: white;
    border-color: #3498db;
}

/* Forms */
.form-container {
    background: white;
    padding: 1.25rem;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    max-width: 600px;
    margin: 1rem auto;
}

.form-group {
    margin-bottom: 0.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.25rem;
    font-weight: 600;
    font-size: 0.85rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.35rem 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.95rem;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #3498db;
}

.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 0.9rem;
}

/* Login Page */
.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-container {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 400px;
}

.login-container h1 {
    text-align: center;
    color: #2c3e50;
    margin-bottom: 0.5rem;
}

.login-container h2 {
    text-align: center;
    color: #7f8c8d;
    margin-bottom: 2rem;
    font-size: 1.05rem;
}

.login-form {
    margin-top: 2rem;
}

.login-form .form-group-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.login-form .form-group-checkbox input[type="checkbox"] {
    width: auto;
    margin: 0;
}

.login-form .form-group-checkbox label {
    margin-bottom: 0;
    font-weight: normal;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 1rem;
    border-radius: 4px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #dee2e6;
}

.modal-header h3 {
    margin: 0;
}

.close {
    font-size: 2rem;
    font-weight: bold;
    cursor: pointer;
    color: #999;
}

.close:hover {
    color: #333;
}

/* ============================================================================
   Alert Modal Styles - Standardized alert/confirmation system
   ============================================================================ */

/* Alert Modal Container */
.sc-alert-modal {
    max-width: 450px;
    padding: 0;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

/* Alert Header - Type-based colors */
.sc-alert-header {
    padding: 0.75rem 1rem;
    color: white;
    border-radius: 4px 4px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0;
    border-bottom: none;
}

/* Info, Warning, and Confirmation all use primary blue */
.sc-alert-header.sc-alert-info,
.sc-alert-header.sc-alert-warning,
.sc-alert-header.sc-alert-confirm {
    background: var(--sc-primary);
}

.sc-alert-header.sc-alert-error {
    background: #e74c3c;
}

.sc-alert-header.sc-alert-success {
    background: #27ae60;
}

.sc-alert-header .close {
    color: white;
    font-size: 24px;
    line-height: 1;
}

.sc-alert-header .close:hover {
    color: rgba(255, 255, 255, 0.8);
}

/* Alert Title */
.sc-alert-title {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.sc-alert-icon {
    font-size: 1.1rem;
    line-height: 1;
}

.sc-alert-title-text {
    flex: 1;
}

/* Alert Body */
.sc-alert-body {
    padding: 1rem;
    font-size: 0.85rem;
    line-height: 1.5;
    color: #333;
}

.sc-alert-message {
    margin: 0;
    white-space: pre-line; /* Preserve line breaks in messages */
    word-wrap: break-word;
}

/* Alert Footer */
.sc-alert-footer {
    padding: 0.75rem 1rem;
    border-top: 1px solid #dee2e6;
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    background: #f8f9fa;
    border-radius: 0 0 4px 4px;
}

.sc-alert-ok-btn,
.sc-alert-cancel-btn {
    min-width: 70px;
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.sc-alert-ok-btn {
    background: var(--sc-primary);
    color: white;
}

.sc-alert-ok-btn:hover {
    background: var(--sc-primary-hover);
}

.sc-alert-cancel-btn {
    background: #95a5a6;
    color: white;
}

.sc-alert-cancel-btn:hover {
    background: #7f8c8d;
}

/* Responsive Design */
@media (max-width: 768px) {
    .sc-alert-modal {
        width: 95%;
        margin: 10% auto;
    }

    .sc-alert-header {
        padding: 0.6rem 0.8rem;
    }

    .sc-alert-title {
        font-size: 0.9rem;
    }

    .sc-alert-icon {
        font-size: 1rem;
    }

    .sc-alert-body {
        padding: 0.8rem;
        font-size: 0.8rem;
    }

    .sc-alert-footer {
        padding: 0.6rem 0.8rem;
        flex-direction: column-reverse;
    }

    .sc-alert-ok-btn,
    .sc-alert-cancel-btn {
        width: 100%;
    }
}

/* Animation for modal appearance */
.sc-alert-modal {
    animation: fadeIn 0.2s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Footer */
footer {
    text-align: center;
    padding: 1rem;
    background-color: #2c3e50;
    color: white;
    margin-top: 3rem;
}

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

.page-header h2 {
    margin: 0;
    color: #2c3e50;
    font-size: 1.15rem;
}

.page-header p {
    margin: 0.5rem 0 0 0;
    color: #7f8c8d;
    font-size: 0.9rem;
}

/* Recovery Badges */
.recovery-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.85rem;
}

.recovery-high {
    background-color: #d4edda;
    color: #155724;
}

.recovery-medium {
    background-color: #fff3cd;
    color: #856404;
}

.recovery-low {
    background-color: #f8d7da;
    color: #721c24;
}

/* Utility Classes */
.text-center {
    text-align: center;
}

.text-muted {
    color: var(--sc-text-muted);
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

.hidden {
    display: none;
}

/* -----------------------------------------------------------------------------
   Additive component classes (used in templates but previously missing)
   These are intentionally conservative to avoid breaking existing pages.
----------------------------------------------------------------------------- */
.card {
    background: var(--sc-surface);
    border: 1px solid var(--sc-border-soft);
    border-radius: var(--sc-radius-sm);
    box-shadow: var(--sc-shadow-1);
}

.dashboard-section {
    margin-bottom: 2rem;
}

.filters {
    background: #f5f5f5;
    border: 1px solid var(--sc-border-soft);
    border-radius: var(--sc-radius-sm);
    padding: 1rem;
}

/* Badges (generic) */
.badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    border: 1px solid var(--sc-border-soft);
    background: var(--sc-surface);
    color: var(--sc-text);
}

.badge-primary {
    background: #e7f3ff;
    border-color: #cfe6ff;
    color: #0b3d91;
}

.badge-secondary {
    background: #f3f4f6;
    border-color: #e5e7eb;
    color: #374151;
}

.badge-warning {
    background: #fff8e6;
    border-color: #ffe0a3;
    color: #6b3a00;
}

.badge-info {
    background: #e6f6ff;
    border-color: #bfe9ff;
    color: #004a6e;
}

.badge-success {
    background: #f0faf2;
    border-color: #cdeed6;
    color: #155724;
}

.badge-danger {
    background: #fff1f0;
    border-color: #ffd0cc;
    color: #7a1c14;
}

/* Status badge - Standardized across all pages */
.status-badge {
    display: inline-block;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    border: 1px solid transparent;
    text-transform: capitalize;
    white-space: nowrap;
}

/* Base text color with complementary highlight background */
.status-stock {
    background: #e8f5e9;
    border-color: #c8e6c9;
    color: #2e7d32;
}

.status-cutting {
    background: #e3f2fd;
    border-color: #bbdefb;
    color: #1565c0;
}

.status-closed {
    background: #f5f5f5;
    border-color: #e0e0e0;
    color: #616161;
}

.status-dispatched {
    background: #fce4ec;
    border-color: #f8bbd0;
    color: #c2185b;
}

.status-planned {
    background: #e1f5fe;
    border-color: #b3e5fc;
    color: #0277bd;
}

.status-running {
    background: #e3f2fd;
    border-color: #bbdefb;
    color: #1565c0;
}

.status-done {
    background: #e8f5e9;
    border-color: #c8e6c9;
    color: #2e7d32;
}

/* Type badges (for Input Log and Dispatch Log) - matching status badge style */
.status-coil {
    background: #e3f2fd;
    border-color: #bbdefb;
    color: #1565c0;
}

.status-circle {
    background: #e8f5e9;
    border-color: #c8e6c9;
    color: #2e7d32;
}

.status-BLANK {
    background: #ede7f6;
    border-color: #d1c4e9;
    color: #4527a0;
}

.status-scrap_jaal {
    background: #fff3e0;
    border-color: #ffe0b2;
    color: #e65100;
}

/* Button sizing/variants used across templates */
.btn-sm {
    padding: 0.25rem 0.45rem;
    font-size: 0.8rem;
    margin: 0 0.2rem;
}

.btn-info {
    background-color: var(--sc-primary);
    color: white;
}

.btn-info:hover {
    background-color: var(--sc-primary-hover);
}

/* Split layout (inline add form + list) */
.layout-split {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.panel {
    background: var(--sc-surface);
    border: 1px solid var(--sc-border-soft);
    border-radius: var(--sc-radius-sm);
    box-shadow: var(--sc-shadow-1);
    padding: 0.75rem;
}

.panel-form.panel {
    padding: 0.57rem; /* 5% more reduction from 0.6rem */
}

.panel-title {
    margin: 0 0 0.6rem 0;
    font-size: 1rem;
    color: #2c3e50;
}

.panel-form .panel-title {
    margin-bottom: 0.46rem; /* 5% more reduction from 0.48rem */
    font-size: 0.86rem; /* 5% more reduction from 0.9rem */
}

.panel-hint {
    margin-top: 0.5rem;
    margin-bottom: 0;
    font-size: 0.85rem;
}

.panel-form {
    flex: 0 0 360px;
}

.panel-table {
    flex: 1;
    min-width: 0; /* allow table container to shrink without overflow issues */
}

/* Extra compact form density for inline entry panels (Upcoming Coils) */
.panel-form .form-group {
    margin-bottom: 0.42rem; /* 5% more reduction from 0.44rem */
}

.panel-form .form-group label {
    margin-bottom: 0.19rem; /* 5% more reduction from 0.2rem */
    font-size: 0.71rem; /* 5% more reduction from 0.75rem */
}

.panel-form .form-group input,
.panel-form .form-group select,
.panel-form .form-group textarea {
    padding: 0.21rem 0.34rem; /* 5% more reduction from 0.22rem 0.36rem */
    font-size: 0.76rem; /* 5% more reduction from 0.8rem */
}

.panel-form textarea {
    min-height: 43px; /* 5% more reduction from 45px */
    resize: vertical;
}

.panel-form .form-actions {
    margin-top: 0.46rem; /* 5% more reduction from 0.48rem */
    gap: 0.38rem; /* 5% more reduction from 0.4rem */
}

.panel-form .btn {
    padding: 0.21rem 0.42rem; /* 5% more reduction from 0.22rem 0.44rem */
    font-size: 0.68rem; /* 5% more reduction from 0.72rem */
}

.panel-form {
    flex: 0 0 265px; /* 5% more reduction from 270px */
}

@media (max-width: 1000px) {
    .layout-split {
        flex-direction: column;
    }
    .panel-form {
        flex: 1 1 auto;
    }
}

/* Responsive */
@media (max-width: 768px) {
    .nav-menu {
        flex-direction: column;
    }
    
    .table-controls {
        flex-direction: column;
    }
    
    .table-controls input,
    .table-controls select {
        width: 100%;
    }
}

/* Notes cell styling (shared across all tables) */
.notes-cell {
    font-size: 0.75rem;
    max-width: 120px;
    display: inline-block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-xs {
    padding: 0.1rem 0.3rem;
    font-size: 0.7rem;
    margin: 0;
}

/* Alert Modal Styles */
.sc-alert-modal {
    max-width: 500px;
    padding: 0;
}

.sc-alert-header {
    padding: 1rem 1.5rem;
    color: white;
    border-radius: 8px 8px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Info, Warning, and Confirmation all use primary blue */
.sc-alert-header.sc-alert-info,
.sc-alert-header.sc-alert-warning,
.sc-alert-header.sc-alert-confirm {
    background: var(--sc-primary);
}

.sc-alert-header.sc-alert-error {
    background: #e74c3c;
}

.sc-alert-header.sc-alert-success {
    background: #27ae60;
}

.sc-alert-title {
    margin: 0;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sc-alert-icon {
    font-size: 1.3rem;
}

.sc-alert-body {
    padding: 1.5rem;
    font-size: 0.9rem;
    line-height: 1.6;
}

.sc-alert-message {
    margin: 0;
    white-space: pre-line; /* Preserve line breaks */
    word-wrap: break-word;
}

.sc-alert-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid #dee2e6;
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    background: #f8f9fa;
    border-radius: 0 0 8px 8px;
}

.sc-alert-footer .btn {
    min-width: 80px;
}

/* Responsive alert modal */
@media (max-width: 768px) {
    .sc-alert-modal {
        width: 95%;
        margin: 10% auto;
    }
    
    .sc-alert-header {
        padding: 0.75rem 1rem;
    }
    
    .sc-alert-title {
        font-size: 1rem;
    }
    
    .sc-alert-body {
        padding: 1rem;
        font-size: 0.85rem;
    }
    
    .sc-alert-footer {
        padding: 0.75rem 1rem;
        flex-direction: column-reverse;
    }
    
    .sc-alert-footer .btn {
        width: 100%;
    }
}

.btn-link {
    background: none;
    border: none;
    color: var(--sc-primary);
    text-decoration: underline;
    cursor: pointer;
}

.btn-link:hover {
    color: var(--sc-primary-hover);
}

/* Form Controls */
.form-select {
    width: 100%;
    padding: 0.4rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.85rem;
    background-color: white;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-select:focus {
    outline: none;
    border-color: var(--sc-primary);
    box-shadow: 0 0 0 0.2rem rgba(44, 62, 80, 0.25);
}

.form-select:hover {
    border-color: #bbb;
}

