/* Author: Bradley R. Kinnard */
/* MWO Portal - Main Stylesheet */

:root {
    --color-primary: #2563eb;
    --color-primary-dark: #1d4ed8;
    --color-secondary: #64748b;
    --color-success: #22c55e;
    --color-warning: #f59e0b;
    --color-danger: #ef4444;
    --color-bg: #f8fafc;
    --color-surface: #ffffff;
    --color-text: #1e293b;
    --color-text-muted: #64748b;
    --color-border: #e2e8f0;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.15);
}

*, *::before, *::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
}

/* Header */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 2rem;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    box-shadow: var(--shadow);
}

.app-header h1 {
    margin: 0;
    font-size: 1.25rem;
    color: var(--color-primary);
}

.header-nav {
    display: flex;
    gap: 1.5rem;
}

.nav-link {
    text-decoration: none;
    color: var(--color-text-muted);
    font-weight: 500;
    transition: color 0.2s;
}

.nav-link:hover,
.nav-link.active {
    color: var(--color-primary);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-name {
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

/* Container */
.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 2rem;
}

/* Auth pages */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.auth-card {
    background: var(--color-surface);
    padding: 2.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 400px;
}

.auth-card h1 {
    margin: 0 0 0.5rem;
    text-align: center;
}

.subtitle {
    text-align: center;
    color: var(--color-text-muted);
    margin-bottom: 2rem;
}

.auth-link {
    text-align: center;
    margin-top: 1.5rem;
}

.auth-link a {
    color: var(--color-primary);
    text-decoration: none;
}

/* Forms */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--color-text);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

.form-card {
    background: var(--color-surface);
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.form-card h2 {
    margin: 0 0 1.5rem;
}

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

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: background 0.2s, transform 0.1s;
}

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

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

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

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

.btn-secondary:hover {
    background: #475569;
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

/* Messages */
.error-msg {
    background: #fef2f2;
    color: var(--color-danger);
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    border: 1px solid #fecaca;
}

.success-msg {
    background: #f0fdf4;
    color: var(--color-success);
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    border: 1px solid #bbf7d0;
}

.info-msg {
    background: #eff6ff;
    color: var(--color-primary);
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    border: 1px solid #bfdbfe;
}

/* Dashboard */
.dashboard-welcome {
    margin-bottom: 2rem;
}

.dashboard-welcome h2 {
    margin: 0 0 0.5rem;
}

.dashboard-welcome p {
    color: var(--color-text-muted);
    margin: 0;
}

.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--color-surface);
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-align: center;
}

.stat-value {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    color: var(--color-primary);
}

.stat-label {
    color: var(--color-text-muted);
    font-size: 0.875rem;
}

.dashboard-actions {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
}

/* Ticket list */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.page-header h2 {
    margin: 0;
}

.filters {
    display: flex;
    gap: 1rem;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.filters label {
    font-weight: 500;
}

.filters select {
    padding: 0.5rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 0.9rem;
}

.ticket-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.ticket-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--color-surface);
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-decoration: none;
    color: inherit;
    transition: box-shadow 0.2s;
}

.ticket-item:hover {
    box-shadow: var(--shadow-lg);
}

.ticket-main {
    flex: 1;
}

.ticket-subject {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.ticket-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

.ticket-badges {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-open { background: #dbeafe; color: #1d4ed8; }
.badge-in_progress { background: #fef3c7; color: #b45309; }
.badge-waiting { background: #e0e7ff; color: #4338ca; }
.badge-closed { background: #e2e8f0; color: #475569; }
.badge-urgent { background: #fee2e2; color: #dc2626; }
.badge-normal { background: #f1f5f9; color: #64748b; }
.badge-emergency { background: #fee2e2; color: #dc2626; }
.badge-maintenance { background: #d1fae5; color: #047857; }
.badge-dev { background: #ddd6fe; color: #6d28d9; }
.badge-billing { background: #fef3c7; color: #b45309; }

/* Ticket detail */
.back-link {
    display: inline-block;
    color: var(--color-primary);
    text-decoration: none;
    margin-bottom: 1.5rem;
}

.ticket-detail {
    background: var(--color-surface);
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

.ticket-header {
    border-bottom: 1px solid var(--color-border);
    padding-bottom: 1rem;
    margin-bottom: 1rem;
}

.ticket-header h2 {
    margin: 0 0 0.5rem;
}

.ticket-info {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    font-size: 0.9rem;
    color: var(--color-text-muted);
}

.admin-controls {
    background: var(--color-surface);
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
    border: 2px solid var(--color-primary);
}

.admin-controls h3 {
    margin: 0 0 1rem;
    color: var(--color-primary);
}

.control-group {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-right: 1.5rem;
    margin-bottom: 1rem;
}

.control-group select {
    padding: 0.5rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
}

/* Messages */
.messages-section,
.reply-section {
    background: var(--color-surface);
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

.messages-section h3,
.reply-section h3 {
    margin: 0 0 1rem;
}

.message-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.message-item {
    padding: 1rem;
    border-radius: var(--radius);
    background: var(--color-bg);
}

.message-item.admin {
    background: #eff6ff;
    border-left: 3px solid var(--color-primary);
}

.message-item.client {
    background: #f0fdf4;
    border-left: 3px solid var(--color-success);
}

.message-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
}

.message-sender {
    font-weight: 600;
    text-transform: capitalize;
}

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

.message-body {
    white-space: pre-wrap;
    word-break: break-word;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-content {
    background: var(--color-surface);
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 400px;
}

.modal-content h2 {
    margin: 0 0 1.5rem;
}

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

/* Utilities */
.loading {
    color: var(--color-text-muted);
    text-align: center;
    padding: 2rem;
}

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--color-text-muted);
}

[hidden] {
    display: none !important;
}

/* Responsive */
@media (max-width: 768px) {
    .app-header {
        flex-wrap: wrap;
        gap: 1rem;
        padding: 1rem;
    }

    .header-nav {
        order: 3;
        width: 100%;
        justify-content: center;
    }

    .container {
        padding: 1rem;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .dashboard-actions {
        flex-direction: column;
    }

    .ticket-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
}
