/**
 * GPS Gateway Portal Styles
 * Color scheme matching tablet app: Primary #1a237e, Accent #3949ab
 */

/* CSS Variables */
:root {
    --gps-primary: #1a237e;
    --gps-primary-light: #3949ab;
    --gps-primary-dark: #0d1642;
    --gps-accent: #3949ab;
    --gps-background: #f5f5f5;
    --gps-surface: #ffffff;
    --gps-text-primary: #333333;
    --gps-text-secondary: #666666;
    --gps-text-muted: #999999;
    --gps-error: #d32f2f;
    --gps-success: #388e3c;
    --gps-warning: #f57c00;
    --gps-border: #e0e0e0;
    --gps-shadow: 0 2px 4px rgba(0,0,0,0.1);
    --gps-shadow-elevated: 0 4px 12px rgba(0,0,0,0.15);
    --gps-radius: 8px;
    --gps-radius-sm: 4px;
    --gps-transition: 0.2s ease;
}

/* Reset for plugin scope */
.gps-gateway-portal *,
.gps-gateway-portal *::before,
.gps-gateway-portal *::after {
    box-sizing: border-box;
}

/* ==================== Main Layout ==================== */

.gps-gateway-portal {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--gps-text-primary);
    background: var(--gps-background);
    min-height: 600px;
}

.gps-gateway-container {
    display: flex;
    max-width: 1400px;
    margin: 0 auto;
    background: var(--gps-surface);
    border-radius: var(--gps-radius);
    box-shadow: var(--gps-shadow);
    overflow: hidden;
}

/* ==================== Sidebar ==================== */

.gps-gateway-sidebar {
    width: 280px;
    min-width: 280px;
    background: var(--gps-primary);
    color: #fff;
    display: flex;
    flex-direction: column;
}

.gps-gateway-sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.gps-gateway-logo {
    font-size: 20px;
    font-weight: 700;
    margin: 0 0 4px 0;
}

.gps-gateway-user-email {
    font-size: 13px;
    opacity: 0.8;
}

.gps-gateway-nav {
    flex: 1;
    padding: 16px 0;
}

.gps-gateway-nav-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    cursor: pointer;
    transition: background var(--gps-transition);
}

.gps-gateway-nav-item:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
}

.gps-gateway-nav-item.active {
    background: rgba(255,255,255,0.15);
    color: #fff;
    border-left: 3px solid #fff;
    padding-left: 17px;
}

.gps-gateway-nav-item .dashicons {
    margin-right: 12px;
    font-size: 20px;
    width: 20px;
    height: 20px;
}

.gps-gateway-nav-divider {
    height: 1px;
    background: rgba(255,255,255,0.1);
    margin: 8px 20px;
}

.gps-gateway-sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

/* ==================== Main Content ==================== */

.gps-gateway-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.gps-gateway-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--gps-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--gps-surface);
}

.gps-gateway-header-title {
    font-size: 20px;
    font-weight: 600;
    margin: 0;
}

.gps-gateway-main {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
}

/* ==================== Buttons ==================== */

.gps-gateway-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    border: none;
    border-radius: var(--gps-radius-sm);
    cursor: pointer;
    transition: all var(--gps-transition);
    text-decoration: none;
}

.gps-gateway-btn-primary {
    background: var(--gps-primary);
    color: #fff;
}

.gps-gateway-btn-primary:hover {
    background: var(--gps-primary-light);
}

.gps-gateway-btn-secondary {
    background: var(--gps-background);
    color: var(--gps-text-primary);
    border: 1px solid var(--gps-border);
}

.gps-gateway-btn-secondary:hover {
    background: var(--gps-border);
}

.gps-gateway-btn-danger {
    background: var(--gps-error);
    color: #fff;
}

.gps-gateway-btn-danger:hover {
    background: #b71c1c;
}

.gps-gateway-btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.gps-gateway-btn-icon {
    padding: 8px;
    background: transparent;
    color: var(--gps-text-secondary);
}

.gps-gateway-btn-icon:hover {
    background: var(--gps-background);
    color: var(--gps-text-primary);
}

.gps-gateway-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ==================== Forms ==================== */

.gps-gateway-form-group {
    margin-bottom: 16px;
}

.gps-gateway-label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--gps-text-primary);
}

.gps-gateway-input,
.gps-gateway-select,
.gps-gateway-textarea {
    width: 100%;
    padding: 10px 12px;
    font-size: 14px;
    border: 1px solid var(--gps-border);
    border-radius: var(--gps-radius-sm);
    background: var(--gps-surface);
    transition: border-color var(--gps-transition), box-shadow var(--gps-transition);
}

.gps-gateway-input:focus,
.gps-gateway-select:focus,
.gps-gateway-textarea:focus {
    outline: none;
    border-color: var(--gps-primary);
    box-shadow: 0 0 0 3px rgba(26, 35, 126, 0.1);
}

