/* --- Modern Professional Stylesheet --- */
:root {
    --primary-color: #0d47a1;
    --primary-light: #1e88e5;
    --primary-dark: #0b3a8a;
    --background-color: #f4f6f8;
    --surface-color: #ffffff;
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --border-color: #dee2e6;
    --error-color: #dc3545;
    --success-color: #198754;
    --workshop-bubble-bg: #e3f2fd;
    --customer-bubble-bg: #e8f5e9;
    --system-bubble-bg: #f8f9fa;
    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --border-radius-sm: 0.25rem;
    --border-radius-md: 0.5rem;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
}
*, *::before, *::after { box-sizing: border-box; }
body {
    font-family: var(--font-family); margin: 0; background-color: var(--background-color); color: var(--text-primary);
    display: flex; flex-direction: column; justify-content: center; align-items: center; min-height: 100vh; font-size: 16px;
    -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
.pwa-banner {
    width: 100%;
    padding: 1rem;
    background-color: #e3f2fd;
    border-bottom: 1px solid #90caf9;
    text-align: center;
    color: var(--primary-dark);
}
.pwa-banner p {
    margin: 0;
    line-height: 1.5;
}
.pwa-banner .btn-small {
    margin-top: 0.5rem;
}
/* THIS IS THE FUCKING FIX: Styles for the new iOS instruction block */
.ios-instruction {
    background-color: rgba(255,255,255,0.5);
    border-radius: var(--border-radius-md);
    padding: 0.75rem;
    margin-top: 0.75rem;
    border: 1px solid var(--primary-light);
    display: inline-block;
    line-height: 1.6;
}
.ios-icon {
    display: inline-block;
    vertical-align: middle;
    width: 18px;
    height: 18px;
    margin: 0 4px;
}

.login-card {
    background-color: var(--surface-color); padding: 2.5rem; border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-md); text-align: center; width: 100%; max-width: 400px;
    border-top: 4px solid var(--primary-color);
    margin: 1rem;
}
.login-card .logo { height: 100px; margin-bottom: 1.5rem; }
.login-card h2 { font-size: 1.75rem; font-weight: 600; margin-bottom: 0.5rem; }
.login-card .subtitle { color: var(--text-secondary); margin-bottom: 2rem; }
.form-group { margin-bottom: 1.25rem; text-align: left; }
.form-group label { display: block; margin-bottom: 0.5rem; font-weight: 500; }
.form-control {
    width: 100%; padding: 0.75rem 1rem; border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm); font-size: 1rem; transition: border-color 0.2s, box-shadow 0.2s;
}
.form-control:focus { outline: none; border-color: var(--primary-light); box-shadow: 0 0 0 3px rgba(30, 136, 229, 0.2); }
.btn {
    width: 100%; padding: 0.85rem; border: none; border-radius: var(--border-radius-sm);
    background-color: var(--primary-color); color: white; font-size: 1rem; font-weight: bold;
    cursor: pointer; transition: background-color 0.2s, opacity 0.2s;
}
.btn:hover { background-color: var(--primary-dark); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.error-alert {
    color: var(--error-color); background-color: #f8d7da; border: 1px solid #f5c2c7;
    padding: 0.75rem 1rem; border-radius: var(--border-radius-sm); margin-bottom: 1.5rem;
}
.chat-container {
    width: 100%; max-width: 800px; height: calc(100vh - 40px); max-height: 900px; margin: 20px;
    background: var(--surface-color); border-radius: var(--border-radius-md); box-shadow: var(--shadow-md);
    display: flex; flex-direction: column; overflow: hidden;
}
.chat-header {
    display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color); flex-shrink: 0;
}
.chat-header h3 { margin: 0; font-size: 1.25rem; }
.chat-header p { margin: 0; color: var(--text-secondary); }
.btn-logout {
    padding: 0.5rem 1rem; border-radius: var(--border-radius-sm); background-color: #f1f3f5;
    color: var(--text-primary); text-decoration: none; font-weight: 500; transition: background-color 0.2s;
}
.btn-logout:hover { background-color: #e9ecef; }
.tabs {
    display: flex;
    background-color: #f8f9fa;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}
.tab-link {
    padding: 1rem 1.5rem;
    text-align: center;
    flex-grow: 1;
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: 600;
    border-bottom: 3px solid transparent;
    transition: color 0.2s, border-color 0.2s;
}
.tab-link:hover {
    color: var(--text-primary);
}
.tab-link.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}
.tab-content {
    display: none;
    flex-grow: 1;
    flex-direction: column;
    overflow: hidden;
}
.tab-content.active {
    display: flex;
}
#info-view {
    flex-grow: 1;
    overflow-y: auto;
}
.info-panel {
    padding: 1.5rem;
}
.info-card {
    background: #fdfdfd;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 1.5rem;
    margin-bottom: 1rem;
}
.info-card h4 {
    margin-top: 0;
    margin-bottom: 1rem;
    font-size: 1.1rem;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}
