/* ==========================================================================
   AI DATASHEET BUILDER - CSS STYLING
   ========================================================================== */

/* Wizard Screen Styling */
.wizard-screen-container {
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 40px 20px;
    display: flex;
    flex-direction: column;
    gap: 32px;
    box-sizing: border-box;
}

.wizard-header {
    text-align: center;
}

.wizard-header h2 {
    font-size: 26px;
    font-weight: 800;
    letter-spacing: -0.5px;
    color: var(--text-light);
}

.wizard-header p {
    font-size: 14px;
    color: var(--text-secondary);
    max-width: 600px;
    margin: 10px auto 0 auto;
    line-height: 1.5;
}

.wizard-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 20px;
}

@media (max-width: 1200px) {
    .wizard-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .wizard-grid {
        grid-template-columns: 1fr;
    }
}

.wizard-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 24px 20px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-normal);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    min-height: 310px;
    box-sizing: border-box;
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
}

.wizard-card:hover {
    transform: translateY(-5px);
    border-color: var(--border-focus);
    box-shadow: 0 8px 25px rgba(0,0,0,0.3);
}

.wizard-card.card-active:hover {
    border-color: var(--color-safe);
    box-shadow: 0 8px 25px rgba(0, 255, 102, 0.08);
}

.wizard-card.card-locked {
    opacity: 0.65;
    background-color: rgba(18, 24, 38, 0.4);
}

.wizard-card.card-locked:hover {
    border-color: var(--color-warning);
    box-shadow: 0 8px 25px rgba(255, 204, 0, 0.04);
}

/* P&ID SVG Symbols Styling */
.pid-symbol-container {
    width: 110px;
    height: 110px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
}

.pid-svg {
    width: 100%;
    height: 100%;
    stroke: var(--text-secondary);
    stroke-width: 1.5;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: all var(--transition-normal);
}

/* Glowing effects for Level */
.card-active .pid-svg {
    stroke: var(--text-primary);
}

.card-active:hover .pid-svg {
    stroke: var(--color-safe);
    filter: drop-shadow(0 0 4px var(--color-safe-glow));
}

.card-locked .pid-svg {
    stroke: var(--text-muted);
}

.card-locked:hover .pid-svg {
    stroke: var(--color-warning);
    filter: drop-shadow(0 0 4px var(--color-warning-glow));
}

/* Custom P&ID SVG classes */
.pid-pipe {
    stroke-width: 3.5;
    stroke: var(--border-focus);
}

.pid-vessel {
    stroke-width: 1.8;
    stroke: var(--text-secondary);
}

.card-active .pid-vessel {
    stroke: var(--color-info);
}

.pid-vessel-fluid-level {
    stroke: var(--color-info);
    stroke-width: 1;
}

.pid-nozzle {
    stroke: var(--text-secondary);
    fill: var(--bg-card);
}

.pid-probe {
    stroke: var(--color-safe);
    stroke-width: 1.2;
}

.pid-bubble {
    fill: var(--bg-dark);
    stroke-width: 1.5;
}

.card-locked .pid-bubble {
    stroke: var(--text-muted);
}

.card-locked:hover .pid-bubble {
    stroke: var(--color-warning);
}

.card-active .pid-bubble {
    stroke: var(--text-secondary);
}

.card-active:hover .pid-bubble {
    stroke: var(--color-safe);
}

.pid-bubble-divider {
    stroke-width: 1;
}

.pid-text-tag {
    font-family: var(--font-primary);
    font-size: 11px;
    font-weight: 800;
    fill: var(--text-light);
    stroke: none;
    text-anchor: middle;
}

.pid-text-sub {
    font-family: var(--font-primary);
    font-size: 8px;
    font-weight: 600;
    fill: var(--text-secondary);
    stroke: none;
    text-anchor: middle;
}

.pid-signal-line {
    stroke-width: 1;
    stroke: var(--color-warning);
}

.pid-flange {
    stroke-width: 2.5;
    stroke: var(--border-focus);
}

.pid-inline-instrument {
    fill: var(--bg-dark);
    stroke: var(--text-secondary);
}

.pid-inline-detail {
    stroke-width: 1.2;
}

.pid-node {
    fill: var(--text-secondary);
    stroke: none;
}

.pid-thermowell {
    stroke-width: 1.5;
    stroke: var(--color-warning);
}

.pid-valve-body {
    fill: var(--bg-dark);
    stroke-width: 1.5;
}

.pid-actuator-bar {
    stroke-width: 1.5;
}

.pid-actuator-dome {
    stroke-width: 1.5;
}

/* Card titles & texts */
.wizard-card h3 {
    font-size: 15px;
    font-weight: 700;
    margin: 8px 0 4px 0;
    color: var(--text-light);
}