.gps-gateway-textarea {
    resize: vertical;
    min-height: 100px;
}

.gps-gateway-input-error {
    border-color: var(--gps-error);
}

.gps-gateway-error-text {
    color: var(--gps-error);
    font-size: 13px;
    margin-top: 4px;
}

/* ==================== Cards ==================== */

.gps-gateway-card {
    background: var(--gps-surface);
    border-radius: var(--gps-radius);
    box-shadow: var(--gps-shadow);
    overflow: hidden;
}

.gps-gateway-card-header {
    padding: 16px;
    border-bottom: 1px solid var(--gps-border);
}

.gps-gateway-card-body {
    padding: 16px;
}

.gps-gateway-card-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--gps-border);
    background: var(--gps-background);
}

/* ==================== Filters ==================== */

.gps-gateway-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--gps-border);
}

.gps-gateway-portal .gps-gateway-filters button.gps-gateway-filter-item,
.gps-gateway-filter-item {
    padding: 8px 16px !important;
    background: #f5f5f5 !important;
    border: 1px solid #e0e0e0 !important;
    border-radius: 20px !important;
    font-size: 13px !important;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #333333 !important;
    font-weight: 500 !important;
    line-height: 1.4 !important;
}

.gps-gateway-portal .gps-gateway-filters button.gps-gateway-filter-item:hover,
.gps-gateway-filter-item:hover {
    border-color: #1a237e !important;
    color: #1a237e !important;
    background: #f5f5f5 !important;
}

.gps-gateway-portal .gps-gateway-filters button.gps-gateway-filter-item.active,
.gps-gateway-filter-item.active {
    background: #1a237e !important;
    color: #ffffff !important;
    border-color: #1a237e !important;
}

/* ==================== Articles ==================== */

.gps-gateway-articles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.gps-gateway-article-card {
    background: var(--gps-surface);
    border-radius: var(--gps-radius);
    box-shadow: var(--gps-shadow);
    overflow: hidden;
    cursor: pointer;
    transition: transform var(--gps-transition), box-shadow var(--gps-transition);
}

.gps-gateway-article-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--gps-shadow-elevated);
}

.gps-gateway-article-thumbnail {
    width: 100%;
    height: 160px;
    object-fit: cover;
    background: var(--gps-background);
}

.gps-gateway-article-content {
    padding: 16px;
}

.gps-gateway-article-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 8px 0;
    color: var(--gps-text-primary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.gps-gateway-article-excerpt {
    font-size: 14px;
    color: var(--gps-text-secondary);
    margin: 0 0 12px 0;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.gps-gateway-article-meta {
    font-size: 12px;
    color: var(--gps-text-muted);
}

.gps-gateway-article-category {
    display: inline-block;
    padding: 2px 8px;
    background: var(--gps-primary);
    color: #fff;
    border-radius: 12px;
    font-size: 11px;
    margin-right: 8px;
}

/* Article Detail */
.gps-gateway-article-detail {
    max-width: 800px;
}

.gps-gateway-article-detail-header {
    margin-bottom: 24px;
}

.gps-gateway-article-detail-title {
    font-size: 28px;
    font-weight: 700;
    margin: 0 0 12px 0;
    line-height: 1.3;
}

.gps-gateway-article-detail-meta {
    color: var(--gps-text-secondary);
    font-size: 14px;
}

.gps-gateway-article-detail-image {
    width: 100%;
    max-height: 400px;
    object-fit: cover;
    border-radius: var(--gps-radius);
    margin-bottom: 24px;
}

.gps-gateway-article-detail-body {
    font-size: 16px;
    line-height: 1.7;
}

.gps-gateway-article-detail-body img {
    max-width: 100%;
    height: auto;
    border-radius: var(--gps-radius-sm);
}

/* ==================== Chat ==================== */

.gps-gateway-chat-container {
    display: flex;
    height: 600px;
}

.gps-gateway-chat-sidebar {
    width: 280px;
    border-right: 1px solid var(--gps-border);
    display: flex;
    flex-direction: column;
}

.gps-gateway-chat-sidebar-header {
    padding: 16px;
    border-bottom: 1px solid var(--gps-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.gps-gateway-chat-list {
    flex: 1;
    overflow-y: auto;
}

.gps-gateway-chat-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--gps-border);
    cursor: pointer;
    transition: background var(--gps-transition);
}

.gps-gateway-chat-item:hover {
    background: var(--gps-background);
}

.gps-gateway-chat-item.active {
    background: rgba(26, 35, 126, 0.08);
    border-left: 3px solid var(--gps-primary);
}

.gps-gateway-chat-item-title {
    font-weight: 500;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gps-gateway-chat-item-date {
    font-size: 12px;
    color: var(--gps-text-muted);
}

.gps-gateway-chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.gps-gateway-chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

.gps-gateway-chat-message {
    max-width: 80%;
    margin-bottom: 16px;
    padding: 12px 16px;
    border-radius: var(--gps-radius);
}

.gps-gateway-chat-message-user {
    background: var(--gps-primary);
    color: #fff;
    margin-left: auto;
    border-bottom-right-radius: 4px;
}

.gps-gateway-chat-message-assistant {
    background: var(--gps-background);
    color: var(--gps-text-primary);
    border-bottom-left-radius: 4px;
}

.gps-gateway-chat-message-content {
    white-space: pre-wrap;
    word-wrap: break-word;
}

.gps-gateway-chat-input-container {
    padding: 16px;
    border-top: 1px solid var(--gps-border);
    display: flex;
    gap: 12px;
}

.gps-gateway-chat-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--gps-border);
    border-radius: 24px;
    font-size: 14px;
    resize: none;
    max-height: 120px;
}

.gps-gateway-chat-send {
    padding: 12px 24px;
    border-radius: 24px;
}

/* Chat Empty State */
.gps-gateway-chat-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    padding: 40px;
}

