/* Enhanced UDSM Dashboard CSS */

/* CSS Variables with Dark Mode Support */
:root {
    --udsm-green: #2d5016;
    --udsm-green-light: #4a7c59;
    --udsm-green-dark: #1a2f0c;
    --udsm-gold: #fdb913;
    --udsm-gold-light: #ffc940;
    --udsm-gold-dark: #e6a000;
    
    --background: #f8f9fa;
    --background-secondary: #e9ecef;
    --surface: #ffffff;
    --surface-hover: #f1f5f9;
    --surface-elevated: #ffffff;
    
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --text-tertiary: #adb5bd;
    --text-inverse: #ffffff;
    
    --border: #dee2e6;
    --border-light: #f1f3f4;
    --border-strong: #adb5bd;
    
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.15);
    
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    
    --transition-fast: all 0.15s ease-out;
    --transition-medium: all 0.2s ease-out;
    --transition-slow: all 0.3s ease-out;
    
    --success: #28a745;
    --warning: #ffc107;
    --error: #dc3545;
    --info: #17a2b8;
}

/* Dark Mode Variables */
@media (prefers-color-scheme: dark) {
    :root {
        --background: #0d1117;
        --background-secondary: #161b22;
        --surface: #21262d;
        --surface-hover: #30363d;
        --surface-elevated: #262c36;
        
        --text-primary: #f0f6fc;
        --text-secondary: #8b949e;
        --text-tertiary: #6e7681;
        
        --border: #30363d;
        --border-light: #21262d;
        --border-strong: #8b949e;
        
        --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
        --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
        --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.5);
        --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.6);
    }
}

/* Base Styles */
* {
    box-sizing: border-box;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--background);
    color: var(--text-primary);
    margin: 0;
    padding: 0;
    line-height: 1.6;
    font-feature-settings: "cv03", "cv04", "cv11";
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: var(--transition-medium);
}

/* Enhanced Header */
header {
    background: linear-gradient(135deg, var(--udsm-green) 0%, var(--udsm-green-dark) 100%);
    color: var(--text-inverse);
    padding: 2rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 5px solid var(--udsm-gold);
    position: relative;
    overflow: hidden;
}

header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grid" width="10" height="10" patternUnits="userSpaceOnUse"><path d="M 10 0 L 0 0 0 10" fill="none" stroke="rgba(255,255,255,0.03)" stroke-width="1"/></pattern></defs><rect width="100" height="100" fill="url(%23grid)"/></svg>');
    pointer-events: none;
}

header .logo {
    position: relative;
    z-index: 1;
}

header .logo img {
    height: 70px;
    margin-right: 1.5rem;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
    transition: var(--transition-medium);
}

header .logo img:hover {
    transform: scale(1.05);
}

header .header-content {
    position: relative;
    z-index: 1;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin: 0;
    background: linear-gradient(135deg, var(--text-inverse) 0%, var(--udsm-gold-light) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

header p {
    font-size: 1.2rem;
    opacity: 0.9;
    margin: 0.5rem 0 0;
    font-weight: 300;
}

/* Enhanced Main Layout */
main {
    max-width: 1400px;
    margin: 3rem auto;
    padding: 0 1.5rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 2rem;
    animation: fadeInUp 0.6s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Enhanced Card Styling */
.tool-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 2rem;
    position: relative;
    overflow: hidden;
    transition: var(--transition-medium);
    backdrop-filter: blur(10px);
}

.tool-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--udsm-green) 0%, var(--udsm-gold) 100%);
    transform: scaleX(0);
    transform-origin: left;
    transition: var(--transition-medium);
}

.tool-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--udsm-green);
}

.tool-card:hover::before {
    transform: scaleX(1);
}

.wide-card {
    grid-column: 1 / -1;
}

.tool-card h2 {
    color: var(--udsm-green);
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0 0 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border-light);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    position: relative;
}

.tool-card h2::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 50px;
    height: 2px;
    background: linear-gradient(90deg, var(--udsm-green) 0%, var(--udsm-gold) 100%);
    border-radius: 2px;
}

