/* ===========================
   DARK THEME STYLESHEET
   (ODT) Omnichannel Distribution Tool | Powered by R.I.Y.A 3rd Gen
   =========================== */

/* ===========================
   ROOT & VARIABLES
   =========================== */

:root {
    --color-bg-primary: #09090b;
    --color-bg-secondary: #18181b;
    --color-bg-tertiary: #27272a;
    --color-bg-quaternary: #3f3f46;

    --color-text-primary: #fafafa;
    --color-text-secondary: #a1a1a1;
    --color-text-tertiary: #71717a;

    --color-border: #27272a;
    --color-border-light: #3f3f46;

    --color-accent-primary: #3b82f6;
    --color-accent-primary-dark: #1e40af;
    --color-accent-primary-light: #60a5fa;

    --color-success: #10b981;
    --color-warning: #f59e0b;
    --color-danger: #ef4444;
    --color-info: #3b82f6;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.2);
    --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.3);
    --shadow-blue: 0 4px 20px rgba(59, 130, 246, 0.15);

    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);

    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.875rem;
    --radius-xl: 1.25rem;
    --radius-2xl: 1.5rem;
}

/* ===========================
   LAYOUT & STRUCTURE
   =========================== */

html {
    background: var(--color-bg-primary);
    color: var(--color-text-primary);
}

body {
    background: var(--color-bg-primary);
    color: var(--color-text-primary);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Main Content */
main {
    background: var(--color-bg-primary);
    min-height: 100vh;
}

/* ===========================
   CARDS & CONTAINERS
   =========================== */

.card,
.panel,
[class*="card"],
[class*="panel"] {
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    transition: all var(--transition-base);
}

.card:hover,
.panel:hover {
    border-color: var(--color-border-light);
    box-shadow: var(--shadow-blue);
}

.card.elevated {
    box-shadow: var(--shadow-lg);
}

/* ===========================
   TYPOGRAPHY
   =========================== */

h1, h2, h3, h4, h5, h6 {
    color: var(--color-text-primary);
    font-weight: 700;
    line-height: 1.2;
}

h1 { font-size: 2.25rem; letter-spacing: -0.02em; }
h2 { font-size: 1.875rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }
h5 { font-size: 1.125rem; }
h6 { font-size: 1rem; }

p {
    color: var(--color-text-secondary);
    line-height: 1.6;
}

a {
    color: var(--color-accent-primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--color-accent-primary-light);
}

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

.text-subtle {
    color: var(--color-text-tertiary);
}

/* ===========================
   BUTTONS
   =========================== */

button,
.btn,
[class*="btn"] {
    padding: 0.625rem 1.25rem;
    border-radius: var(--radius-md);
    border: none;
    font-weight: 600;
    font-size: 0.9375rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    white-space: nowrap;
}

/* Primary Button */
.btn-primary,
button.bg-blue-600,
button[type="submit"] {
    background: var(--color-accent-primary);
    color: white;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.25);
}

.btn-primary:hover,
button.bg-blue-600:hover {
    background: var(--color-accent-primary-dark);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.35);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(0);
}

/* Secondary Button */
.btn-secondary {
    background: var(--color-bg-tertiary);
    color: var(--color-text-primary);
    border: 1px solid var(--color-border-light);
}

.btn-secondary:hover {
    background: var(--color-bg-quaternary);
    border-color: var(--color-accent-primary);
}

/* Danger Button */
.btn-danger {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: #ef4444;
}

/* Icon Button */
.btn-icon {
    padding: 0.625rem;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 0.5rem;
}

/* Disabled State */
button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* ===========================
   FORMS & INPUTS
   =========================== */

input,
textarea,
select {
    width: 100%;
    padding: 0.875rem 1rem;
    background: var(--color-bg-tertiary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text-primary);
    font-family: inherit;
    font-size: 0.9375rem;
    transition: all var(--transition-fast);
    min-height: 40px;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

input::placeholder,
textarea::placeholder {
    color: var(--color-text-tertiary);
}

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

input:disabled,
textarea:disabled,
select:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

textarea {
    resize: vertical;
    min-height: 6rem;
}

select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23a1a1a1' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2.5rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--color-text-secondary);
    font-weight: 500;
    font-size: 0.875rem;
}

/* ===========================
   MODALS & OVERLAYS
   =========================== */

.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal.active {
    display: flex;
    animation: fadeIn var(--transition-base);
}

.modal-content {
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    max-width: 500px;
    width: 100%;
    padding: 2rem;
    animation: slideUp var(--transition-base);
}

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

.modal-header h2 {
    margin: 0;
}