.info-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
}
@media (min-width: 600px) { .info-grid { grid-template-columns: 1fr 1fr; } }
.info-item {
    display: flex;
    flex-direction: column;
}
.info-item span {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}
.chat-messages { flex-grow: 1; overflow-y: auto; padding: 1.5rem; display: flex; flex-direction: column; gap: 1rem; }
.message-wrapper { display: flex; max-width: 75%; }
.message-wrapper.out { align-self: flex-start; }
.message-wrapper.in { align-self: flex-end; }
.message-wrapper.system { align-self: center; max-width: 100%; }
.message-bubble { padding: 0.75rem 1rem; border-radius: var(--border-radius-md); box-shadow: var(--shadow-sm); }
.message-wrapper.out .message-bubble { background-color: var(--workshop-bubble-bg); border-top-left-radius: 0.25rem; }
.message-wrapper.in .message-bubble { background-color: var(--customer-bubble-bg); border-top-right-radius: 0.25rem; }
.message-wrapper.system .message-bubble { background-color: var(--system-bubble-bg); text-align: center; font-style: italic; color: var(--text-secondary); font-size: 0.875rem; }
.sender-name { font-weight: 600; font-size: 0.875rem; margin-bottom: 0.25rem; }
.message-wrapper.out .sender-name { color: var(--primary-color); }
.message-wrapper.in .sender-name { color: var(--success-color); }
.message-wrapper.system .sender-name { display: none; }
.message-bubble p { margin: 0; line-height: 1.5; white-space: pre-wrap; word-wrap: break-word; }
.timestamp { font-size: 0.75rem; color: var(--text-secondary); display: block; text-align: right; margin-top: 0.5rem; }
.timestamp.unread { font-weight: bold; color: var(--primary-dark); }
.message-images { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.5rem; }
.message-thumbnail { max-width: 120px; max-height: 120px; border-radius: var(--border-radius-sm); border: 1px solid var(--border-color); cursor: pointer; object-fit: cover; transition: transform 0.2s; }
.message-thumbnail:hover { transform: scale(1.05); }
.message-files { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 0.5rem; }
.message-files a { display: inline-flex; align-items: center; gap: 0.5rem; background-color: rgba(0,0,0,0.05); padding: 0.5rem 0.75rem; border-radius: var(--border-radius-sm); color: var(--text-primary); text-decoration: none; transition: background-color 0.2s; }
.message-files a:hover { background-color: rgba(0,0,0,0.1); }
.chat-input-area { padding: 1rem 1.5rem; border-top: 1px solid var(--border-color); background-color: #f8f9fa; flex-shrink: 0; }
.chat-input-area .form { display: flex; flex-direction: row; align-items: center; gap: 0.75rem; }
.chat-input-area textarea { flex-grow: 1; border: 1px solid var(--border-color); border-radius: 20px; padding: 0.6rem 1rem; font-size: 1rem; font-family: inherit; resize: none; max-height: 120px; }
.chat-input-area textarea:focus { outline: none; border-color: var(--primary-light); box-shadow: 0 0 0 3px rgba(30, 136, 229, 0.2); }
.btn-icon { border: none; background: transparent; font-size: 1.5rem; cursor: pointer; color: var(--text-secondary); padding: 0.5rem; border-radius: 50%; transition: background-color 0.2s, color 0.2s; }
.btn-icon:hover { background-color: #e9ecef; }
.btn-icon[type="submit"] { color: var(--primary-color); }
.btn-icon:disabled { opacity: 0.5; cursor: not-allowed; }
.preview-area { display: none; padding: 0.5rem 1.5rem; border-bottom: 1px solid #e9ecef; flex-wrap: wrap; gap: 0.5rem; }
.file-preview { background-color: #e9ecef; padding: 0.25rem 0.75rem; border-radius: 20px; font-size: 0.8rem; display: flex; align-items: center; gap: 0.5rem; }
.remove-btn { border: none; background: #adb5bd; color: white; border-radius: 50%; width: 16px; height: 16px; cursor: pointer; font-size: 10px; line-height: 16px; text-align: center; padding: 0; }
.notification-banner {
    padding: 0.5rem 1.5rem;
    background-color: #fffbe6;
    border-bottom: 1px solid #ffe58f;
    text-align: center;
    flex-shrink: 0;
}
.btn.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    width: auto;
}
@media (max-width: 600px) {
    body { justify-content: flex-start; }
    .chat-container { margin: 0; border-radius: 0; height: 100vh; max-height: 100vh; }
    .message-wrapper { max-width: 90%; }
}