/* =============================================
   Product Costing Calculator - Arabic RTL Styles
   Professional Corporate Finance Design
   ============================================= */

/* CSS Custom Properties */
:root {
    /* Colors - Corporate Finance Palette */
    --primary-50: #eff6ff;
    --primary-100: #dbeafe;
    --primary-200: #bfdbfe;
    --primary-300: #93c5fd;
    --primary-400: #60a5fa;
    --primary-500: #3b82f6;
    --primary-600: #2563eb;
    --primary-700: #1d4ed8;
    --primary-800: #1e40af;
    --primary-900: #1e3a8a;

    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;

    --success-500: #22c55e;
    --success-600: #16a34a;
    --warning-500: #f59e0b;
    --warning-600: #d97706;
    --danger-500: #ef4444;
    --danger-600: #dc2626;

    /* Spacing */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;

    /* Border Radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-2xl: 1.5rem;
    --radius-full: 9999px;

    /* Shadows */
    --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);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 350ms ease;
}

/* Reset & Base Styles */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Tajawal', sans-serif;
    background: linear-gradient(135deg, var(--primary-50) 0%, #ffffff 50%, var(--primary-100) 100%);
    min-height: 100vh;
    color: var(--gray-800);
    line-height: 1.6;
}

/* Container */
.container {
    max-width: 900px;
    margin: 0 auto;
    padding: var(--space-6);
}

/* Header */
.header {
    background: linear-gradient(135deg, var(--primary-700) 0%, var(--primary-800) 100%);
    border-radius: var(--radius-2xl);
    padding: var(--space-8);
    margin-bottom: var(--space-8);
    box-shadow: var(--shadow-xl);
    position: relative;
    overflow: hidden;
}

.header::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 60%);
    animation: shimmer 15s ease-in-out infinite;
}

@keyframes shimmer {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(10%, 10%); }
}

.logo-section {
    display: flex;
    align-items: center;
    gap: var(--space-5);
    position: relative;
    z-index: 1;
}

.logo-icon {
    width: 60px;
    height: 60px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-xl);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
}

.logo-icon svg {
    width: 32px;
    height: 32px;
    color: white;
}

.logo-text h1 {
    font-size: 1.75rem;
    font-weight: 800;
    color: white;
    margin-bottom: var(--space-1);
}

.logo-text p {
    font-size: 0.95rem;
    color: var(--primary-200);
    font-weight: 500;
}

/* Main Content */
.main-content {
    display: grid;
    gap: var(--space-8);
}

/* Sections */
.input-section,
.results-section {
    background: white;
    border-radius: var(--radius-2xl);
    padding: var(--space-8);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--gray-100);
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-6);
    padding-bottom: var(--space-4);
    border-bottom: 2px solid var(--gray-100);
}

.section-header h2 {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--gray-800);
}

.section-badge {
    background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
    color: white;
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 600;
}

.results-badge {
    background: linear-gradient(135deg, var(--success-500), var(--success-600));
}

/* Form Styles */
.cost-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-6);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-5);
}

@media (max-width: 640px) {
    .form-row {
        grid-template-columns: 1fr;
    }
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.form-group label {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--gray-700);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.label-icon {
    font-size: 1.1rem;
}

.input-wrapper {
    position: relative;
}

.input-wrapper input {
    width: 100%;
    padding: var(--space-4);
    padding-left: 80px;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-lg);
    font-size: 1rem;
    font-family: 'Tajawal', sans-serif;
    font-weight: 500;
    color: var(--gray-800);
    background: var(--gray-50);
    transition: all var(--transition-normal);
}

.input-wrapper input:focus {
    outline: none;
    border-color: var(--primary-500);
    background: white;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
}

.input-wrapper input::placeholder {
    color: var(--gray-400);
    font-weight: 400;
}

.input-suffix {
    position: absolute;
    left: var(--space-4);
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-500);
    font-size: 0.85rem;
    font-weight: 500;
    background: var(--gray-200);
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-sm);
}

.margin-input {
    max-width: 250px;
}

/* Slider Styles */
.slider-group {
    background: linear-gradient(135deg, var(--gray-50), var(--primary-50));
    padding: var(--space-5);
    border-radius: var(--radius-xl);
    border: 1px solid var(--gray-200);
}

.slider-group label {
    margin-bottom: var(--space-3);
}

.slider-value {
    background: var(--primary-500);
    color: white;
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-full);
    font-size: 0.85rem;
    margin-right: auto;
    margin-left: var(--space-2);
}