.tool-card h2 i {
    font-size: 1.2rem;
    color: var(--udsm-gold);
    padding: 0.5rem;
    background: var(--udsm-gold);
    background: linear-gradient(135deg, var(--udsm-gold) 0%, var(--udsm-gold-light) 100%);
    color: var(--text-inverse);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

/* Enhanced Button Styling */
button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    border-radius: var(--radius-md);
    padding: 0.875rem 2rem;
    font-weight: 600;
    font-size: 1rem;
    transition: var(--transition-medium);
    position: relative;
    overflow: hidden;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: var(--shadow-sm);
}

button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: var(--transition-medium);
}

button:hover::before {
    left: 100%;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

button:active {
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}

.btn-primary {
    background: linear-gradient(135deg, var(--udsm-green) 0%, var(--udsm-green-light) 100%);
    color: var(--text-inverse);
}

.btn-secondary {
    background: linear-gradient(135deg, var(--udsm-gold) 0%, var(--udsm-gold-light) 100%);
    color: var(--udsm-green);
}

.btn-outline {
    background: transparent;
    color: var(--udsm-green);
    border: 2px solid var(--udsm-green);
}

.btn-outline:hover {
    background: var(--udsm-green);
    color: var(--text-inverse);
}

/* Enhanced Dashboard */
.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 2rem;
    align-items: start;
}

.chart-container {
    position: relative;
    overflow: hidden;
    border-radius: var(--radius-lg);
}

.chart-placeholder {
    min-height: 300px;
    background: linear-gradient(135deg, var(--background-secondary) 0%, var(--border-light) 100%);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 1.1rem;
    font-weight: 500;
    position: relative;
    overflow: hidden;
}

.chart-placeholder::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 10px,
        rgba(0, 0, 0, 0.02) 10px,
        rgba(0, 0, 0, 0.02) 20px
    );
}

.info-container {
    background: var(--surface-elevated);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.info-container h3 {
    margin-top: 0;
    color: var(--udsm-green);
    font-size: 1.3rem;
    font-weight: 600;
}

.insights-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.insights-list li {
    padding: 1rem 0;
    display: flex;
    align-items: center;
    gap: 1rem;
    border-bottom: 1px solid var(--border-light);
    transition: var(--transition-fast);
    cursor: pointer;
}

.insights-list li:last-child {
    border-bottom: none;
}

.insights-list li:hover {
    background: var(--surface-hover);
    margin: 0 -1rem;
    padding-left: 1rem;
    padding-right: 1rem;
    border-radius: var(--radius-sm);
}

.insights-list li i {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 0.9rem;
}

.insights-list .fa-lightbulb {
    color: var(--udsm-gold);
    background: rgba(253, 185, 19, 0.1);
}

.insights-list .fa-triangle-exclamation {
    color: var(--error);
    background: rgba(220, 53, 69, 0.1);
}

.insights-list .fa-users,
.insights-list .fa-map-marker-alt {
    color: var(--udsm-green);
    background: rgba(45, 80, 22, 0.1);
}

/* Enhanced Survey Styling */
.survey-container {
    max-width: 600px;
    margin: 0 auto;
}

.survey-question {
    margin-bottom: 2rem;
}

.survey-question label {
    display: block;
    margin-bottom: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1.1rem;
}

.rating-buttons {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
}

.rating-btn {
    width: 60px;
    height: 60px;
    border: 2px solid var(--border);
    background: var(--surface);
    color: var(--text-primary);
    font-size: 1.4rem;
    font-weight: 700;
    border-radius: 50%;
    transition: var(--transition-medium);
    position: relative;
    overflow: hidden;
}

.rating-btn:hover {
    background: var(--udsm-gold);
    border-color: var(--udsm-gold);
    color: var(--text-inverse);
    transform: scale(1.1);
}

.rating-btn.selected {
    background: var(--udsm-green);
    color: var(--text-inverse);
    border-color: var(--udsm-green);
    transform: scale(1.1);
    box-shadow: var(--shadow-md);
}

.rating-btn.selected::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 80%;
    height: 80%;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(1.4);
        opacity: 0;
    }
}

