/**
 * Custom CSS
 * Theme system with CSS variables and dark mode support
 */

/* =====================================
   CSS Variables (Theme Colors)
   ===================================== */
:root {
    --color-primary: #3B82F6;
    --color-secondary: #1E40AF;
    --color-accent: #60A5FA;
    --transition-speed: 0.3s;
}

/* Apply theme colors */
.text-primary {
    color: var(--color-primary) !important;
}

.bg-primary {
    background-color: var(--color-primary) !important;
}

.border-primary {
    border-color: var(--color-primary) !important;
}

.hover\:bg-primary:hover {
    background-color: var(--color-primary) !important;
}

.hover\:text-primary:hover {
    color: var(--color-primary) !important;
}

/* Secondary colors */
.text-secondary {
    color: var(--color-secondary) !important;
}

.bg-secondary {
    background-color: var(--color-secondary) !important;
}

.hover\:text-secondary:hover {
    color: var(--color-secondary) !important;
}

/* Accent colors */
.text-accent {
    color: var(--color-accent) !important;
}

.bg-accent {
    background-color: var(--color-accent) !important;
}

/* =====================================
   Dark Mode Support
   ===================================== */
/* Only override in dark mode, let Tailwind handle light mode */
html.dark body {
    background-color: #111827 !important;
    color: #F9FAFB !important;
}

html.dark .bg-gray-50 {
    background-color: #111827 !important;
}

html.dark .bg-white {
    background-color: #1F2937 !important;
}

html.dark .text-gray-800 {
    color: #F9FAFB !important;
}

html.dark .text-gray-600 {
    color: #D1D5DB !important;
}

html.dark .text-gray-700 {
    color: #E5E7EB !important;
}

html.dark .text-gray-400 {
    color: #9CA3AF !important;
}

html.dark .border-gray-200 {
    border-color: #374151 !important;
}

html.dark .bg-gray-200 {
    background-color: #374151 !important;
}

html.dark .bg-gray-700 {
    background-color: #1F2937 !important;
}

/* Ensure Tailwind dark mode classes work */
html.dark {
    color-scheme: dark;
}

/* Light mode - ensure text is visible */
html:not(.dark) body {
    background-color: #F9FAFB;
    color: #1F2937;
}

html:not(.dark) .bg-gray-50 {
    background-color: #F9FAFB;
}

html:not(.dark) .bg-white {
    background-color: #FFFFFF;
}

html:not(.dark) .bg-gray-100 {
    background-color: #F3F4F6;
}

html:not(.dark) .bg-gray-200 {
    background-color: #E5E7EB;
}

html:not(.dark) .text-gray-800 {
    color: #1F2937;
}

html:not(.dark) .text-gray-700 {
    color: #374151;
}

html:not(.dark) .text-gray-600 {
    color: #4B5563;
}

html:not(.dark) .text-gray-400 {
    color: #9CA3AF;
}

html:not(.dark) .text-gray-300 {
    color: #D1D5DB;
}

html:not(.dark) .text-white {
    color: #FFFFFF;
}

html:not(.dark) .border-gray-200 {
    border-color: #E5E7EB;
}

/* Hero section gradient - ensure it shows in both modes */
.bg-gradient-to-r.from-primary.to-secondary {
    background: linear-gradient(to right, var(--color-primary), var(--color-secondary));
}

/* Ensure white text is visible on gradients */
.bg-gradient-to-r.from-primary.to-secondary .text-white,
.bg-gradient-to-r.from-primary.to-secondary h1,
.bg-gradient-to-r.from-primary.to-secondary p {
    color: #FFFFFF !important;
}

.text-gray-100 {
    color: #F3F4F6 !important;
}

.text-gray-200 {
    color: #E5E7EB !important;
}

/* =====================================
   Navigation Styles
   ===================================== */
.nav-link {
    color: #374151;
    font-weight: 500;
    transition: color 0.2s;
}

.dark .nav-link {
    color: #E5E7EB;
}

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

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

.nav-link-mobile {
    display: block;
    padding: 0.5rem 1rem;
    color: #374151;
    border-radius: 0.5rem;
    transition: background-color 0.2s, color 0.2s;
}

.dark .nav-link-mobile {
    color: #E5E7EB;
}

.nav-link-mobile:hover {
    background-color: #F3F4F6;
}

.dark .nav-link-mobile:hover {
    background-color: #374151;
}

/* =====================================
   Button Styles
   ===================================== */
.btn {
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-weight: 500;
    transition: all 0.2s;
    cursor: pointer;
    border: none;
    display: inline-block;
    text-decoration: none;
    text-align: center;
}

.btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.3);
}

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

.btn-primary:hover {
    opacity: 0.9;
}

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

.btn-secondary:hover {
    opacity: 0.9;
}

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

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

.btn-icon {
    padding: 0.5rem;
    border-radius: 0.5rem;
    color: #374151;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: background-color 0.2s;
}

.dark .btn-icon {
    color: #E5E7EB;
}

.btn-icon:hover {
    background-color: #F3F4F6;
}

.dark .btn-icon:hover {
    background-color: #374151;
}

/* Button ripple effect */
.btn {
    position: relative;
    overflow: hidden;
}

.btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.4s, height 0.4s;
}

.btn:active::after {
    width: 300px;
    height: 300px;
}

/* =====================================
   Card Styles
   ===================================== */
.card {
    background-color: white;
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    transition: all 0.3s;
}

.dark .card {
    background-color: #1F2937;
}

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

.card-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #E5E7EB;
}

