:root {
    --ms-primary: #0d253f;
    --ms-primary-light: #1a3a5c;
    --ms-accent: #2980b9;
    --ms-bg: #f4f7fa;
    --ms-card-bg: #ffffff;
    --ms-text: #2c3e50;
    --ms-text-muted: #7f8c8d;
}

body {
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--ms-bg);
    color: var(--ms-text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Navbar */
.navbar-ms {
    background: linear-gradient(135deg, var(--ms-primary) 0%, var(--ms-primary-light) 100%);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
}

.navbar-ms .navbar-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 1.35rem;
    color: #fff;
    letter-spacing: -0.02em;
}

.navbar-ms .navbar-brand:hover {
    color: #fff;
}

.navbar-ms .navbar-brand img {
    height: 32px;
    width: auto;
}

/* Login card */
.login-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
}

.login-card {
    background: var(--ms-card-bg);
    border-radius: 1rem;
    box-shadow: 0 4px 24px rgba(13, 37, 63, 0.1);
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 420px;
}

.login-card .logo-section {
    text-align: center;
    margin-bottom: 2rem;
}

.login-card .logo-section img {
    height: 48px;
    width: auto;
    margin-bottom: 0.75rem;
}

.login-card .logo-section p {
    color: var(--ms-text-muted);
    font-size: 0.95rem;
    margin: 0;
}

.login-card h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--ms-primary);
    text-align: center;
    margin-bottom: 0.25rem;
}

/* Phone input */
.phone-input-group {
    position: relative;
}

.phone-input-group .phone-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--ms-text-muted);
    pointer-events: none;
    font-size: 1.1rem;
}

.phone-input-group input {
    padding-left: 2.75rem;
    height: 3rem;
    font-size: 1.05rem;
    border: 2px solid #e0e6ed;
    border-radius: 0.75rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.phone-input-group input:focus {
    border-color: var(--ms-accent);
    box-shadow: 0 0 0 3px rgba(41, 128, 185, 0.15);
}

.phone-input-group input::placeholder {
    color: #b0bec5;
}

/* Code digit inputs */
.code-digits {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
}

.code-digit {
    width: 3rem;
    height: 3.5rem;
    text-align: center;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--ms-primary);
    border: 2px solid #e0e6ed;
    border-radius: 0.75rem;
    background: var(--ms-card-bg);
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
    caret-color: var(--ms-accent);
}

.code-digit:focus {
    border-color: var(--ms-accent);
    box-shadow: 0 0 0 3px rgba(41, 128, 185, 0.15);
}

.code-separator {
    width: 0.75rem;
    height: 3px;
    background: #e0e6ed;
    border-radius: 2px;
    flex-shrink: 0;
}

/* Navbar buttons */
.navbar-ms-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-help {
    color: rgba(255, 255, 255, 0.7);
}

.btn-help:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

/* Help page */
.help-section {
    background: var(--ms-card-bg);
    border-radius: 0.75rem;
    padding: 1.5rem;
    box-shadow: 0 1px 6px rgba(13, 37, 63, 0.06);
}

.help-section h2 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--ms-primary);
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--ms-bg);
}

.help-section h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--ms-text);
    margin-top: 1rem;
    margin-bottom: 0.5rem;
}

.help-section p,
.help-section li {
    font-size: 0.92rem;
    line-height: 1.6;
    color: var(--ms-text);
}

.help-section ul {
    padding-left: 1.25rem;
}

.help-section code {
    background: var(--ms-bg);
    padding: 0.15rem 0.4rem;
    border-radius: 0.25rem;
    font-size: 0.85rem;
    color: var(--ms-primary);
}

/* Submit button */
.btn-ms-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--ms-primary-light) 0%, var(--ms-primary) 100%);
    border: none;
    color: #fff;
    font-weight: 600;
    font-size: 1.05rem;
    height: 3rem;
    border-radius: 0.75rem;
    transition: opacity 0.2s, transform 0.1s;
}

.btn-ms-primary:hover {
    opacity: 0.9;
    color: #fff;
}

.btn-ms-primary:active {
    transform: scale(0.98);
}

/* Footer */
.footer-ms {
    background: var(--ms-primary);
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.85rem;
    padding: 1rem 0;
    text-align: center;
    margin-top: auto;
}

.footer-ms a {
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
}

.footer-ms a:hover {
    color: #fff;
}

/* Admin */
.admin-wrapper {
    flex: 1;
    padding: 2rem 1rem;
}

.admin-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--ms-primary);
    margin-bottom: 1.5rem;
}

.admin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1.5rem;
}

.admin-card {
    background: var(--ms-card-bg);
    border-radius: 1rem;
    box-shadow: 0 2px 12px rgba(13, 37, 63, 0.08);
    padding: 2rem 1.5rem;
    text-decoration: none;
    color: var(--ms-text);
    transition: box-shadow 0.2s, transform 0.15s;
}

