/* ============================================
   GTC Agro CRM - Modern Grain Trading System
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@300;400;500;600;700;800&display=swap');

/* CSS Variables */
:root {
    --primary-green: #2d5a27;
    --primary-green-light: #4a9142;
    --primary-green-dark: #1e3d1a;
    --primary-pink: #2d5a27;
    --primary-pink-light: #4a9142;
    --primary-pink-dark: #1e3d1a;
    --secondary-gold: #c9a227;
    --secondary-gold-light: #e8c547;
    
    --bg-dark: #1a1f2e;
    --bg-sidebar: #232837;
    --bg-card: #ffffff;
    --bg-main: #f5f7fa;
    
    --text-primary: #2c3e50;
    --text-secondary: #6c7a89;
    --text-light: #95a5a6;
    --text-white: #ffffff;
    
    --border-color: #e8ecef;
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
    
    --status-green: #27ae60;
    --status-yellow: #f39c12;
    --status-blue: #3498db;
    --status-orange: #e67e22;
    --status-red: #e74c3c;
    
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 72px;
    --header-height: 70px;
    
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
}

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

body {
    font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.6;
    display: flex;
    min-height: 100vh;
}

a {
    text-decoration: none;
    color: inherit;
}

button {
    cursor: pointer;
    border: none;
    background: none;
    font-family: inherit;
}

/* ============================================
   SIDEBAR
   ============================================ */