.modal-footer {
    margin-top: 1.5rem;
    border-top: 1px solid var(--color-border);
    padding-top: 1rem;
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

.modal-footer button {
    flex: 1;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

/* ===========================
   BADGES & PILLS
   =========================== */

.badge,
.pill,
[class*="badge"] {
    display: inline-block;
    padding: 0.375rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge-primary {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.badge-success {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.badge-danger {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* ===========================
   ALERTS & MESSAGES
   =========================== */

.alert {
    padding: 1rem;
    border-radius: var(--radius-lg);
    border: 1px solid;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.alert-info {
    background: rgba(59, 130, 246, 0.05);
    border-color: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
}

.alert-success {
    background: rgba(16, 185, 129, 0.05);
    border-color: rgba(16, 185, 129, 0.2);
    color: #10b981;
}

.alert-warning {
    background: rgba(245, 158, 11, 0.05);
    border-color: rgba(245, 158, 11, 0.2);
    color: #f59e0b;
}

.alert-danger {
    background: rgba(239, 68, 68, 0.05);
    border-color: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

/* ===========================
   TABLES
   =========================== */

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9375rem;
}

th {
    background: var(--color-bg-tertiary);
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--color-text-secondary);
    border-bottom: 2px solid var(--color-border);
    white-space: nowrap;
}

td {
    padding: 1rem;
    border-bottom: 1px solid var(--color-border);
}

tbody tr:hover {
    background: rgba(59, 130, 246, 0.03);
}

tbody tr:last-child td {
    border-bottom: none;
}

/* ===========================
   UTILITIES
   =========================== */

.divider {
    height: 1px;
    background: var(--color-border);
    margin: 1.5rem 0;
}

.glass {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.gradient-text {
    background: linear-gradient(135deg, var(--color-accent-primary), var(--color-accent-primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.loader {
    width: 40px;
    height: 40px;
    border: 4px solid var(--color-bg-tertiary);
    border-top-color: var(--color-accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ===========================
   RESPONSIVE GRID
   =========================== */

.grid-auto {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}

@media (max-width: 768px) {
    .grid-2,
    .grid-3 {
        grid-template-columns: 1fr;
    }

    h1 { font-size: 1.875rem; }
    h2 { font-size: 1.5rem; }
    h3 { font-size: 1.25rem; }
}

/* ===========================
   SCROLLBAR STYLING
   =========================== */

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--color-bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--color-bg-tertiary);
    border-radius: 4px;
    transition: background var(--transition-fast);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--color-border-light);
}

/* ===========================
   ACCESSIBILITY
   =========================== */

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Focus visible for keyboard navigation */
button:focus-visible,
a:focus-visible,
input:focus-visible {
    outline: 2px solid var(--color-accent-primary);
    outline-offset: 2px;
}

/* ===========================
   ANIMATIONS
   =========================== */

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes shimmer {
    0% { background-position: -1000px 0; }
    100% { background-position: 1000px 0; }
}

.animate-pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.animate-shimmer {
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
    background-size: 1000px 100%;
    animation: shimmer 2s infinite;
}

/* ===========================
   TEXT OVERFLOW & WRAPPING
   =========================== */

.break-words {
    word-break: break-word;
    overflow-wrap: break-word;
}

.truncate-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.text-wrap {
    word-wrap: break-word;
    word-break: break-word;
    overflow-wrap: break-word;
}

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

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

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

/* ===========================
   CARD IMPROVEMENTS
   =========================== */

.card {
    overflow: hidden;
}

.card-content {
    overflow: auto;
}

.card p {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Better flex layouts for cards */
.flex-safe {
    display: flex;
    min-width: 0;
}

.flex-safe > * {
    min-width: 0;
}

/* Posting box specific improvements */
.posting-box {
    padding: 1.5rem;
    border-radius: 0.875rem;
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
}

.posting-box-header {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 1rem;
    align-items: flex-start;
    min-height: 5rem;
}

.posting-box-header-left {
    min-width: 0;
    overflow: hidden;
}

.posting-box-header-left p {
    word-break: break-word;
    overflow-wrap: break-word;
    line-height: 1.4;
}

.posting-box-header-right {
    text-align: right;
    flex-shrink: 0;
    white-space: nowrap;
}

/* Compact match results grid */
#matchResults {
    display: grid;
    gap: 0.75rem;
}

#matchResults .card {
    padding: 1rem;
}

/* Compact mindset suggestions */
#mindsetSuggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

#mindsetSuggestions label {
    display: inline-flex;
    align-items: center;
    font-size: 0.75rem;
}

/* Preview section styling */
#previewSection {
    animation: slideDown 300ms ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        max-height: 0;
    }
    to {
        opacity: 1;
        max-height: 500px;
    }
}

#previewImages {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    align-items: center;
    justify-items: center;
}

#previewImages img {
    width: 100%;
    height: 80px;
    object-fit: cover;
    border-radius: 0.375rem;
    border: 1px solid var(--color-border);
}

#previewServers {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
}