.wizard-card p {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
    margin: 0;
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Card statuses */
.card-status {
    font-size: 9px;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 12px;
    margin-top: 16px;
    letter-spacing: 0.5px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.status-ready {
    background-color: rgba(0, 255, 102, 0.06);
    border: 1px solid var(--color-safe);
    color: var(--color-safe);
}

.status-under-construction {
    background-color: rgba(255, 204, 0, 0.04);
    border: 1px solid var(--color-warning);
    color: var(--color-warning);
}

/* Animations / Transitions */
.hidden {
    display: none !important;
}

.fade-in {
    animation: fadeIn 0.4s ease-out forwards;
}

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

/* Workspace Grid Layout */
.workspace-grid {
    display: grid;
    grid-template-columns: 380px 1fr;
    height: calc(100vh - 60px); /* Subtract header */
    overflow: hidden;
}

@media (max-width: 1200px) {
    .workspace-grid {
        grid-template-columns: 320px 1fr;
    }
}

@media (max-width: 900px) {
    .workspace-grid {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr 1fr;
        height: auto;
        overflow: auto;
    }
    .chat-panel {
        height: 450px !important;
    }
    .datasheet-panel {
        height: auto !important;
        overflow: visible !important;
    }
}

/* Panels Common */
.chat-panel, .datasheet-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.chat-panel {
    border-right: 1px solid var(--border-color);
    background-color: #090c14;
}

.datasheet-panel {
    background-color: var(--bg-dark);
}

.panel-header {
    padding: 12px 18px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #0c111e;
    flex-shrink: 0;
}

.panel-header h2 {
    font-size: 13px;
    font-weight: 700;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.panel-header h2 i {
    color: var(--color-safe);
}

.btn-icon {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: color var(--transition-fast);
}

.btn-icon:hover {
    color: var(--text-light);
}

.action-buttons {
    display: flex;
    gap: 8px;
}

/* Chat Interface */
.chat-log {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.message {
    display: flex;
    flex-direction: column;
    max-width: 85%;
}

.message-ai {
    align-self: flex-start;
}

.message-user {
    align-self: flex-end;
}

.message-bubble {
    padding: 12px 15px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.5;
    word-break: break-word;
}

.message-ai .message-bubble {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-top-left-radius: 2px;
}

.message-user .message-bubble {
    background-color: rgba(0, 255, 102, 0.06);
    border: 1px solid var(--color-safe);
    color: var(--text-light);
    border-top-right-radius: 2px;
    box-shadow: 0 0 10px rgba(0, 255, 102, 0.05);
}

.chat-input-area {
    padding: 12px 15px;
    border-top: 1px solid var(--border-color);
    background-color: #0c111e;
    flex-shrink: 0;
}

.chat-form-row {
    display: flex;
    gap: 10px;
    align-items: center;
}

.chat-form-row input {
    background-color: var(--bg-dark);
    padding: 10px 14px;
    font-size: 13px;
    height: 40px;
}

.chat-form-row button {
    height: 40px;
    width: 40px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 15px;
    margin-bottom: 5px;
}

.typing-indicator span {
    width: 6px;
    height: 6px;
    background-color: var(--color-safe);
    border-radius: 50%;
    display: inline-block;
    animation: bounce 1.4s infinite ease-in-out both;
}

.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1.0); }
}

/* Datasheet Styling (Screen View) */
.datasheet-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.isa20-sheet {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    width: 100%;
    max-width: 900px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.25);
    padding: 24px;
    color: var(--text-primary);
    font-family: var(--font-primary);
}

.isa20-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 2px solid var(--border-focus);
    padding-bottom: 12px;
    margin-bottom: 15px;
}

.header-logo-title h1 {
    font-size: 18px;
    font-weight: 800;
    margin: 0;
    letter-spacing: 0.5px;
}

.header-logo-title h2 {
    font-size: 11px;
    color: var(--color-safe);
    font-weight: 700;
    margin: 4px 0 0 0;
    text-transform: uppercase;
}

.header-meta-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px 15px;
    font-size: 11px;
}

.meta-cell {
    border-bottom: 1px dashed var(--border-color);
    padding-bottom: 2px;
}

.isa20-grid {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    border: 1px solid var(--border-color);
}

.isa20-grid tr {
    border-bottom: 1px solid var(--border-color);
}

/* Center Divider Line for 2-column layout */
.isa20-grid td.val-col:not(:last-child) {
    border-right: 2px solid var(--border-focus);
}

.section-title-row td:first-child {
    border-right: 2px solid var(--border-focus);
}

.section-title-row {
    background-color: #1b2336;
    font-weight: 700;
    letter-spacing: 0.5px;
    font-size: 11px;
}

.section-title-row td {
    padding: 6px 10px !important;
    color: var(--text-light);
    border-bottom: 2px solid var(--border-focus) !important;
}

.isa20-grid td {
    padding: 5px 8px;
    vertical-align: middle;
}

