/* ============================================================
   TECHEV — Maintenance & Reliability Style Sheet
   ============================================================ */

:root {
    --twine:        #c0a463;
    --laurel:       #6a9a75;
    --cutty-sark:   #54857a;
    --tarawera:     #0a425c;
    --matisse:      #177d90;
    --teal-blue:    #043c54;
    --flamingo:     #ec642c;
    --sea-green:    #2f7c46;
    --tarawera-dark:#0c3c54;
    --teal-blue-dark:#044454;

    --primary:      var(--matisse);
    --primary-dark: var(--teal-blue);
    --secondary:    var(--cutty-sark);
    --success:      var(--sea-green);
    --warning:      var(--twine);
    --danger:       var(--flamingo);
    --info:         var(--laurel);
    --dark:         var(--tarawera);
    --light:        #f8fafc;
    --white:        #ffffff;
    --border:       #e2e8f0;
    --shadow:       0 2px 8px rgba(0,0,0,0.08);
    --shadow-lg:    0 4px 16px rgba(0,0,0,0.12);
    --radius:       6px;
    --radius-lg:    8px;
    --transition:   all 0.2s ease;
    --gradient-primary: linear-gradient(135deg, var(--primary) 0%, var(--teal-blue) 100%);
}

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

body {
    font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
    background: var(--gradient-primary);
    min-height: 100vh;
    padding: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--dark);
    overflow: hidden;
}

/* ---- Logo ---- */
.logo {
    position: fixed; top: -50px; left: 80px;
    width: 300px; height: 300px;
    z-index: 9999; pointer-events: none;
    background-size: contain; background-repeat: no-repeat; background-position: center;
}
.logo2 {
    position: fixed; top: -99px; right: 10px;
    width: 400px; height: 400px;
    z-index: 9999; pointer-events: none;
    background-size: contain; background-repeat: no-repeat; background-position: center;
}

/* ---- Container ---- */
.container {
    width: 98vw; height: 95vh; max-width: 100%;
    margin: 1vh auto;
    background: rgba(255,255,255,0.95);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(10px);
    display: flex; flex-direction: column;
    overflow: hidden;
    border: 2px solid rgba(255,255,255,0.2);
}

/* ---- Header ---- */
.header {
    background: var(--gradient-primary);
    color: var(--white);
    padding: 4px 20px;
    text-align: center;
    border-radius: 12px 12px 0 0;
    position: relative; overflow: hidden;
    border-bottom: 2px solid var(--primary-dark);
    flex-shrink: 0;
}
.header::before {
    content: '';
    position: absolute; inset: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.1'%3E%3Cpath d='m36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E") repeat;
    opacity: 0.3;
}
.header-content {
    display: flex; align-items: center; gap: 20px;
    position: relative; z-index: 2;
}
.header-text { flex: 1; }
.header h1 {
    font-size: 1.8em; font-weight: 700; margin: 0;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}
.header p { font-size: 1em; opacity: 0.9; font-weight: 500; margin: 0; }

/* ---- Main Menu ---- */
.main-menu {
    background: var(--light);
    padding: 10px;
    border-bottom: 2px solid var(--primary);
    display: flex; justify-content: center; align-items: center;
    gap: 10px; flex-wrap: wrap; flex-shrink: 0;
}
.main-menu-buttons { display: flex; gap: 10px; flex-wrap: wrap; }
.main-menu-btn {
    padding: 8px 20px;
    border: 2px solid var(--primary);
    background: var(--white);
    color: var(--primary);
    border-radius: var(--radius);
    font-weight: 600; cursor: pointer;
    transition: var(--transition);
    font-size: 14px; text-align: center;
    min-width: 220px;
    font-family: inherit;
    box-shadow: 0 2px 6px rgba(23,125,144,0.1);
}
.main-menu-btn:hover {
    background: var(--primary);
    color: var(--white);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(23,125,144,0.25);
}
.main-menu-btn.active {
    background: var(--gradient-primary);
    color: var(--white);
    border-color: var(--primary-dark);
    box-shadow: 0 4px 12px rgba(23,125,144,0.3);
}

/* ---- Plant Selector Badge ---- */
.plant-badge {
    padding: 6px 16px;
    background: var(--gradient-primary);
    color: white;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    border: 2px solid rgba(255,255,255,0.3);
    white-space: nowrap;
    transition: var(--transition);
}
.plant-badge:hover { opacity: 0.85; }

/* ---- Content Areas ---- */
.main-content {
    flex: 1; overflow: auto; display: none;
    flex-direction: column;
}
.main-content.active { display: flex; }

/* ---- Sub Menu ---- */
.sub-menu {
    padding: 10px 20px;
    background: var(--light);
    border-bottom: 1px solid var(--border);
    display: flex; flex-wrap: wrap;
    align-items: center; gap: 10px;
    flex-shrink: 0;
}