#survey-result-area {
    text-align: center;
    margin-top: 2rem;
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    transition: var(--transition-medium);
}

.survey-result.ok {
    background: linear-gradient(135deg, #e8f5e9 0%, #f1f8e9 100%);
    color: var(--success);
    border: 1px solid rgba(40, 167, 69, 0.2);
}

/* Enhanced Research Repository */
.research-feed {
    max-height: 400px;
    overflow-y: auto;
    padding-right: 0.5rem;
    scrollbar-width: thin;
    scrollbar-color: var(--border) var(--background);
}

.research-feed::-webkit-scrollbar {
    width: 6px;
}

.research-feed::-webkit-scrollbar-track {
    background: var(--background);
    border-radius: 3px;
}

.research-feed::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.research-feed::-webkit-scrollbar-thumb:hover {
    background: var(--border-strong);
}

.research-item {
    display: block;
    padding: 1.5rem;
    margin-bottom: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    text-decoration: none;
    color: inherit;
    transition: var(--transition-medium);
    position: relative;
    overflow: hidden;
}

.research-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--udsm-green);
    transform: scaleY(0);
    transition: var(--transition-medium);
}

.research-item:hover {
    background: var(--surface-hover);
    border-color: var(--udsm-green);
    transform: translateX(4px);
    box-shadow: var(--shadow-md);
}

.research-item:hover::before {
    transform: scaleY(1);
}

.research-item strong {
    color: var(--udsm-green);
    font-size: 1.2rem;
    font-weight: 600;
    display: block;
    margin-bottom: 0.5rem;
}

.research-item span {
    color: var(--text-secondary);
    font-size: 0.95rem;
    display: block;
    margin-top: 0.5rem;
    font-weight: 400;
}

.research-item .tags {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
    flex-wrap: wrap;
}

.research-item .tag {
    background: var(--udsm-gold);
    color: var(--text-inverse);
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* Loading States */
.loading {
    position: relative;
    opacity: 0.7;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top: 2px solid var(--udsm-green);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    transform: translate(-50%, -50%);
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Success States */
.success-message {
    background: var(--surface);
    border: 1px solid var(--success);
    color: var(--success);
    padding: 1rem;
    border-radius: var(--radius-md);
    margin: 1rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    header {
        flex-direction: column;
        text-align: center;
        padding: 1.5rem;
    }
    
    header .logo img {
        height: 50px;
        margin-right: 0;
        margin-bottom: 1rem;
    }
    
    header h1 {
        font-size: 1.8rem;
    }
    
    header p {
        font-size: 1rem;
    }
    
    main {
        grid-template-columns: 1fr;
        gap: 1.5rem;
        margin: 2rem auto;
        padding: 0 1rem;
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    .tool-card {
        padding: 1.5rem;
    }
    
    .rating-buttons {
        gap: 0.5rem;
    }
    
    .rating-btn {
        width: 50px;
        height: 50px;
        font-size: 1.2rem;
    }
    
    button {
        padding: 0.75rem 1.5rem;
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .tool-card h2 {
        font-size: 1.3rem;
    }
    
    .research-item {
        padding: 1rem;
    }
    
    .rating-buttons {
        gap: 0.25rem;
    }
    
    .rating-btn {
        width: 45px;
        height: 45px;
        font-size: 1.1rem;
    }
}

/* Print Styles */
@media print {
    header {
        background: white !important;
        color: black !important;
        border-bottom: 2px solid #333 !important;
    }
    
    .tool-card {
        box-shadow: none !important;
        border: 1px solid #333 !important;
        break-inside: avoid;
    }
    
    button {
        display: none !important;
    }
    
    .chart-placeholder {
        border: 1px solid #333 !important;
    }
}

/* Focus Styles for Accessibility */
button:focus,
.research-item:focus,
.rating-btn:focus {
    outline: 2px solid var(--udsm-green);
    outline-offset: 2px;
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}