.lbl-col {
    background-color: rgba(255, 255, 255, 0.02);
    color: var(--text-secondary);
    border-right: 1px solid var(--border-color);
    font-weight: 500;
}

.num-col {
    background-color: rgba(255, 255, 255, 0.01);
    color: var(--text-muted);
    text-align: center;
    font-size: 10px;
    font-weight: 700;
    border-right: 1px solid var(--border-color);
    width: 25px;
}

.val-col {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    border-right: 1px solid var(--border-color);
}

.val-col:last-child {
    border-right: none;
}

.remarks-box {
    line-height: 1.5;
    background-color: var(--bg-dark);
}

.isa20-footer {
    margin-top: 15px;
    border-top: 1px solid var(--border-color);
    padding-top: 8px;
    font-size: 10px;
    color: var(--text-muted);
    text-align: center;
}

/* Interactive Editable Cels */
.editable {
    outline: none;
    border-bottom: 1px solid transparent;
    transition: all var(--transition-fast);
}

.editable:hover {
    background-color: var(--bg-input);
    cursor: text;
}

.editable:focus {
    background-color: var(--bg-input) !important;
    border-bottom: 1px solid var(--color-safe);
    color: var(--text-light);
}

/* Visual Glow effect when AI fills in a cell */
@keyframes cellHighlight {
    0% { background-color: rgba(0, 255, 102, 0.3); }
    100% { background-color: transparent; }
}

.cell-highlight-active {
    animation: cellHighlight 1.5s ease-out;
}

/* Print Layout Override Styles */
@media print {
    .no-print {
        display: none !important;
    }

    body, html {
        background: #ffffff !important;
        color: #000000 !important;
        height: auto !important;
        overflow: visible !important;
        font-size: 11px !important;
    }

    #app-container {
        display: block !important;
        min-height: 0 !important;
        height: auto !important;
    }

    .workspace-grid {
        display: block !important;
        height: auto !important;
        overflow: visible !important;
    }

    .datasheet-panel {
        display: block !important;
        width: 100% !important;
        height: auto !important;
        overflow: visible !important;
    }

    .datasheet-container {
        display: block !important;
        padding: 0 !important;
        overflow: visible !important;
    }

    .isa20-sheet {
        background: #ffffff !important;
        color: #000000 !important;
        border: none !important;
        box-shadow: none !important;
        padding: 0 !important;
        margin: 0 !important;
        max-width: 100% !important;
        width: 100% !important;
    }

    .isa20-header-row {
        border-bottom: 2px solid #000000 !important;
    }

    .isa20-header-row td {
        background-color: #ffffff !important;
        color: #000000 !important;
        border-right: 1px solid #000000 !important;
        border-bottom: 2px solid #000000 !important;
    }

    .meta-inner-table td {
        background-color: #ffffff !important;
        color: #000000 !important;
        border-right: 1px solid #000000 !important;
        border-bottom: 1px solid #cccccc !important;
    }

    .meta-inner-table tr:last-child td {
        border-bottom: none !important;
    }

    .isa20-grid {
        border: 1px solid #000000 !important;
        color: #000000 !important;
        width: 100% !important;
    }

    /* Print divider styles */
    .isa20-grid td.val-col:not(:last-child) {
        border-right: 2px solid #000000 !important;
    }

    .section-title-row td:first-child {
        border-right: 2px solid #000000 !important;
    }

    .isa20-grid tr {
        border-bottom: 1px solid #000000 !important;
    }

    .section-title-row {
        background-color: #eaeaea !important;
    }

    .section-title-row td {
        color: #000000 !important;
        border-bottom: 2px solid #000000 !important;
    }

    .lbl-col {
        background-color: #f7f7f7 !important;
        color: #333333 !important;
        border-right: 1px solid #000000 !important;
    }

    .num-col {
        background-color: #eaeaea !important;
        color: #333333 !important;
        border-right: 1px solid #000000 !important;
        font-weight: 700 !important;
    }

    .val-col {
        background-color: #ffffff !important;
        color: #000000 !important;
        border-right: 1px solid #000000 !important;
    }

    .remarks-box {
        background-color: #ffffff !important;
    }

    .isa20-footer {
        border-top: 1px solid #000000 !important;
        color: #666666 !important;
    }

    .editable {
        border: none !important;
    }

    /* Style cells with specific data-attributes for writing */
    [data-print-blank="true"] {
        color: transparent !important;
        border-bottom: 1.5px dotted #000000 !important;
        min-width: 80px;
        display: inline-block;
    }
    
    [data-supplier-fill="true"] {
        background-color: #f7f7f7 !important;
        border: 1px dashed #555555 !important;
        color: #444444 !important;
        font-weight: 700 !important;
        font-style: italic !important;
        font-size: 9px !important;
        text-align: center !important;
        padding: 3px 6px !important;
    }
}