.gps-gateway-chat-empty h3 {
    margin: 16px 0 8px;
    color: var(--gps-text-primary);
}

.gps-gateway-chat-empty p {
    color: var(--gps-text-secondary);
    margin-bottom: 24px;
}

.gps-gateway-prompts {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 400px;
}

.gps-gateway-prompt {
    padding: 12px 16px;
    background: var(--gps-background);
    border: 1px solid var(--gps-border);
    border-radius: var(--gps-radius);
    cursor: pointer;
    text-align: left;
    transition: all var(--gps-transition);
}

.gps-gateway-prompt:hover {
    background: var(--gps-surface);
    border-color: var(--gps-primary);
}

/* ==================== Legal ==================== */

.gps-gateway-legal-tabs {
    display: flex;
    border-bottom: 2px solid var(--gps-border);
    margin-bottom: 20px;
}

.gps-gateway-legal-tab {
    padding: 12px 24px;
    font-weight: 500;
    color: var(--gps-text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all var(--gps-transition);
}

.gps-gateway-legal-tab:hover {
    color: var(--gps-primary);
}

.gps-gateway-legal-tab.active {
    color: var(--gps-primary);
    border-bottom-color: var(--gps-primary);
}

.gps-gateway-legal-panel {
    display: none;
}

.gps-gateway-legal-panel.active {
    display: block;
}

.gps-gateway-search-box {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
}

.gps-gateway-search-input {
    flex: 1;
}

.gps-gateway-search-filters {
    display: flex;
    gap: 12px;
}

.gps-gateway-case-result,
.gps-gateway-ocga-result {
    padding: 16px;
    border: 1px solid var(--gps-border);
    border-radius: var(--gps-radius);
    margin-bottom: 12px;
    cursor: pointer;
    transition: all var(--gps-transition);
}

.gps-gateway-case-result:hover,
.gps-gateway-ocga-result:hover {
    border-color: var(--gps-primary);
    box-shadow: var(--gps-shadow);
}

.gps-gateway-case-name {
    font-weight: 600;
    color: var(--gps-primary);
    margin-bottom: 4px;
}

.gps-gateway-case-citation {
    font-size: 13px;
    color: var(--gps-text-secondary);
    margin-bottom: 8px;
}

.gps-gateway-case-snippet {
    font-size: 14px;
    color: var(--gps-text-secondary);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.gps-gateway-saved-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border: 1px solid var(--gps-border);
    border-radius: var(--gps-radius);
    margin-bottom: 8px;
}

.gps-gateway-saved-item-content {
    flex: 1;
    min-width: 0;
}

.gps-gateway-saved-item-title {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gps-gateway-saved-item-type {
    font-size: 12px;
    color: var(--gps-text-muted);
}

/* ==================== Auth Modal ==================== */

.gps-gateway-modal-overlay {
    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;
    z-index: 99999;
    opacity: 0;
    visibility: hidden;
    transition: all var(--gps-transition);
}

.gps-gateway-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.gps-gateway-modal {
    background: var(--gps-surface);
    border-radius: var(--gps-radius);
    width: 100%;
    max-width: 400px;
    max-height: 90vh;
    overflow-y: auto;
    transform: translateY(20px);
    transition: transform var(--gps-transition);
}

.gps-gateway-modal-overlay.active .gps-gateway-modal {
    transform: translateY(0);
}

.gps-gateway-modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--gps-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.gps-gateway-modal-title {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
}

.gps-gateway-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--gps-text-secondary);
    padding: 0;
    line-height: 1;
}

.gps-gateway-modal-body {
    padding: 24px;
}

.gps-gateway-modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--gps-border);
    text-align: center;
}