.slider-container {
    position: relative;
}

.slider-container input[type="range"] {
    width: 100%;
    height: 8px;
    -webkit-appearance: none;
    appearance: none;
    background: linear-gradient(to left, var(--primary-200), var(--primary-400));
    border-radius: var(--radius-full);
    cursor: pointer;
}

.slider-container input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
    border-radius: 50%;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    border: 3px solid white;
    transition: transform var(--transition-fast);
}

.slider-container input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

.slider-container input[type="range"]::-moz-range-thumb {
    width: 24px;
    height: 24px;
    background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
    border-radius: 50%;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    border: 3px solid white;
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    margin-top: var(--space-2);
    color: var(--gray-500);
    font-size: 0.8rem;
}

/* Warning Message */
.warning-message {
    display: none;
    align-items: center;
    gap: var(--space-2);
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    border: 2px solid var(--warning-500);
    color: var(--warning-600);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-lg);
    margin-top: var(--space-4);
    font-weight: 600;
    animation: flashWarning 1s ease-in-out infinite;
}

.warning-message.show {
    display: flex;
}

.warning-icon {
    font-size: 1.3rem;
    animation: shake 0.5s ease-in-out infinite;
}

@keyframes flashWarning {
    0%, 100% { opacity: 1; background: linear-gradient(135deg, #fef3c7, #fde68a); }
    50% { opacity: 0.8; background: linear-gradient(135deg, #fde68a, #fcd34d); }
}

@keyframes shake {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-5deg); }
    75% { transform: rotate(5deg); }
}

/* Calculate Button */
.calculate-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-3);
    width: 100%;
    padding: var(--space-5);
    background: linear-gradient(135deg, var(--primary-600), var(--primary-700));
    color: white;
    border: none;
    border-radius: var(--radius-xl);
    font-size: 1.15rem;
    font-weight: 700;
    font-family: 'Tajawal', sans-serif;
    cursor: pointer;
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-lg);
    margin-top: var(--space-4);
}

.calculate-btn:hover {
    background: linear-gradient(135deg, var(--primary-700), var(--primary-800));
    transform: translateY(-2px);
    box-shadow: var(--shadow-xl);
}

.calculate-btn:active {
    transform: translateY(0);
}

.btn-icon {
    font-size: 1.4rem;
}

/* Results Grid */
.results-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-5);
}

@media (max-width: 640px) {
    .results-grid {
        grid-template-columns: 1fr;
    }
}

/* Result Cards */
.result-card {
    background: linear-gradient(135deg, var(--gray-50), white);
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-xl);
    padding: var(--space-5);
    text-align: center;
    transition: all var(--transition-normal);
}

.result-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    margin-bottom: var(--space-3);
}

.card-icon {
    font-size: 1.3rem;
}

.card-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--gray-600);
}

.card-value {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--gray-800);
    font-variant-numeric: tabular-nums;
}

.card-currency {
    font-size: 0.85rem;
    color: var(--gray-500);
    margin-top: var(--space-1);
}

/* Highlight Cards */
.highlight-card {
    border-width: 2px;
}

.total-card {
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    border-color: var(--warning-500);
}

.total-card .card-value {
    color: var(--warning-600);
}

.selling-card {
    background: linear-gradient(135deg, #d1fae5, #a7f3d0);
    border-color: var(--success-500);
}

.selling-card .card-value {
    color: var(--success-600);
}

.large-value {
    font-size: 2.25rem;
}

/* Profit Info */
.profit-info {
    background: linear-gradient(135deg, var(--primary-50), var(--primary-100));
    border: 2px solid var(--primary-200);
    border-radius: var(--radius-xl);
    padding: var(--space-5);
    margin-top: var(--space-5);
}

.profit-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.profit-label {
    font-weight: 600;
    color: var(--primary-700);
}

.profit-value {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--primary-800);
}

/* Footer */
.footer {
    text-align: center;
    padding: var(--space-6);
    color: var(--gray-500);
    font-size: 0.9rem;
}

/* Responsive Adjustments */
@media (max-width: 640px) {
    .container {
        padding: var(--space-4);
    }

    .header {
        padding: var(--space-6);
    }

    .logo-text h1 {
        font-size: 1.35rem;
    }

    .input-section,
    .results-section {
        padding: var(--space-5);
    }

    .large-value {
        font-size: 1.85rem;
    }
}

/* Print Styles */
@media print {
    body {
        background: white;
    }

    .container {
        max-width: 100%;
    }

    .calculate-btn {
        display: none;
    }
}
