/* Co-Fleeter Design System
   Matches "Premium Maritime SaaS" aesthetic
*/

:root {
    /* Color Palette */
    --color-bg-dark: #0f172a;
    /* Slater Slate */
    --color-bg-card: #1e293b;
    /* Lighter Slate */
    --color-primary: #0ea5e9;
    /* Sky Blue */
    --color-primary-hover: #0284c7;
    --color-secondary: #0f766e;
    /* Teal/Ocean */
    --color-accent: #f59e0b;
    /* Amber/Warning */
    --color-danger: #ef4444;
    /* Red */
    --color-success: #10b981;
    /* Emerald */

    --color-text-main: #f8fafc;
    --color-text-muted: #94a3b8;
    --color-border: #334155;

    /* Spacing & Params */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;

    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);

    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
}

/* Reset & Base */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--color-bg-dark);
    color: var(--color-text-main);
    font-family: var(--font-sans);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

a {
    color: var(--color-primary);
    text-decoration: none;
    transition: color 0.2s;
}

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

button {
    font-family: inherit;
    cursor: pointer;
}

/* Utilities */
.hidden {
    display: none !important;
}

.flex {
    display: flex;
}

.grid {
    display: grid;
}

.grid-cols-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.flex-col {
    flex-direction: column;
}

.items-center {
    align-items: center;
}

.justify-center {
    justify-content: center;
}

.justify-between {
    justify-content: space-between;
}

.gap-1 {
    gap: 0.25rem;
}

.gap-2 {
    gap: 0.5rem;
}

.gap-4 {
    gap: 1rem;
}

.w-full {
    width: 100%;
}

.text-center {
    text-align: center;
}

.text-sm {
    font-size: 0.875rem;
}

.text-lg {
    font-size: 1.125rem;
}

.font-bold {
    font-weight: 700;
}

.text-muted {
    color: var(--color-text-muted);
}

.mt-4 {
    margin-top: 1rem;
}

.mb-4 {
    margin-bottom: 1rem;
}

.p-4 {
    padding: 1rem;
}

.p-8 {
    padding: 2rem;
}

/* Components */

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    font-weight: 500;
    transition: all 0.2s;
    border: none;
    outline: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%);
    color: white;
    box-shadow: var(--shadow-md);
}

.btn-primary:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--color-border);
    color: var(--color-text-muted);
}

.btn-outline:hover {
    border-color: var(--color-text-main);
    color: var(--color-text-main);
}

.btn-xs {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

/* Inputs */
.input-group {
    margin-bottom: 1rem;
    text-align: left;
}

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

.input-field {
    width: 100%;
    padding: 0.75rem 1rem;
    background-color: rgb(15 23 42 / 0.5);
    /* Semi-transparent */
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    color: white;
    font-size: 1rem;
    transition: border-color 0.2s;
}

.input-field:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(14, 165, 233, 0.2);
}

/* Cards */
.card {
    background-color: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 1.5rem;
}

/* Layout Specifics */
/* Login Page */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at top right, #1e293b 0%, #0f172a 100%);
    position: relative;
    overflow: hidden;
}

/* Background animated elements */
.bg-shape {
    position: absolute;
    filter: blur(100px);
    z-index: 0;
    opacity: 0.4;
}

.shape-1 {
    top: -10%;
    right: -10%;
    width: 600px;
    height: 600px;
    background: var(--color-primary);
    border-radius: 50%;
}

.shape-2 {
    bottom: -10%;
    left: -10%;
    width: 500px;
    height: 500px;
    background: var(--color-secondary);
    border-radius: 50%;
}

.login-box {
    width: 100%;
    max-width: 400px;
    z-index: 1;
    backdrop-filter: blur(12px);
    background-color: rgba(30, 41, 59, 0.7);
}

.brand-title {
    font-size: 2rem;
    font-weight: 800;
    background: linear-gradient(to right, #fff, #94a3b8);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
}

/* Dashboard Layout */
.dashboard-grid {
    display: grid;
    grid-template-columns: 240px 1fr;
    min-height: 100vh;
}

.sidebar {
    background-color: rgba(15, 23, 42, 0.95);
    border-right: 1px solid var(--color-border);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
}

.main-content {
    background-color: var(--color-bg-dark);
    padding: 2rem;
    overflow-y: auto;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--color-text-muted);
    border-radius: var(--radius-md);
    margin-bottom: 0.25rem;
    transition: all 0.2s;
}

.nav-link:hover,
.nav-link.active {
    background-color: rgba(14, 165, 233, 0.1);
    color: var(--color-primary);
}

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

.alert-error {
    background-color: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: #fca5a5;
}

.alert-success {
    background-color: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.2);
    color: #6ee7b7;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 400px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transform: translateX(400px);
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.toast-show {
    opacity: 1;
    transform: translateX(0);
}

.toast-hide {
    opacity: 0;
    transform: translateX(400px);
}

