/**
 * Storesync CRM - Custom Styles
 * This file contains all custom styles for the lead-to-lease CRM system
 * Built to match the Storesync design system
 */

/* ===================================
   CSS Variables & Global Styles
   =================================== */

:root {
    /* Brand Colors */
    --storesync-primary: #6366F1;
    --storesync-primary-hover: #4F46E5;
    --storesync-secondary: #FD9E27;
    --storesync-secondary-hover: #E58D1D;
    --text-primary: #1F2937;
    --text-secondary: #4B5563;
    --text-tertiary: #9CA3AF;
    --bg-white: #FFFFFF;
    --bg-light: #F9FAFB;
    --bg-dark: #111827;
    --border-light: #E5E7EB;
    --border-medium: #D1D5DB;

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

    /* Border Radius */
    --radius-sm: 0.25rem;
    --radius-md: 0.375rem;
    --radius-lg: 0.5rem;
}

/* Global font family override */
body, * {
    font-family: 'Outfit', sans-serif;
}

/* ===================================
   Button Styles
   =================================== */

.storesync-btn {
    padding: 8px 12px !important;
    font-size: 13px !important;
    line-height: 1.2 !important;
    border-radius: 4px !important;
    font-weight: 500 !important;
    transition: all 0.2s ease !important;
    cursor: pointer;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.storesync-btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

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

.storesync-btn-primary:hover {
    background-color: var(--storesync-primary-hover) !important;
}

.storesync-btn-secondary {
    background-color: var(--storesync-secondary) !important;
    color: var(--text-primary) !important;
}

.storesync-btn-secondary:hover {
    background-color: var(--storesync-secondary-hover) !important;
}

.storesync-btn-ghost {
    background-color: transparent !important;
    color: var(--storesync-primary) !important;
    padding: 8px 0 !important;
    position: relative;
}

.storesync-btn-ghost::after {
    content: '';
    position: absolute;
    width: 100%;
    transform: scaleX(0);
    height: 2px;
    bottom: 0;
    left: 0;
    background-color: currentColor;
    transform-origin: bottom right;
    transition: transform 0.3s ease-out;
}

.storesync-btn-ghost:hover::after {
    transform: scaleX(1);
    transform-origin: bottom left;
}

/* ===================================
   Form Input Styles
   =================================== */

.storesync-input {
    height: 40px !important;
    padding: 8px 12px !important;
    font-size: 13px !important;
    line-height: 1.2 !important;
    border-radius: 4px !important;
    transition: border-color 0.2s ease, box-shadow 0.2s ease !important;
    border: 1px solid var(--border-light) !important;
    background-color: var(--bg-white) !important;
    color: var(--text-primary) !important;
    width: 100% !important;
    outline: none !important;
}

.storesync-input:focus {
    border-color: var(--storesync-primary) !important;
    box-shadow: 0 0 0 1px var(--storesync-primary) !important;
}

.storesync-input::placeholder {
    color: var(--text-tertiary) !important;
}

textarea.storesync-input {
    height: auto !important;
    min-height: 80px !important;
    resize: vertical !important;
}

select.storesync-input {
    appearance: none !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%239CA3AF'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right 0.5rem center !important;
    background-size: 1rem !important;
    padding-right: 2.5rem !important;
}

/* ===================================
   Navigation Styles
   =================================== */

.nav-item {
    transition: all 0.2s ease;
}

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

.sidebar-item {
    transition: all 0.2s ease;
    position: relative;
}

.sidebar-item.active {
    background-color: rgba(99, 102, 241, 0.05);
    border-left: 3px solid var(--storesync-primary);
    font-weight: 500;
}

.sidebar-item.active i {
    color: var(--storesync-primary);
}

/* ===================================
   Pipeline/Kanban Styles
   =================================== */

.pipeline-view {
    min-height: calc(100vh - 280px);
}

.pipeline-stage {
    min-width: 320px;
}

.deal-card {
    transition: all 0.2s ease;
    cursor: move;
    user-select: none;
}

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

.deal-card.dragging {
    opacity: 0.5;
    transform: rotate(5deg);
    cursor: grabbing;
}

.pipeline-stage [data-stage] {
    transition: background-color 0.2s ease;
}

.pipeline-stage [data-stage].drag-over {
    background-color: rgba(99, 102, 241, 0.05);
    border: 2px dashed var(--storesync-primary);
    border-radius: 0.5rem;
}

/* ===================================
   Toggle Switch Styles
   =================================== */

.switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 20px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
}

input:checked + .slider {
    background-color: var(--storesync-primary);
}

input:checked + .slider:before {
    transform: translateX(20px);
}

.slider.round {
    border-radius: 20px;
}