.admin-card:hover {
    box-shadow: 0 4px 20px rgba(13, 37, 63, 0.15);
    transform: translateY(-2px);
    color: var(--ms-text);
}

.admin-card-icon {
    color: var(--ms-accent);
    margin-bottom: 1rem;
}

.admin-card h2 {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.admin-card p {
    color: var(--ms-text-muted);
    font-size: 0.9rem;
    margin: 0;
}

.admin-create-form {
    background: var(--ms-card-bg);
    border-radius: 0.75rem;
    padding: 1rem 1.25rem;
    box-shadow: 0 1px 6px rgba(13, 37, 63, 0.06);
}

.admin-table {
    background: var(--ms-card-bg);
    border-radius: 0.75rem;
    overflow: hidden;
    box-shadow: 0 1px 6px rgba(13, 37, 63, 0.06);
}

.admin-table th {
    background: var(--ms-bg);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--ms-text-muted);
    border-bottom: 2px solid #e0e6ed;
}

.admin-table td {
    vertical-align: middle;
}

/* App wrapper (authenticated pages) */
.app-wrapper {
    flex: 1;
    padding: 2rem 1rem;
}

.app-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--ms-primary);
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    background: var(--ms-card-bg);
    border-radius: 1rem;
    box-shadow: 0 2px 12px rgba(13, 37, 63, 0.06);
}

/* Trigger list */
.trigger-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.trigger-card {
    background: var(--ms-card-bg);
    border-radius: 0.75rem;
    padding: 1rem 1.25rem;
    box-shadow: 0 1px 6px rgba(13, 37, 63, 0.06);
}

.trigger-badge {
    flex-shrink: 0;
    margin-top: 2px;
}

.trigger-content {
    font-size: 0.95rem;
    color: var(--ms-text);
    line-height: 1.4;
}

.trigger-meta {
    font-size: 0.8rem;
    color: var(--ms-text-muted);
}

.trigger-detail-link {
    align-self: center;
    flex-shrink: 0;
}

/* Form sections */
.form-section {
    background: var(--ms-card-bg);
    border-radius: 0.75rem;
    padding: 1.5rem;
    box-shadow: 0 1px 6px rgba(13, 37, 63, 0.06);
}

.form-section-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--ms-primary);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--ms-bg);
}

/* Book list in trigger form */
.book-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.book-item {
    padding: 0.5rem 0.25rem;
    border-radius: 0.375rem;
    transition: background 0.15s;
}

.book-item:hover {
    background: var(--ms-bg);
}

/* Icon buttons */
.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border: none;
    background: none;
    border-radius: 0.375rem;
    color: var(--ms-text-muted);
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
    padding: 0;
    text-decoration: none;
    flex-shrink: 0;
}

.btn-icon:hover {
    background: var(--ms-bg);
    color: var(--ms-primary);
}

.btn-icon.text-danger:hover {
    color: #dc3545;
    background: #fff0f0;
}

/* Contact list in book edit */
.contact-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.contact-item {
    padding: 0.5rem 0.5rem;
    border-radius: 0.375rem;
    transition: background 0.15s;
}

.contact-item:hover {
    background: var(--ms-bg);
}

/* Sandbox */
.sandbox-call-card {
    background: var(--ms-card-bg);
    border-radius: 0.75rem;
    padding: 1rem 1.25rem;
    box-shadow: 0 1px 6px rgba(13, 37, 63, 0.06);
}

.sandbox-call-content {
    font-size: 0.9rem;
    color: var(--ms-text);
    padding-left: 0.75rem;
    border-left: 3px solid var(--ms-accent);
    line-height: 1.4;
}

.sandbox-keypad {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-top: 0.5rem;
}

.sandbox-key-btn {
    width: 2.25rem;
    height: 2.25rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #e0e6ed;
    border-radius: 0.375rem;
    background: var(--ms-bg);
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--ms-text);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.sandbox-key-btn:hover {
    background: var(--ms-accent);
    border-color: var(--ms-accent);
    color: #fff;
}

/* Message progress bar */
.message-progress {
    height: 6px;
    border-radius: 3px;
    background: #e0e6ed;
}

.message-progress .progress-bar {
    transition: width 0.15s, background-color 0.2s;
    border-radius: 3px;
}

/* Trigger status progress bar */
.trigger-progress {
    height: 6px;
    border-radius: 3px;
    background: #e0e6ed;
}

.trigger-progress .progress-bar {
    transition: width 0.3s;
}

.trigger-status-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: var(--ms-text-muted);
}

.trigger-status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 0.2rem;
    vertical-align: middle;
}