.gps-gateway-auth-form .gps-gateway-btn {
    width: 100%;
    margin-top: 8px;
}

.gps-gateway-auth-footer {
    text-align: center;
    margin-top: 16px;
    font-size: 14px;
    color: var(--gps-text-secondary);
}

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

.gps-gateway-auth-footer a:hover {
    text-decoration: underline;
}

/* Auth Required Message */
.gps-gateway-auth-required {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    padding: 40px;
}

.gps-gateway-auth-message {
    text-align: center;
    max-width: 400px;
}

.gps-gateway-auth-message .dashicons {
    font-size: 48px;
    width: 48px;
    height: 48px;
    color: var(--gps-primary);
}

.gps-gateway-auth-message h3 {
    margin: 16px 0 8px;
}

.gps-gateway-auth-message p {
    color: var(--gps-text-secondary);
    margin-bottom: 20px;
}

.gps-gateway-register-prompt {
    margin-top: 16px;
    font-size: 14px;
}

/* ==================== Loading & States ==================== */

.gps-gateway-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.gps-gateway-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--gps-border);
    border-top-color: var(--gps-primary);
    border-radius: 50%;
    animation: gps-spin 0.8s linear infinite;
}

@keyframes gps-spin {
    to { transform: rotate(360deg); }
}

.gps-gateway-empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--gps-text-secondary);
}

.gps-gateway-empty .dashicons {
    font-size: 48px;
    width: 48px;
    height: 48px;
    opacity: 0.5;
}

.gps-gateway-alert {
    padding: 12px 16px;
    border-radius: var(--gps-radius-sm);
    margin-bottom: 16px;
}

.gps-gateway-alert-error {
    background: #ffebee;
    color: var(--gps-error);
    border: 1px solid #ffcdd2;
}

.gps-gateway-alert-success {
    background: #e8f5e9;
    color: var(--gps-success);
    border: 1px solid #c8e6c9;
}

/* ==================== Pagination ==================== */

.gps-gateway-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 24px;
}

.gps-gateway-pagination-btn {
    padding: 8px 16px;
    background: var(--gps-surface);
    border: 1px solid var(--gps-border);
    border-radius: var(--gps-radius-sm);
    cursor: pointer;
    transition: all var(--gps-transition);
}

.gps-gateway-pagination-btn:hover:not(:disabled) {
    background: var(--gps-background);
    border-color: var(--gps-primary);
}

.gps-gateway-pagination-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.gps-gateway-pagination-info {
    color: var(--gps-text-secondary);
    font-size: 14px;
}

/* ==================== Mobile Toggle ==================== */

.gps-gateway-mobile-toggle {
    display: none;
    padding: 12px;
    background: var(--gps-primary);
    color: #fff;
    border: none;
    cursor: pointer;
}

/* ==================== Back Button ==================== */

.gps-gateway-back-link {
    display: inline-flex;
    align-items: center;
    color: var(--gps-primary);
    text-decoration: none;
    font-size: 14px;
    margin-bottom: 16px;
}

.gps-gateway-back-link:hover {
    text-decoration: underline;
}

.gps-gateway-back-link .dashicons {
    margin-right: 4px;
}

/* ==================== Streaming Cursor ==================== */

.gps-gateway-typing-cursor {
    display: inline-block;
    width: 8px;
    height: 16px;
    background: var(--gps-text-primary);
    margin-left: 2px;
    animation: gps-blink 1s step-end infinite;
}

@keyframes gps-blink {
    50% { opacity: 0; }
}

/* ==================== Responsive ==================== */

@media (max-width: 1024px) {
    .gps-gateway-sidebar {
        width: 240px;
        min-width: 240px;
    }
    
    .gps-gateway-chat-sidebar {
        width: 240px;
    }
}

@media (max-width: 768px) {
    .gps-gateway-mobile-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 100%;
    }
    
    .gps-gateway-container {
        flex-direction: column;
    }
    
    .gps-gateway-sidebar {
        width: 100%;
        min-width: 100%;
        display: none;
    }
    
    .gps-gateway-sidebar.open {
        display: flex;
    }
    
    .gps-gateway-chat-container {
        flex-direction: column;
        height: auto;
        min-height: 500px;
    }
    
    .gps-gateway-chat-sidebar {
        width: 100%;
        max-height: 200px;
        border-right: none;
        border-bottom: 1px solid var(--gps-border);
    }
    
    .gps-gateway-chat-messages {
        min-height: 300px;
    }
    
    .gps-gateway-articles-grid {
        grid-template-columns: 1fr;
    }
    
    .gps-gateway-search-box {
        flex-direction: column;
    }
    
    .gps-gateway-search-filters {
        flex-direction: column;
    }
    
    .gps-gateway-legal-tabs {
        overflow-x: auto;
    }
    
    .gps-gateway-chat-message {
        max-width: 90%;
    }
}
