/* CSS Variables */
:root {
    --primary-color: #0066cc;
    --primary-hover: #0052a3;
    --secondary-color: #6c757d;
    --success-color: #28a745;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --light-color: #f8f9fa;
    --dark-color: #343a40;
    --border-color: #dee2e6;
    --text-color: #212529;
    --text-muted: #6c757d;
    --shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    --radius: 8px;
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}

/* Reset */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    color: var(--text-color);
    line-height: 1.6;
    background-color: var(--light-color);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    background: white;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

.logo-img {
    height: 40px;
    width: auto;
    max-width: 200px;
    object-fit: contain;
}

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

.nav-link {
    color: var(--text-color);
    text-decoration: none;
    padding: 0.5rem 0;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

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

.user-menu {
    display: flex;
    align-items: center;
    gap: 1rem;
}

#userName {
    font-weight: 500;
}

/* Main Content */
.main {
    flex: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    width: 100%;
}

/* Hero Section */
.hero {
    text-align: center;
    padding: 3rem 0;
}

.hero h2 {
    font-size: 2rem;
    margin-bottom: 1rem;
}

.hero p {
    color: var(--text-muted);
    font-size: 1.125rem;
}

/* Cards */
.card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card h3 {
    margin-bottom: 1rem;
    color: var(--dark-color);
}

/* Status Sections */
.status-section {
    margin-bottom: 2rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    font-size: 1rem;
    font-weight: 500;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

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

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

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

.btn-secondary:hover {
    background: #5a6268;
}

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

.btn-danger:hover {
    background: #c82333;
}

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

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

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

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

.form-input:focus,
.form-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
}

.form-hint {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.form-error {
    color: var(--danger-color);
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

/* Action Cards */
.action-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.action-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2rem;
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-decoration: none;
    color: var(--text-color);
    transition: transform 0.2s, box-shadow 0.2s;
}

.action-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.action-icon {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.action-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.action-desc {
    font-size: 0.875rem;
    color: var(--text-muted);
    text-align: center;
}

/* Resource Cards (Dashboard) */
.resource-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
}

.resource-card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    position: relative;
}

.resource-card.expiring {
    border-left: 4px solid var(--warning-color);
}

.resource-card.high-cost {
    border-left: 4px solid var(--danger-color);
}

.resource-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.resource-name {
    font-weight: 600;
    font-size: 1rem;
    word-break: break-word;
}

.resource-type {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    background: var(--light-color);
    color: var(--text-muted);
}

.resource-meta {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.resource-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

/* Activity Badges */
.activity-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
}

.activity-high {
    background: #d4edda;
    color: #155724;
}

.activity-medium {
    background: #fff3cd;
    color: #856404;
}

.activity-low {
    background: #f8d7da;
    color: #721c24;
}

.activity-none {
    background: var(--light-color);
    color: var(--text-muted);
}

/* Cost Display */
.cost-display {
    font-weight: 600;
}

.cost-warning {
    color: var(--danger-color);
}

/* Loading States */
.loading {
    color: var(--text-muted);
    font-style: italic;
}

.spinner {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Alerts */
.alert {
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeeba;
}

.alert-danger {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert-info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* Modal */
.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: 1000;
}

.modal {
    background: white;
    border-radius: var(--radius);
    padding: 2rem;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    margin-bottom: 1.5rem;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 600;
}

.modal-body {
    margin-bottom: 1.5rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

/* Filters */
.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Footer */
.footer {
    background: var(--dark-color);
    color: white;
    text-align: center;
    padding: 1.5rem;
    margin-top: auto;
}

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

    .nav {
        order: 3;
        width: 100%;
        justify-content: center;
        margin-top: 1rem;
    }

    .main {
        padding: 1rem;
    }

    .hero {
        padding: 2rem 0;
    }

    .hero h2 {
        font-size: 1.5rem;
    }

    .filters {
        flex-direction: column;
    }

    .modal {
        margin: 1rem;
    }
}

/* User Search and Selection Styles */
.user-search-container {
    position: relative;
}

.search-results-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    max-height: 300px;
    overflow-y: auto;
    z-index: 50;
}

.search-result-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover,
.search-result-item.highlighted {
    background-color: var(--light-color);
}

.search-result-item strong {
    color: var(--text-color);
}

.selected-users-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.5rem;
    min-height: 2.5rem;
    background: var(--light-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
}

.user-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.5rem 0.375rem 0.75rem;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    font-size: 0.875rem;
}

.user-chip-name {
    font-weight: 500;
    color: var(--text-color);
}

.user-chip-email {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.user-chip-remove {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.25rem;
    line-height: 1;
    padding: 0;
    margin-left: 0.25rem;
}

.user-chip-remove:hover {
    color: var(--danger-color);
}

/* Mobile styles for user selection */
@media (max-width: 768px) {
    .search-results-dropdown {
        max-height: 200px;
    }

    .user-chip {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.125rem;
        padding: 0.5rem 0.75rem;
    }

    .user-chip-remove {
        position: absolute;
        top: 0.25rem;
        right: 0.5rem;
    }

    .user-chip {
        position: relative;
        padding-right: 2rem;
    }
}

/* User Source Tabs */
.user-source-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 1rem;
    border-bottom: 2px solid var(--border-color);
}

.user-source-tab {
    padding: 0.75rem 1.5rem;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    color: var(--text-muted);
    font-weight: 500;
    transition: all 0.2s ease;
}

.user-source-tab:hover {
    color: var(--text-color);
    background: var(--light-color);
}

.user-source-tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.user-source-content {
    display: none;
}

.user-source-content.active {
    display: block;
}

/* Organization Members Selection List */
.org-members-select-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 0.5rem;
}

.org-member-select-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.2s ease;
}

.org-member-select-item:hover {
    background: var(--light-color);
}

.org-member-avatar-sm {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.org-member-login {
    font-weight: 500;
    flex: 1;
}

/* Organization Members Admin List (Dashboard) */
.org-members-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.org-member-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--light-color);
    border-radius: var(--radius);
}

.org-member-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.org-member-info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.org-member-role {
    font-size: 0.75rem;
    padding: 0.125rem 0.5rem;
}

.org-member-remove {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 999px;
}

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

.badge-secondary {
    background: var(--border-color);
    color: var(--text-color);
}

/* Cost Widget Styling */
.costs-panel {
    padding: 1.5rem;
}

.cost-section {
    margin-bottom: 2rem;
}

.cost-section h4 {
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.cost-total {
    font-size: 2rem;
    font-weight: 700;
    color: #28a745;
    margin: 1rem 0;
}

.cost-metadata,
.cost-footnote {
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.cost-footnote {
    font-size: 0.9rem;
    margin-top: 1rem;
}

.cost-loading,
.cost-warning {
    margin-top: 0.75rem;
    color: var(--text-muted);
}

.cost-warning {
    color: var(--warning-color);
}

.cost-breakdown {
    background: var(--light-color);
    padding: 1rem;
    border-radius: var(--radius);
    margin-top: 0.5rem;
}

.cost-item {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
}

.cost-item:last-child {
    border-bottom: none;
}

.cost-item .rg-name,
.cost-item .office-name {
    font-weight: 500;
}

.cost-item .cost-amount {
    font-weight: 700;
    color: var(--primary-color);
}

.cost-breakdown .label {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}