.sidebar {
    width: var(--sidebar-collapsed-width);
    background: linear-gradient(180deg, var(--bg-sidebar) 0%, var(--bg-dark) 100%);
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.sidebar:hover,
.sidebar.expanded,
.sidebar.active {
    width: var(--sidebar-width);
}

.sidebar-header {
    padding: 16px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    min-height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar:hover .sidebar-header,
.sidebar.expanded .sidebar-header,
.sidebar.active .sidebar-header {
    justify-content: flex-start;
    padding: 16px 20px;
}

.logo {
    position: relative;
    width: 38px;
    height: 40px;
    flex-shrink: 0;
    overflow: hidden;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar:hover .logo,
.sidebar.expanded .logo,
.sidebar.active .logo {
    width: 210px;
}

.logo-icon,
.logo-full {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: auto;
    transition: opacity 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.logo-icon {
    opacity: 1;
}

.logo-full {
    opacity: 0;
}

.sidebar:hover .logo-icon,
.sidebar.expanded .logo-icon,
.sidebar.active .logo-icon {
    opacity: 0;
}

.sidebar:hover .logo-full,
.sidebar.expanded .logo-full,
.sidebar.active .logo-full {
    opacity: 1;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 8px;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-nav ul {
    list-style: none;
}

.sidebar-nav li {
    margin-bottom: 4px;
    position: relative;
}

.sidebar-nav > ul > li > a {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    color: rgba(255,255,255,0.7);
    font-weight: 500;
    transition: all 0.2s ease;
    white-space: nowrap;
    position: relative;
}

.sidebar-nav > ul > li > a i:first-child {
    font-size: 1.2rem;
    width: 28px;
    min-width: 28px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-nav > ul > li > a span {
    display: inline-block;
    max-width: 0;
    overflow: hidden;
    opacity: 0;
    transform: translateX(-8px);
    transition: max-width 0.3s ease, opacity 0.2s ease, transform 0.3s ease;
}

.sidebar:hover .sidebar-nav > ul > li > a span,
.sidebar.expanded .sidebar-nav > ul > li > a span,
.sidebar.active .sidebar-nav > ul > li > a span {
    max-width: 240px;
    opacity: 1;
    transform: translateX(0);
}

.sidebar-nav a:hover {
    background: rgba(255,255,255,0.08);
    color: var(--text-white);
}

.sidebar-nav li.active > a {
    background: linear-gradient(135deg, var(--primary-green) 0%, var(--primary-green-light) 100%);
    color: var(--text-white);
    box-shadow: 0 4px 15px rgba(45, 90, 39, 0.4);
}

/* Submenu styles */
.sidebar-nav .has-submenu > a {
    position: relative;
}

.sidebar-nav .submenu-toggle {
    justify-content: space-between;
}

.sidebar-nav .submenu-arrow {
    font-size: 0.7rem;
    transition: opacity 0.2s ease, transform 0.3s ease, max-width 0.3s ease;
    margin-left: auto;
    max-width: 0;
    overflow: hidden;
    opacity: 0;
}

.sidebar:hover .submenu-arrow,
.sidebar.expanded .submenu-arrow,
.sidebar.active .submenu-arrow {
    max-width: 24px;
    opacity: 1;
}

.sidebar-nav .has-submenu.open .submenu-arrow {
    transform: rotate(180deg);
}

.sidebar-nav .submenu {
    list-style: none;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease;
    padding-left: 0;
    margin: 0;
    opacity: 0;
}

.sidebar:hover .sidebar-nav .has-submenu.open .submenu,
.sidebar.expanded .sidebar-nav .has-submenu.open .submenu,
.sidebar.active .sidebar-nav .has-submenu.open .submenu {
    max-height: 500px;
    margin-top: 4px;
    margin-bottom: 4px;
    opacity: 1;
}

.sidebar-nav .submenu li {
    margin-bottom: 0;
}

.sidebar-nav .submenu a {
    padding: 10px 16px 10px 56px;
    font-size: 0.85rem;
    background: rgba(255,255,255,0.03);
    display: flex;
    align-items: center;
    gap: 10px;
    color: rgba(255,255,255,0.6);
    border-radius: var(--radius-sm);
    margin: 2px 0;
    transition: all 0.2s ease;
}

.sidebar-nav .submenu a:hover {
    background: rgba(255,255,255,0.08);
    color: var(--text-white);
    padding-left: 60px;
}

.sidebar-nav .submenu li.active a {
    background: rgba(45, 90, 39, 0.3);
    color: var(--text-white);
}

.sidebar-nav .submenu a i {
    font-size: 0.85rem;
    width: 20px;
    min-width: 20px;
    text-align: center;
}

/* Tooltip wyłączony - menu rozwija się po najechaniu */

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: rgba(255,255,255,0.05);
    border-radius: var(--radius-md);
}

.user-info img {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 2px solid var(--secondary-gold);
}

.user-details {
    display: flex;
    flex-direction: column;
}

.user-name {
    color: var(--text-white);
    font-weight: 600;
    font-size: 0.95rem;
}

.user-role {
    color: rgba(255,255,255,0.5);
    font-size: 0.8rem;
}

/* ============================================
   MAIN CONTENT
   ============================================ */

.main-content {
    flex: 1;
    margin-left: var(--sidebar-collapsed-width);
    min-height: 100vh;
}

/* Top Header */
.top-header {
    height: var(--header-height);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow-sm);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.menu-toggle {
    display: none;
    font-size: 1.3rem;
    color: var(--text-secondary);
}

.search-box {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-main);
    padding: 12px 20px;
    border-radius: 50px;
    min-width: 400px;
}

.search-box i {
    color: var(--text-light);
}

.search-box input {
    border: none;
    background: none;
    outline: none;
    font-size: 0.95rem;
    width: 100%;
    color: var(--text-primary);
}

.search-box input::placeholder {
    color: var(--text-light);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-weight: 500;
    transition: var(--transition-fast);
    position: relative;
}

.header-btn:hover {
    background: var(--bg-main);
    color: var(--primary-green);
}

.header-btn:last-child {
    background: linear-gradient(135deg, var(--primary-green) 0%, var(--primary-green-light) 100%);
    color: var(--text-white);
    padding: 12px 20px;
}

.header-btn:last-child:hover {
    box-shadow: 0 4px 15px rgba(45, 90, 39, 0.4);
    transform: translateY(-1px);
}

.badge {
    position: absolute;
    top: 4px;
    right: 4px;
    background: var(--status-red);
    color: white;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 50px;
    font-weight: 600;
}

/* ============================================
   DASHBOARD
   ============================================ */

.dashboard {
    padding: 30px;
}

.welcome-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.welcome-text h1 {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.welcome-text p {
    color: var(--text-secondary);
    font-size: 1rem;
}

.date-display {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    color: var(--text-secondary);
    font-weight: 500;
}

.date-display i {
    color: var(--primary-green);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 24px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 20px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition-normal);
}

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

.stat-icon {
    width: 64px;
    height: 64px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-icon.green {
    background: linear-gradient(135deg, rgba(45, 90, 39, 0.15) 0%, rgba(39, 174, 96, 0.15) 100%);
    color: var(--primary-green);
}

.stat-icon.yellow {
    background: linear-gradient(135deg, rgba(201, 162, 39, 0.15) 0%, rgba(243, 156, 18, 0.15) 100%);
    color: var(--secondary-gold);
}

.stat-icon.blue {
    background: linear-gradient(135deg, rgba(52, 152, 219, 0.15) 0%, rgba(41, 128, 185, 0.15) 100%);
    color: var(--status-blue);
}

.stat-icon.orange {
    background: linear-gradient(135deg, rgba(230, 126, 34, 0.15) 0%, rgba(211, 84, 0, 0.15) 100%);
    color: var(--status-orange);
}

.stat-info h3 {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.stat-change {
    font-size: 0.8rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 4px;
}

.stat-change.positive {
    color: var(--status-green);
}

.stat-change.negative {
    color: var(--status-red);
}

.stat-change.neutral {
    color: var(--text-light);
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
}

.dashboard-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.card-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-header h2 i {
    color: var(--primary-green);
}

.view-all {
    font-size: 0.85rem;
    color: var(--primary-green);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition-fast);
}

.view-all:hover {
    gap: 10px;
}

/* Orders Card */
.orders-card {
    grid-column: span 2;
}

.orders-table {
    overflow-x: auto;
}

.orders-table table {
    width: 100%;
    border-collapse: collapse;
}

.orders-table th,
.orders-table td {
    text-align: left;
    padding: 14px 12px;
    font-size: 0.9rem;
}

.orders-table th {
    color: var(--text-secondary);
    font-weight: 500;
    border-bottom: 2px solid var(--border-color);
}

.orders-table td {
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

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

.orders-table tr:hover {
    background: var(--bg-main);
}

.status {
    padding: 6px 12px;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.status.delivered {
    background: rgba(39, 174, 96, 0.12);
    color: var(--status-green);
}

.status.in-transit {
    background: rgba(52, 152, 219, 0.12);
    color: var(--status-blue);
}

.status.pending {
    background: rgba(243, 156, 18, 0.12);
    color: var(--status-yellow);
}

.status.processing {
    background: rgba(230, 126, 34, 0.12);
    color: var(--status-orange);
}

/* Chart Card */
.chart-card {
    grid-column: span 1;
}

.chart-filters {
    display: flex;
    gap: 8px;
}

.chart-filters button {
    padding: 6px 14px;
    border-radius: 50px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: var(--transition-fast);
}

.chart-filters button:hover {
    background: var(--bg-main);
}

.chart-filters button.active {
    background: var(--primary-green);
    color: var(--text-white);
}

.chart-container {
    height: 220px;
}

.chart-placeholder {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 10px 0;
}

.price-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-main);
    border-radius: var(--radius-sm);
}

.grain-name {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
    color: var(--text-primary);
}

.grain-name i {
    color: var(--secondary-gold);
}

.grain-price {
    font-weight: 700;
    color: var(--text-primary);
}

.price-trend {
    font-size: 0.8rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
}

.price-trend.positive {
    color: var(--status-green);
}

.price-trend.negative {
    color: var(--status-red);
}

.price-trend.neutral {
    color: var(--text-light);
}

/* Warehouse Card */
.warehouse-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.warehouse-item {
    display: grid;
    grid-template-columns: 1fr 120px 50px;
    gap: 16px;
    align-items: center;
}

.warehouse-info h4 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.warehouse-info p {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.warehouse-bar {
    height: 8px;
    background: var(--bg-main);
    border-radius: 50px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-green) 0%, var(--primary-green-light) 100%);
    border-radius: 50px;
    transition: var(--transition-normal);
}

.bar-fill.high {
    background: linear-gradient(90deg, var(--status-orange) 0%, var(--status-yellow) 100%);
}

.warehouse-percent {
    font-weight: 700;
    color: var(--text-primary);
    text-align: right;
}

/* Actions Card */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 20px;
    border-radius: var(--radius-md);
    font-weight: 500;
    transition: var(--transition-fast);
}

.action-btn i {
    font-size: 1.4rem;
}

.action-btn span {
    font-size: 0.85rem;
}

.action-btn.primary {
    background: linear-gradient(135deg, var(--primary-green) 0%, var(--primary-green-light) 100%);
    color: var(--text-white);
    grid-column: span 2;
}

.action-btn.primary:hover {
    box-shadow: 0 6px 20px rgba(45, 90, 39, 0.4);
    transform: translateY(-2px);
}

.action-btn.secondary {
    background: var(--bg-main);
    color: var(--text-secondary);
}

.action-btn.secondary:hover {
    background: var(--primary-green);
    color: var(--text-white);
}

/* Deliveries Card */
.deliveries-card {
    grid-column: span 2;
}

.deliveries-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.delivery-item {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 16px;
    background: var(--bg-main);
    border-radius: var(--radius-md);
    transition: var(--transition-fast);
}

.delivery-item:hover {
    background: rgba(45, 90, 39, 0.08);
}

.delivery-date {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--primary-green) 0%, var(--primary-green-light) 100%);
    border-radius: var(--radius-sm);
    color: var(--text-white);
}

.delivery-date .day {
    font-size: 1.4rem;
    font-weight: 700;
    line-height: 1;
}

.delivery-date .month {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    opacity: 0.8;
}

.delivery-info {
    flex: 1;
}

.delivery-info h4 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.delivery-info p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.delivery-info p i {
    color: var(--primary-green);
}

.delivery-time {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    padding: 8px 16px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
}

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

@media (max-width: 1400px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .orders-card {
        grid-column: span 2;
    }
    
    .chart-card {
        grid-column: span 1;
    }
    
    .deliveries-card {
        grid-column: span 2;
    }
}

@media (max-width: 1024px) {
    .sidebar {
        width: var(--sidebar-width);
        transform: translateX(-100%);
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .menu-toggle {
        display: block;
    }
    
    .search-box {
        min-width: 280px;
    }
}

@media (max-width: 768px) {
    .dashboard {
        padding: 20px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    .orders-card,
    .chart-card,
    .deliveries-card {
        grid-column: span 1;
    }
    
    .search-box {
        display: none;
    }
    
    .welcome-section {
        flex-direction: column;
        gap: 16px;
        align-items: flex-start;
    }
    
    .header-btn:last-child span {
        display: none;
    }
    
    .warehouse-item {
        grid-template-columns: 1fr;
        gap: 8px;
    }
}

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

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

.stat-card,
.dashboard-card {
    animation: fadeIn 0.4s ease forwards;
}

.stat-card:nth-child(1) { animation-delay: 0.1s; }
.stat-card:nth-child(2) { animation-delay: 0.15s; }
.stat-card:nth-child(3) { animation-delay: 0.2s; }
.stat-card:nth-child(4) { animation-delay: 0.25s; }

.dashboard-card:nth-child(1) { animation-delay: 0.3s; }
.dashboard-card:nth-child(2) { animation-delay: 0.35s; }
.dashboard-card:nth-child(3) { animation-delay: 0.4s; }
.dashboard-card:nth-child(4) { animation-delay: 0.45s; }
.dashboard-card:nth-child(5) { animation-delay: 0.5s; }

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
}

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

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

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

/* ============================================
   Global Button Styles - Unified Save Buttons
   ============================================ */
.btn-success,
.btn-save-comment {
    background: linear-gradient(135deg, #2d5a27 0%, #4a9142 100%) !important;
    color: #fff !important;
    border: none !important;
}

.btn-success:hover,
.btn-save-comment:hover {
    background: linear-gradient(135deg, #1e3d1a 0%, #2d5a27 100%) !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(45, 90, 39, 0.4) !important;
}