.dark .card-header {
    border-bottom-color: #374151;
}

.card-body {
    padding: 1.5rem;
}

.card-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid #E5E7EB;
    background-color: #F9FAFB;
}

.dark .card-footer {
    border-top-color: #374151;
    background-color: #111827;
}

/* =====================================
   Form Styles
   ===================================== */
.form-input,
.form-textarea,
.form-select {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    border: 1px solid #D1D5DB;
    background-color: white;
    color: #111827;
    transition: all 0.2s;
}

.dark .form-input,
.dark .form-textarea,
.dark .form-select {
    border-color: #4B5563;
    background-color: #374151;
    color: #F9FAFB;
}

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

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
    margin-bottom: 0.5rem;
}

.dark .form-label {
    color: #D1D5DB;
}

.form-error {
    font-size: 0.875rem;
    color: #DC2626;
    margin-top: 0.25rem;
}

.dark .form-error {
    color: #F87171;
}

.form-help {
    font-size: 0.875rem;
    color: #6B7280;
    margin-top: 0.25rem;
}

.dark .form-help {
    color: #9CA3AF;
}

/* =====================================
   Tool Card Styles
   ===================================== */
.tool-card {
    background-color: white;
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    transition: all 0.3s;
    cursor: pointer;
}

.dark .tool-card {
    background-color: #1F2937;
}

.tool-card:hover {
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    transform: translateY(-4px);
}

.tool-card-icon {
    width: 3rem;
    height: 3rem;
    margin: 0 auto 1rem;
    color: var(--color-primary);
}

.tool-card-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: #1F2937;
    margin-bottom: 0.5rem;
}

.dark .tool-card-title {
    color: white;
}

.tool-card-description {
    font-size: 0.875rem;
    color: #4B5563;
    margin-bottom: 1rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.dark .tool-card-description {
    color: #9CA3AF;
}

/* =====================================
   Alert/Notification Styles
   ===================================== */
.alert {
    padding: 1rem;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    border: 1px solid;
}

.alert-success {
    background-color: #D1FAE5;
    color: #065F46;
    border-color: #A7F3D0;
}

.dark .alert-success {
    background-color: #064E3B;
    color: #A7F3D0;
    border-color: #065F46;
}

.alert-error {
    background-color: #FEE2E2;
    color: #991B1B;
    border-color: #FECACA;
}

.dark .alert-error {
    background-color: #7F1D1D;
    color: #FECACA;
    border-color: #991B1B;
}

.alert-warning {
    background-color: #FEF3C7;
    color: #92400E;
    border-color: #FDE68A;
}

.dark .alert-warning {
    background-color: #78350F;
    color: #FDE68A;
    border-color: #92400E;
}

.alert-info {
    background-color: #DBEAFE;
    color: #1E40AF;
    border-color: #BFDBFE;
}

.dark .alert-info {
    background-color: #1E3A8A;
    color: #BFDBFE;
    border-color: #1E40AF;
}

/* =====================================
   Toast Notification (JavaScript)
   ===================================== */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    min-width: 250px;
    max-width: 400px;
    padding: 1rem 1.5rem;
    background: white;
    border-radius: 0.5rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    z-index: 9999;
    animation: slideInRight 0.3s ease-out;
}

.dark .toast {
    background: #1F2937;
    color: #F9FAFB;
}

@keyframes slideInRight {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(400px);
        opacity: 0;
    }
}

.toast.hiding {
    animation: slideOutRight 0.3s ease-out;
}

/* =====================================
   Loading States
   ===================================== */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
}

.dark .skeleton {
    background: linear-gradient(90deg, #374151 25%, #4B5563 50%, #374151 75%);
    background-size: 200% 100%;
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

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

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

/* =====================================
   Code Block Styles
   ===================================== */
.code-block {
    background-color: #F3F4F6;
    border-radius: 0.5rem;
    padding: 1rem;
    overflow-x: auto;
}

.dark .code-block {
    background-color: #111827;
}

.code-block code {
    font-size: 0.875rem;
    font-family: monospace;
    color: #1F2937;
}

.dark .code-block code {
    color: #E5E7EB;
}

/* =====================================
   Table Styles
   ===================================== */
.table {
    width: 100%;
    border-collapse: collapse;
}

.table thead {
    background-color: #F9FAFB;
}

.dark .table thead {
    background-color: #374151;
}

.table th {
    padding: 0.75rem 1.5rem;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 500;
    color: #6B7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.dark .table th {
    color: #D1D5DB;
}

.table td {
    padding: 1rem 1.5rem;
    white-space: nowrap;
    font-size: 0.875rem;
    color: #111827;
}

.dark .table td {
    color: #F9FAFB;
}

.table tbody tr {
    border-bottom: 1px solid #E5E7EB;
    transition: background-color 0.2s;
}

.dark .table tbody tr {
    border-bottom-color: #374151;
}

.table tbody tr:hover {
    background-color: #F9FAFB;
}

.dark .table tbody tr:hover {
    background-color: #374151;
}

/* =====================================
   Utility Classes
   ===================================== */
.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.line-clamp-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.smooth-transition {
    transition: all var(--transition-speed) ease;
}

.hover-lift {
    transition: transform 0.3s, box-shadow 0.3s;
}

.hover-lift:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

/* =====================================
   Scrollbar Styling
   ===================================== */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.dark ::-webkit-scrollbar-track {
    background: #1F2937;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.dark ::-webkit-scrollbar-thumb {
    background: #4B5563;
}

.dark ::-webkit-scrollbar-thumb:hover {
    background: #6B7280;
}