/* ---- Buttons ---- */
.btn {
    padding: 8px 16px; border: none; border-radius: 4px;
    cursor: pointer; font-size: 12px; font-weight: 600;
    color: white; transition: all 0.2s; font-family: inherit;
}
.btn-success { background: linear-gradient(135deg, #2ecc71 0%, #27ae60 100%); }
.btn-info    { background: linear-gradient(135deg, #3498db 0%, #2980b9 100%); }
.btn-warning { background: linear-gradient(135deg, #f1c40f 0%, #f39c12 100%); color: #333; }
.btn-secondary{ background: linear-gradient(135deg, #95a5a6 0%, #7f8c8d 100%); }
.btn-danger  { background: var(--danger); }
.btn-small   { padding: 2px 6px; font-size: 10px; border: none; border-radius: 4px; cursor: pointer; color: white; margin: 0 1px; }

/* ---- Action Dropdown ---- */
.action-dropdown {
    background: var(--light) !important;
    border: 2px solid var(--info) !important;
    min-width: 200px; padding: 6px;
    border-radius: 4px; color: var(--dark);
    font-family: inherit; font-size: 11px;
}
.action-dropdown:focus {
    border-color: var(--info) !important;
    box-shadow: 0 0 0 2px rgba(106,154,117,0.1) !important;
    outline: none;
}

/* ---- Table ---- */
.table-container {
    overflow: auto; border-radius: var(--radius-lg);
    max-height: 100%; border: 2px solid var(--border);
    background: var(--white); flex: 1;
}
.interactive-table {
    width: 100%; border-collapse: collapse;
    font-size: 11px; background: var(--white);
}
.interactive-table th,
.interactive-table td {
    padding: 8px 10px; text-align: left;
    border: 1px solid var(--border);
    vertical-align: middle; color: var(--dark);
}
.interactive-table th {
    font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.3px; font-size: 10px;
    position: sticky; top: 0; z-index: 10;
    background: var(--primary-dark); color: white;
}

/* Sticky columns */
.sticky-no  { position: sticky; left: 0; z-index: 12; border-right: 2px solid #ddd; }
.sticky-wo  { position: sticky; z-index: 12; border-right: 2px solid #ddd; }

/* ---- Editable Cells ---- */
.data-cell { position: relative; cursor: pointer; min-width: 120px; }
.data-cell:hover { background-color: #e0f2fe; }
.data-cell.empty:hover::after {
    content: 'Click to enter data';
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    color: #999; font-style: italic; font-size: 10px; pointer-events: none;
}
.data-cell .cell-value { display: block; width: 100%; min-height: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.data-cell input {
    width: 100%; border: 1px solid var(--primary); padding: 2px;
    font-family: inherit; font-size: 11px; background: #fff;
    position: absolute; top: 0; left: 0; height: 100%; box-sizing: border-box; display: none;
}

/* ---- Form ---- */
.form-group { display: flex; flex-direction: column; margin-bottom: 10px; }

/* ---- Plant Selector Overlay ---- */
.plant-selector-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: var(--gradient-primary); z-index: 10000;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    color: white; text-align: center;
}
.plant-selector-title h1  { font-size: 2.5em; margin-bottom: 10px; text-shadow: 0 2px 4px rgba(0,0,0,0.3); }
.plant-selector-title p   { font-size: 1.2em; margin-bottom: 40px; opacity: 0.9; }
.plant-options-container  { display: flex; gap: 30px; justify-content: center; flex-wrap: wrap; }
.plant-card {
    background: rgba(255,255,255,0.95); color: var(--dark);
    border-radius: 15px; padding: 30px; width: 280px;
    text-align: center; box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    border: 2px solid transparent; transition: all 0.3s ease;
    cursor: pointer; backdrop-filter: blur(5px);
}
.plant-card:hover { transform: translateY(-10px); box-shadow: 0 15px 30px rgba(0,0,0,0.3); background: white; }
.plant-card-logo  { font-size: 3em; margin-bottom: 15px; font-weight: 800; }
.plant-card h2    { color: var(--primary); font-size: 1.8em; margin-bottom: 5px; }
.plant-card span  { color: var(--secondary); font-size: 0.9em; font-weight: 600; }

/* ---- Modal ---- */
.modal {
    display: none; position: fixed; z-index: 2000;
    left: 0; top: 0; width: 100%; height: 100%;
    background-color: rgba(0,0,0,0.6); backdrop-filter: blur(5px);
    justify-content: center; align-items: center;
}
.modal-header {
    background: linear-gradient(135deg,#177d90 0%,#043c54 100%);
    color: white; padding: 15px;
    border-radius: 8px 8px 0 0; flex-shrink: 0;
    display: flex; justify-content: space-between; align-items: center;
}
.modal-close {
    color: white; background: none; border: none;
    font-size: 24px; cursor: pointer;
}

/* ---- RCFA ---- */
#rcfa-table th { text-align: center; vertical-align: middle; }
#rcfa-table td { vertical-align: top; }

.input-with-evidence { display: flex; gap: 5px; align-items: center; width: 100%; }
.rcfa-thumb-preview {
    height: 34px; width: 34px; object-fit: cover;
    border-radius: 4px; border: 1px solid #ccc; margin-left: 5px; cursor: pointer;
}
.rcfa-add-btn {
    height: 34px; width: 30px; padding: 0; margin-left: 5px;
    font-size: 14px; font-weight: bold; cursor: pointer;
    background: #eee; border: 1px solid #ccc; border-radius: 4px; color: #333;
}
#rcfa-tree-container h5 { margin: 0 0 5px 0; color: #666; font-size: 12px; }

/* ---- Dashboard Charts ---- */
.chart-container {
    background: var(--white); border-radius: 8px;
    padding: 15px; box-shadow: var(--shadow);
    border: 1px solid var(--border);
    display: flex; flex-direction: column; min-height: 0;
}
.chart-title { font-size: 14px; margin: 0; color: var(--primary); font-weight: 700; }
.chart-canvas-container { flex: 1; position: relative; min-height: 0; }
.btn-camera {
    background: none; border: 1px solid var(--primary);
    color: var(--primary); border-radius: 4px;
    cursor: pointer; padding: 0 5px; font-size: 12px;
}

/* ---- Loader overlay ---- */
#page-loader {
    position: fixed; inset: 0; z-index: 20000;
    background: var(--gradient-primary);
    display: flex; align-items: center; justify-content: center;
    flex-direction: column; gap: 16px; color: white;
    font-size: 16px; font-weight: 600;
    transition: opacity 0.4s ease;
}
#page-loader .spinner {
    width: 48px; height: 48px;
    border: 5px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