.toast-icon {
    font-size: 1.5rem;
    font-weight: bold;
    min-width: 24px;
    text-align: center;
}

.toast-message {
    flex: 1;
    font-size: 0.9rem;
    line-height: 1.4;
}

.toast-close {
    background: none;
    border: none;
    color: var(--color-text-muted);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.toast-close:hover {
    color: var(--color-text-main);
}

.toast-success {
    border-left: 4px solid var(--color-success);
}

.toast-success .toast-icon {
    color: var(--color-success);
}

.toast-error {
    border-left: 4px solid var(--color-danger);
}

.toast-error .toast-icon {
    color: var(--color-danger);
}

.toast-warning {
    border-left: 4px solid var(--color-accent);
}

.toast-warning .toast-icon {
    color: var(--color-accent);
}

.toast-info {
    border-left: 4px solid var(--color-primary);
}

.toast-info .toast-icon {
    color: var(--color-primary);
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9998;
}

.loading-spinner {
    text-align: center;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

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

.loading-text {
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

/* Button Loading State */
.btn-loading {
    position: relative;
    color: transparent !important;
}

.btn-spinner {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Skeleton Loading */
.skeleton-container {
    padding: 1rem;
}

.skeleton-line {
    height: 16px;
    background: linear-gradient(90deg,
            rgba(255, 255, 255, 0.05) 25%,
            rgba(255, 255, 255, 0.1) 50%,
            rgba(255, 255, 255, 0.05) 75%);
    background-size: 200% 100%;
    animation: skeleton-pulse 1.5s ease-in-out infinite;
    border-radius: 4px;
    margin-bottom: 12px;
}

.skeleton-line:last-child {
    width: 60%;
}

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

    100% {
        background-position: -200% 0;
    }
}

/* Form Validation */
.input-valid {
    border-color: var(--color-success) !important;
}

.input-invalid {
    border-color: var(--color-danger) !important;
}

.input-validation-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.2rem;
    pointer-events: none;
}

.input-valid+.input-validation-icon {
    color: var(--color-success);
}

.input-invalid+.input-validation-icon {
    color: var(--color-danger);
}

.input-error-message {
    color: var(--color-danger);
    font-size: 0.8rem;
    margin-top: 4px;
    display: block;
}

/* Password Strength Indicator */
.password-strength {
    margin-top: 8px;
    font-size: 0.8rem;
}

.password-strength-bar {
    height: 4px;
    background: var(--color-border);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 4px;
}

.password-strength-fill {
    height: 100%;
    transition: width 0.3s, background-color 0.3s;
}

.strength-very-weak .password-strength-fill {
    width: 20%;
    background-color: var(--color-danger);
}

.strength-weak .password-strength-fill {
    width: 40%;
    background-color: #f97316;
}

.strength-fair .password-strength-fill {
    width: 60%;
    background-color: var(--color-accent);
}

.strength-good .password-strength-fill {
    width: 80%;
    background-color: #84cc16;
}

.strength-strong .password-strength-fill {
    width: 100%;
    background-color: var(--color-success);
}

/* Admin Table & Data Grid */
.admin-table-container {
    max-height: 500px;
    overflow-y: auto;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: rgba(0,0,0,0.1);
}

.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    text-align: left;
    font-size: 0.9rem;
}

.data-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
    background-color: var(--color-bg-card);
}

.data-table th {
    padding: 0.75rem;
    font-weight: 600;
    color: var(--color-text-muted);
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
}

.data-table td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--color-border);
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table tr:hover {
    background-color: rgba(255,255,255,0.03);
}

.cell-numeric {
    text-align: right;
    font-family: 'Geist Mono', 'Fira Code', monospace;
}

.cell-error {
    color: var(--color-danger);
    font-weight: bold;
    background: rgba(239, 68, 68, 0.1);
}

.cell-empty {
    color: var(--color-text-muted);
    font-style: italic;
}

/* Section Header / Accordion */
.section-header {
    background-color: rgba(255,255,255,0.05);
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    font-weight: bold;
    color: var(--color-primary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
}

.section-header:hover {
    background-color: rgba(255,255,255,0.08);
}

.section-content {
    margin-bottom: 1rem;
    padding-left: 0.5rem;
    border-left: 2px solid var(--color-border);
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1;
}

.bg-primary { background-color: var(--color-primary); color: white; }
.bg-secondary { background-color: var(--color-secondary); color: white; }
.bg-danger { background-color: var(--color-danger); color: white; }
.bg-success { background-color: var(--color-success); color: white; }
.bg-warning { background-color: var(--color-accent); color: white; }

/* Mobile Responsive */
@media (max-width: 768px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    .sidebar {
        display: none; /* simple stack for now */
    }
    .toast-container {
        left: 10px;
        right: 10px;
        max-width: none;
    }

    .toast {
        transform: translateY(-100px);
    }

    .toast-show {
        transform: translateY(0);
    }
}

/* Fix for dark calendar icon */
input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(1);
    cursor: pointer;
}