.slider.round:before {
    border-radius: 50%;
}

/* ===================================
   Dropdown Menu Styles
   =================================== */

.dropdown-menu {
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-light);
    transition: all 0.2s ease;
    opacity: 0;
    transform: translateY(-10px);
}

.dropdown-menu.show {
    opacity: 1;
    transform: translateY(0);
}

/* ===================================
   Tab Styles
   =================================== */

.deal-tab {
    transition: all 0.2s ease;
    position: relative;
}

.deal-tab.active {
    color: var(--storesync-primary);
    border-color: var(--storesync-primary);
}

.view-toggle-btn {
    transition: all 0.2s ease;
}

/* ===================================
   List View Styles
   =================================== */

.list-view table tbody tr {
    transition: background-color 0.2s ease;
}

.list-view table tbody tr:hover {
    background-color: var(--bg-light);
}

/* ===================================
   Modal Styles
   =================================== */

.modal-overlay {
    animation: fadeIn 0.2s ease;
}

.modal-content {
    animation: slideUp 0.3s ease;
}

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

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

/* ===================================
   Quick Create Menu Styles
   =================================== */

.quick-create-option {
    transition: all 0.2s ease;
}

.quick-create-option:hover {
    background-color: var(--bg-light);
    border-color: var(--storesync-primary);
}

.quick-create-option:hover i {
    color: var(--storesync-primary);
}

/* ===================================
   Activity Timeline Styles
   =================================== */

.activity-timeline {
    position: relative;
}

.activity-timeline::before {
    content: '';
    position: absolute;
    left: 16px;
    top: 0;
    bottom: 0;
    width: 2px;
    background-color: var(--border-light);
}

/* ===================================
   Stats Card Styles
   =================================== */

.stats-card {
    transition: all 0.2s ease;
}

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

/* ===================================
   Toast Notification Styles
   =================================== */

#toast {
    animation: slideInRight 0.3s ease;
}

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

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

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

/* ===================================
   Badge Styles
   =================================== */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 9999px;
}

.badge-primary {
    background-color: rgba(99, 102, 241, 0.1);
    color: var(--storesync-primary);
}

.badge-secondary {
    background-color: rgba(253, 158, 39, 0.1);
    color: var(--storesync-secondary);
}

.badge-success {
    background-color: rgba(16, 185, 129, 0.1);
    color: #10B981;
}

.badge-danger {
    background-color: rgba(239, 68, 68, 0.1);
    color: #EF4444;
}

.badge-warning {
    background-color: rgba(245, 158, 11, 0.1);
    color: #F59E0B;
}

/* ===================================
   Loading States
   =================================== */

.skeleton {
    animation: skeleton-loading 1s linear infinite alternate;
}

@keyframes skeleton-loading {
    0% {
        background-color: hsl(200, 20%, 95%);
    }
    100% {
        background-color: hsl(200, 20%, 90%);
    }
}

/* ===================================
   Scrollbar Styles
   =================================== */

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

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

::-webkit-scrollbar-thumb {
    background: var(--border-medium);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

/* ===================================
   Responsive Utilities
   =================================== */

@media (max-width: 768px) {
    .pipeline-view {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .pipeline-stage {
        min-width: 280px;
    }

    #dealsSidebar {
        display: none !important;
    }
}

@media (max-width: 640px) {
    .storesync-btn {
        font-size: 12px !important;
        padding: 6px 10px !important;
    }

    .stats-card {
        padding: 0.75rem !important;
    }
}

/* ===================================
   Print Styles
   =================================== */

@media print {
    .no-print {
        display: none !important;
    }

    body {
        background: white;
    }

    .pipeline-stage {
        break-inside: avoid;
    }
}

/* ===================================
   Accessibility Enhancements
   =================================== */

.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 */
*:focus-visible {
    outline: 2px solid var(--storesync-primary);
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .storesync-btn-primary {
        border: 2px solid transparent;
    }

    .storesync-btn-secondary {
        border: 2px solid var(--text-primary);
    }
}

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

/* ===================================
   Custom Animations
   =================================== */

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

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

.bounce {
    animation: bounce 1s infinite;
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(-25%);
        animation-timing-function: cubic-bezier(0.8, 0, 1, 1);
    }
    50% {
        transform: translateY(0);
        animation-timing-function: cubic-bezier(0, 0, 0.2, 1);
    }
}

/* ===================================
   Utility Classes
   =================================== */

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

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

.transition-all {
    transition: all 0.2s ease;
}

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

/* ===================================
   Dark Mode Support (Future Enhancement)
   =================================== */

@media (prefers-color-scheme: dark) {
    /* Dark mode styles can be added here */
}